亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mutex.cxx

?? eCos/RedBoot for勤研ARM AnywhereII(4510) 含全部源代碼
?? CXX
?? 第 1 頁 / 共 2 頁
字號:
//==========================================================================
//
//      sync/mutex.cxx
//
//      Mutex and condition variable implementation
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s):    nickg
// Contributors: nickg, jlarmour
// Date:         1999-02-17
// Purpose:      Mutex implementation
// Description:  This file contains the implementations of the mutex
//               and condition variable classes.
//
//####DESCRIPTIONEND####
//
//==========================================================================

#include <pkgconf/kernel.h>

#include <cyg/kernel/ktypes.h>         // base kernel types
#include <cyg/infra/cyg_trac.h>        // tracing macros
#include <cyg/infra/cyg_ass.h>         // assertion macros
#include <cyg/kernel/instrmnt.h>       // instrumentation

#include <cyg/kernel/mutex.hxx>        // our header

#include <cyg/kernel/thread.inl>       // thread inlines
#include <cyg/kernel/sched.inl>        // scheduler inlines
#include <cyg/kernel/clock.inl>        // clock inlines

// -------------------------------------------------------------------------
// Mutex protocol test macros.
// If the dynamic protocol option is enabled, then these generate appropriate
// tests on the protocol field. If there is no dynamic choice then they simply
// result in empty statements.

#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC

#define IF_PROTOCOL_INHERIT if( protocol == INHERIT )
#define IF_PROTOCOL_CEILING if( protocol == CEILING )
#define IF_PROTOCOL_ACTIVE  if( protocol != NONE )

#else

#define IF_PROTOCOL_INHERIT
#define IF_PROTOCOL_CEILING
#define IF_PROTOCOL_ACTIVE

#endif

// -------------------------------------------------------------------------
// Constructor

Cyg_Mutex::Cyg_Mutex()
{
    CYG_REPORT_FUNCTION();
        
    locked      = false;
    owner       = NULL;

#if defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT) && \    defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC)

#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_INHERIT
    protocol    = INHERIT;
#endif    
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_CEILING
    protocol    = CEILING;
    ceiling     = CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY;
#endif    
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_NONE
    protocol    = NONE;
#endif

#else // not (DYNAMIC and DEFAULT defined)

#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING    
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY

    // if there is a default priority ceiling defined, use that to initialize
    // the ceiling.
    ceiling = CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY;    

#else

    // Otherwise set it to zero.
    ceiling = 0;
    
#endif    
#endif

#endif // DYNAMIC and DEFAULT defined
    
    CYG_REPORT_RETURN();
}

// -------------------------------------------------------------------------
// Construct with defined protocol

#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC

Cyg_Mutex::Cyg_Mutex( cyg_protcol protocol_arg )
{
    CYG_REPORT_FUNCTION();
        
    locked      = false;
    owner       = NULL;

    protocol    = protocol_arg;

#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING    
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY

    // if there is a default priority ceiling defined, use that to initialize
    // the ceiling.
    ceiling = CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY;    

#else

    // Otherwise set it to zero.
    ceiling = 0;
    
#endif    
#endif
    
    CYG_REPORT_RETURN();
}

#endif

// -------------------------------------------------------------------------
// Destructor

Cyg_Mutex::~Cyg_Mutex()
{
    CYG_REPORT_FUNCTION();
        
    CYG_ASSERT( owner == NULL, "Deleting mutex with owner");
    CYG_ASSERT( queue.empty(), "Deleting mutex with waiting threads");
    CYG_REPORT_RETURN();
}

// -------------------------------------------------------------------------

#ifdef CYGDBG_USE_ASSERTS

cyg_bool
Cyg_Mutex::check_this( cyg_assert_class_zeal zeal) const
{
//    CYG_REPORT_FUNCTION();
        
    // check that we have a non-NULL pointer first
    if( this == NULL ) return false;
    
    switch( zeal )
    {
    case cyg_system_test:
    case cyg_extreme:
    case cyg_thorough:
    case cyg_quick:
    case cyg_trivial:
        if(  locked && owner == NULL ) return false;
        if( !locked && owner != NULL ) return false;        
    case cyg_none:
    default:
        break;
    };

    return true;
}

#endif

// -------------------------------------------------------------------------
// Lock and/or wait

cyg_bool
Cyg_Mutex::lock(void)
{
    CYG_REPORT_FUNCTYPE("returning %d");

    cyg_bool result = true;
    Cyg_Thread *self = Cyg_Thread::self();
    
    // Prevent preemption
    Cyg_Scheduler::lock();

    CYG_ASSERTCLASS( this, "Bad this pointer");
    
    CYG_INSTRUMENT_MUTEX(LOCK, this, 0);

    // Loop while the mutex is locked, sleeping each time around
    // the loop. This copes with the possibility of a higher priority
    // thread grabbing the mutex between the wakeup in unlock() and
    // this thread actually starting.
    
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL

    IF_PROTOCOL_ACTIVE
	self->count_mutex();

#endif

#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING
    
    IF_PROTOCOL_CEILING
        self->set_priority_ceiling(ceiling);

#endif        
               
    while( locked && result )
    {
        CYG_ASSERT( self != owner, "Locking mutex I already own");
        
        self->set_sleep_reason( Cyg_Thread::WAIT );
        
        self->sleep();
        
        queue.enqueue( self );

#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT

        IF_PROTOCOL_INHERIT
            owner->inherit_priority(self);

#endif

        CYG_INSTRUMENT_MUTEX(WAIT, this, 0);

        // Allow other threads to run
        Cyg_Scheduler::reschedule();
        
        CYG_ASSERTCLASS( this, "Bad this pointer");

        switch( self->get_wake_reason() )
        {
        case Cyg_Thread::DESTRUCT:
        case Cyg_Thread::BREAK:
            result = false;
            break;
            
        case Cyg_Thread::EXIT:            
            self->exit();
            break;

        default:
            break;
        }

    }

    if( result )
    {
        locked      = true;
        owner       = self;

        CYG_INSTRUMENT_MUTEX(LOCKED, this, 0);
    }
    else
    {
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL

       IF_PROTOCOL_ACTIVE
           self->uncount_mutex();

#endif    
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT

        IF_PROTOCOL_INHERIT
            self->disinherit_priority();

#endif
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING

        IF_PROTOCOL_CEILING
            self->clear_priority_ceiling();

#endif
    }
    
    // Unlock the scheduler and maybe switch threads
    Cyg_Scheduler::unlock();

    CYG_ASSERTCLASS( this, "Bad this pointer");    

    CYG_REPORT_RETVAL(result);

    return result;
}

// -------------------------------------------------------------------------
// Try to lock and return success

cyg_bool
Cyg_Mutex::trylock(void)
{
    CYG_REPORT_FUNCTYPE("returning %d");
        
    CYG_ASSERTCLASS( this, "Bad this pointer");
    
    cyg_bool result = true;
    
    // Prevent preemption
    Cyg_Scheduler::lock();

    // If the mutex is not locked, grab it
    // for ourself. Otherwise return failure.
    if( !locked )
    {
        Cyg_Thread *self = Cyg_Thread::self();
        
        locked  = true;
        owner   = self;

#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL

       IF_PROTOCOL_ACTIVE
            self->count_mutex();

#endif
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING

        IF_PROTOCOL_CEILING
            self->set_priority_ceiling(ceiling);
        
#endif        
        
    }
    else result = false;

    CYG_INSTRUMENT_MUTEX(TRY, this, result);
    
    // Unlock the scheduler and maybe switch threads
    Cyg_Scheduler::unlock();
    
    CYG_REPORT_RETVAL(result);
    return result;    
}

// -------------------------------------------------------------------------
// unlock

void
Cyg_Mutex::unlock(void)
{
    CYG_REPORT_FUNCTION();
        
    // Prevent preemption
    Cyg_Scheduler::lock();

    CYG_INSTRUMENT_MUTEX(UNLOCK, this, 0);

    CYG_ASSERTCLASS( this, "Bad this pointer");
    CYG_ASSERT( locked, "Unlock mutex that is not locked");
    CYG_ASSERT( owner == Cyg_Thread::self(), "Unlock mutex I do not own");
        
    if( !queue.empty() ) {

        // The queue is non-empty, so grab the next
        // thread from it and wake it up.

        Cyg_Thread *thread = queue.dequeue();

        CYG_ASSERTCLASS( thread, "Bad thread pointer");

#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT

        // Give the owner-to-be a chance to inherit from the remaining
        // queue or the relinquishing thread:

        IF_PROTOCOL_INHERIT
            thread->relay_priority(owner, &queue);

#endif

        thread->set_wake_reason( Cyg_Thread::DONE );
        
        thread->wake();

        CYG_INSTRUMENT_MUTEX(WAKE, this, thread);
        
    }

#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL

    IF_PROTOCOL_ACTIVE
	owner->uncount_mutex();

#endif    
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT

    IF_PROTOCOL_INHERIT
        owner->disinherit_priority();
    
#endif
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本高清视频一区二区| 678五月天丁香亚洲综合网| 国产一区二区三区观看| 日本最新不卡在线| 亚洲最大成人综合| 亚洲国产乱码最新视频| 亚洲午夜久久久久| 午夜欧美视频在线观看| 亚洲福利电影网| 日韩精品电影一区亚洲| 日本不卡一区二区| 免费观看在线色综合| 麻豆国产精品777777在线| 久久97超碰国产精品超碰| 久久草av在线| 国产成人精品午夜视频免费| 岛国av在线一区| www.av亚洲| 91麻豆国产精品久久| 91精品福利视频| 欧美精品久久99| 精品久久五月天| 国产午夜亚洲精品午夜鲁丝片| 国产免费成人在线视频| 国产精品久久久久久久久免费相片| 国产精品免费av| 亚洲精品成人天堂一二三| 亚洲一区二区在线播放相泽| 亚洲h动漫在线| 久久国产尿小便嘘嘘尿| 国产福利91精品一区二区三区| 成人精品一区二区三区四区| 在线视频一区二区三区| 在线播放欧美女士性生活| 久久蜜桃av一区精品变态类天堂| 久久精品一区蜜桃臀影院| 亚洲日穴在线视频| 日韩成人精品在线观看| 国产成人8x视频一区二区| 色猫猫国产区一区二在线视频| 91精品免费在线| 欧美国产一区二区| 亚洲一二三区视频在线观看| 国产自产高清不卡| 色噜噜狠狠一区二区三区果冻| 91精品久久久久久久久99蜜臂| 国产清纯白嫩初高生在线观看91| 一区二区免费视频| 国精产品一区一区三区mba视频| youjizz国产精品| 777亚洲妇女| 国产欧美日韩另类视频免费观看| 亚洲自拍与偷拍| 国产福利精品导航| 欧美伦理影视网| 国产日韩欧美一区二区三区综合| 亚洲免费观看视频| 国产自产高清不卡| 欧美男男青年gay1069videost| www久久精品| 亚洲国产欧美另类丝袜| 北条麻妃一区二区三区| 欧美一区二区播放| 亚洲黄色免费电影| 国产成人在线电影| 精品视频1区2区3区| 亚洲国产成人一区二区三区| 午夜视频在线观看一区二区 | 麻豆视频一区二区| 91色乱码一区二区三区| 26uuu欧美日本| 婷婷中文字幕综合| 色狠狠色狠狠综合| 一区视频在线播放| 国产传媒久久文化传媒| 欧美精品日韩综合在线| 中文字幕综合网| 国产成人综合在线| 日韩欧美你懂的| 婷婷久久综合九色综合绿巨人| 97精品视频在线观看自产线路二| 欧美成人一区二区三区| 偷拍日韩校园综合在线| 色婷婷综合激情| 国产精品国产三级国产专播品爱网| 男男成人高潮片免费网站| 欧美性受xxxx黑人xyx| 亚洲人吸女人奶水| 成人精品小蝌蚪| 国产精品福利av| 成人美女视频在线看| 中文字幕va一区二区三区| 国产九九视频一区二区三区| 欧美mv和日韩mv的网站| 青青草成人在线观看| 欧美精品丝袜中出| 日韩av中文字幕一区二区| 欧美久久久影院| 五月天欧美精品| 制服丝袜成人动漫| 五月婷婷激情综合| 欧美一区午夜精品| 久色婷婷小香蕉久久| 2023国产一二三区日本精品2022| 美女在线观看视频一区二区| 日韩美女一区二区三区| 久久99久久99| 精品少妇一区二区三区日产乱码 | 国产mv日韩mv欧美| 国产人成一区二区三区影院| 成人免费视频视频在线观看免费| 国产精品色哟哟| 99久久er热在这里只有精品15| 亚洲色大成网站www久久九九| 一本一道波多野结衣一区二区| 亚洲精品视频观看| 欧美日韩在线综合| 日本免费在线视频不卡一不卡二| 欧美放荡的少妇| 捆绑紧缚一区二区三区视频 | 亚洲午夜久久久久中文字幕久| 欧美性生活影院| 日韩电影在线免费观看| 日韩一级免费观看| 国产真实乱偷精品视频免| 日韩欧美国产系列| 国产精品自在欧美一区| 中文字幕亚洲欧美在线不卡| 色婷婷国产精品久久包臀| 亚洲不卡在线观看| 日韩欧美亚洲另类制服综合在线| 国产一区在线观看麻豆| 国产精品沙发午睡系列990531| 色av一区二区| 亚洲成人你懂的| 日韩视频永久免费| 成人免费观看视频| 亚洲国产日产av| 久久新电视剧免费观看| 成人av在线电影| 亚洲国产精品久久久久婷婷884| 欧美精品在欧美一区二区少妇| 国产乱码精品一区二区三区av| 亚洲欧美在线视频观看| 欧美精品黑人性xxxx| 国产91精品在线观看| 亚洲高清视频在线| 精品福利在线导航| 色婷婷av一区二区三区之一色屋| 男女性色大片免费观看一区二区 | 欧美一级欧美三级在线观看 | 欧美日韩和欧美的一区二区| 韩国精品久久久| 亚洲老司机在线| 精品成a人在线观看| 色综合色综合色综合| 免费成人在线观看视频| 国产精品蜜臀在线观看| 日韩一级成人av| 色综合久久精品| 精东粉嫩av免费一区二区三区| 亚洲私人影院在线观看| 欧美xxx久久| 欧美三级视频在线| 粗大黑人巨茎大战欧美成人| 青青草精品视频| 一卡二卡三卡日韩欧美| 久久久精品中文字幕麻豆发布| 欧美日韩大陆在线| 91亚洲大成网污www| 国产一区二区三区在线观看免费视频 | 国产成人在线网站| 蜜臀av性久久久久蜜臀aⅴ四虎 | 亚洲成a人片在线观看中文| 国产精品美女久久久久久| 欧美一区二区三区性视频| 在线观看国产日韩| 99热在这里有精品免费| 国产伦理精品不卡| 久久精品国产一区二区三区免费看| 亚洲与欧洲av电影| 国产精品久久久久久亚洲伦| 久久久久一区二区三区四区| 91精品国产91综合久久蜜臀| 91亚洲精品久久久蜜桃| 成人免费视频播放| 国产精品1024| 国产在线播放一区二区三区| 蜜臀av亚洲一区中文字幕| 天天综合日日夜夜精品| 亚洲综合小说图片| 亚洲黄色小视频| 一区二区国产视频| 一区二区在线观看av| 自拍偷自拍亚洲精品播放| 中文字幕第一区| 欧美激情一区在线观看| 欧美韩国日本一区| 国产精品久久久久aaaa樱花 | 亚洲综合一区二区三区|