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

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

?? os_mutex.c

?? UCOS2.85的源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                  MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2007, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_MUTEX.C
* By      : Jean J. Labrosse
* Version : V2.85
*
* LICENSING TERMS:
* ---------------
*   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.  
* If you plan on using  uC/OS-II  in a commercial product you need to contact Micri祄 to properly license 
* its use in your product. We provide ALL the source code for your convenience and to help you experience 
* uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  paying a 
* licensing fee.
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include <ucos_ii.h>
#endif


#if OS_MUTEX_EN > 0
/*
*********************************************************************************************************
*                                            LOCAL CONSTANTS
*********************************************************************************************************
*/

#define  OS_MUTEX_KEEP_LOWER_8   (INT16U)0x00FFu
#define  OS_MUTEX_KEEP_UPPER_8   (INT16U)0xFF00u

#define  OS_MUTEX_AVAILABLE      (INT16U)0x00FFu

/*
*********************************************************************************************************
*                                            LOCAL CONSTANTS
*********************************************************************************************************
*/

static  void  OSMutex_RdyAtPrio(OS_TCB *ptcb, INT8U prio);

/*$PAGE*/
/*
*********************************************************************************************************
*                                   ACCEPT MUTUAL EXCLUSION SEMAPHORE
*
* Description: This  function checks the mutual exclusion semaphore to see if a resource is available.
*              Unlike OSMutexPend(), OSMutexAccept() does not suspend the calling task if the resource is
*              not available or the event did not occur.
*
* Arguments  : pevent     is a pointer to the event control block
*
*              perr       is a pointer to an error code which will be returned to your application:
*                            OS_ERR_NONE         if the call was successful.
*                            OS_ERR_EVENT_TYPE   if 'pevent' is not a pointer to a mutex
*                            OS_ERR_PEVENT_NULL  'pevent' is a NULL pointer
*                            OS_ERR_PEND_ISR     if you called this function from an ISR
*                            OS_ERR_PIP_LOWER    If the priority of the task that owns the Mutex is
*                                                HIGHER (i.e. a lower number) than the PIP.  This error
*                                                indicates that you did not set the PIP higher (lower
*                                                number) than ALL the tasks that compete for the Mutex.
*                                                Unfortunately, this is something that could not be
*                                                detected when the Mutex is created because we don't know
*                                                what tasks will be using the Mutex.
*
* Returns    : == OS_TRUE    if the resource is available, the mutual exclusion semaphore is acquired
*              == OS_FALSE   a) if the resource is not available
*                            b) you didn't pass a pointer to a mutual exclusion semaphore
*                            c) you called this function from an ISR
*
* Warning(s) : This function CANNOT be called from an ISR because mutual exclusion semaphores are
*              intended to be used by tasks only.
*********************************************************************************************************
*/

#if OS_MUTEX_ACCEPT_EN > 0
BOOLEAN  OSMutexAccept (OS_EVENT *pevent, INT8U *perr)
{
    INT8U      pip;                                    /* Priority Inheritance Priority (PIP)          */
#if OS_CRITICAL_METHOD == 3                            /* Allocate storage for CPU status register     */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {                          /* Validate 'perr'                              */
        return (OS_FALSE);
    }
    if (pevent == (OS_EVENT *)0) {                     /* Validate 'pevent'                            */
        *perr = OS_ERR_PEVENT_NULL;
        return (OS_FALSE);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) {  /* Validate event block type                    */
        *perr = OS_ERR_EVENT_TYPE;
        return (OS_FALSE);
    }
    if (OSIntNesting > 0) {                            /* Make sure it's not called from an ISR        */
        *perr = OS_ERR_PEND_ISR;
        return (OS_FALSE);
    }
    OS_ENTER_CRITICAL();                               /* Get value (0 or 1) of Mutex                  */
    pip = (INT8U)(pevent->OSEventCnt >> 8);            /* Get PIP from mutex                           */
    if ((pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8) == OS_MUTEX_AVAILABLE) {
        pevent->OSEventCnt &= OS_MUTEX_KEEP_UPPER_8;   /*      Mask off LSByte (Acquire Mutex)         */
        pevent->OSEventCnt |= OSTCBCur->OSTCBPrio;     /*      Save current task priority in LSByte    */
        pevent->OSEventPtr  = (void *)OSTCBCur;        /*      Link TCB of task owning Mutex           */
        if (OSTCBCur->OSTCBPrio <= pip) {              /*      PIP 'must' have a SMALLER prio ...      */
            OS_EXIT_CRITICAL();                        /*      ... than current task!                  */
            *perr = OS_ERR_PIP_LOWER;
        } else {
            OS_EXIT_CRITICAL();
            *perr = OS_ERR_NONE;
        }
        return (OS_TRUE);
    }
    OS_EXIT_CRITICAL();
    *perr = OS_ERR_NONE;
    return (OS_FALSE);
}
#endif

/*$PAGE*/
/*
*********************************************************************************************************
*                                  CREATE A MUTUAL EXCLUSION SEMAPHORE
*
* Description: This function creates a mutual exclusion semaphore.
*
* Arguments  : prio          is the priority to use when accessing the mutual exclusion semaphore.  In
*                            other words, when the semaphore is acquired and a higher priority task
*                            attempts to obtain the semaphore then the priority of the task owning the
*                            semaphore is raised to this priority.  It is assumed that you will specify
*                            a priority that is LOWER in value than ANY of the tasks competing for the
*                            mutex.
*
*              perr          is a pointer to an error code which will be returned to your application:
*                               OS_ERR_NONE         if the call was successful.
*                               OS_ERR_CREATE_ISR   if you attempted to create a MUTEX from an ISR
*                               OS_ERR_PRIO_EXIST   if a task at the priority inheritance priority
*                                                   already exist.
*                               OS_ERR_PEVENT_NULL  No more event control blocks available.
*                               OS_ERR_PRIO_INVALID if the priority you specify is higher that the
*                                                   maximum allowed (i.e. > OS_LOWEST_PRIO)
*
* Returns    : != (void *)0  is a pointer to the event control clock (OS_EVENT) associated with the
*                            created mutex.
*              == (void *)0  if an error is detected.
*
* Note(s)    : 1) The LEAST significant 8 bits of '.OSEventCnt' are used to hold the priority number
*                 of the task owning the mutex or 0xFF if no task owns the mutex.
*
*              2) The MOST  significant 8 bits of '.OSEventCnt' are used to hold the priority number
*                 to use to reduce priority inversion.
*********************************************************************************************************
*/

OS_EVENT  *OSMutexCreate (INT8U prio, INT8U *perr)
{
    OS_EVENT  *pevent;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {                              /* Validate 'perr'                          */
        return ((OS_EVENT *)0);
    }
    if (prio >= OS_LOWEST_PRIO) {                          /* Validate PIP                             */
        *perr = OS_ERR_PRIO_INVALID;
        return ((OS_EVENT *)0);
    }
#endif
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *perr = OS_ERR_CREATE_ISR;                         /* ... can't CREATE mutex from an ISR       */
        return ((OS_EVENT *)0);
    }
    OS_ENTER_CRITICAL();
    if (OSTCBPrioTbl[prio] != (OS_TCB *)0) {               /* Mutex priority must not already exist    */
        OS_EXIT_CRITICAL();                                /* Task already exist at priority ...       */
        *perr = OS_ERR_PRIO_EXIST;                         /* ... inheritance priority                 */
        return ((OS_EVENT *)0);
    }
    OSTCBPrioTbl[prio] = OS_TCB_RESERVED;                  /* Reserve the table entry                  */
    pevent             = OSEventFreeList;                  /* Get next free event control block        */
    if (pevent == (OS_EVENT *)0) {                         /* See if an ECB was available              */
        OSTCBPrioTbl[prio] = (OS_TCB *)0;                  /* No, Release the table entry              */
        OS_EXIT_CRITICAL();
        *perr              = OS_ERR_PEVENT_NULL;           /* No more event control blocks             */
        return (pevent);
    }
    OSEventFreeList        = (OS_EVENT *)OSEventFreeList->OSEventPtr;   /* Adjust the free list        */
    OS_EXIT_CRITICAL();
    pevent->OSEventType    = OS_EVENT_TYPE_MUTEX;
    pevent->OSEventCnt     = (INT16U)((INT16U)prio << 8) | OS_MUTEX_AVAILABLE; /* Resource is avail.   */
    pevent->OSEventPtr     = (void *)0;                                 /* No task owning the mutex    */
#if OS_EVENT_NAME_SIZE > 1
    pevent->OSEventName[0] = '?';
    pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
    OS_EventWaitListInit(pevent);
    *perr                  = OS_ERR_NONE;
    return (pevent);
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                          DELETE A MUTEX
*
* Description: This function deletes a mutual exclusion semaphore and readies all tasks pending on the it.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired mutex.
*
*              opt           determines delete options as follows:
*                            opt == OS_DEL_NO_PEND   Delete mutex ONLY if no task pending
*                            opt == OS_DEL_ALWAYS    Deletes the mutex even if tasks are waiting.
*                                                    In this case, all the tasks pending will be readied.
*
*              perr          is a pointer to an error code that can contain one of the following values:
*                            OS_ERR_NONE             The call was successful and the mutex was deleted
*                            OS_ERR_DEL_ISR          If you attempted to delete the MUTEX from an ISR
*                            OS_ERR_INVALID_OPT      An invalid option was specified
*                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the mutex
*                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a mutex
*                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
*
* Returns    : pevent        upon error

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲第一综合色| 国产91综合一区在线观看| 国产东北露脸精品视频| 色婷婷国产精品综合在线观看| 欧美一二三在线| 亚洲一区中文在线| 色综合天天综合| 久久精品一级爱片| 免费高清在线一区| 欧美无砖专区一中文字| 婷婷国产在线综合| 99re视频精品| 国产精品国产自产拍高清av| 黄色日韩网站视频| 欧美一区二区久久| 亚洲国产美女搞黄色| 91麻豆高清视频| 国产精品免费久久久久| 国产精品综合二区| 欧美videofree性高清杂交| 日产欧产美韩系列久久99| 欧美亚洲综合久久| 亚洲一二三四久久| 在线观看日韩毛片| 亚洲v中文字幕| 欧美亚洲愉拍一区二区| 亚洲自拍偷拍麻豆| 欧美日韩一区高清| 亚欧色一区w666天堂| 91精品蜜臀在线一区尤物| 五月激情综合婷婷| 555夜色666亚洲国产免| 性做久久久久久免费观看| 欧美日韩国产一区| 日韩av不卡一区二区| 日韩一区二区免费在线观看| 六月婷婷色综合| 久久综合资源网| 国产99久久久国产精品潘金| 国产精品色在线| 色94色欧美sute亚洲线路一ni| 亚洲乱码日产精品bd| 欧美性色综合网| 日韩国产欧美三级| 精品国产91久久久久久久妲己| 国产精品18久久久久| 国产精品日韩成人| 91久久精品一区二区二区| 亚洲一二三四区| 日韩精品一区二区三区视频| 国产精品一区一区| 中文字幕一区二区不卡| 欧美日韩亚洲另类| 国产精品一区专区| 尤物在线观看一区| 日韩免费高清av| 成人动漫视频在线| 天天影视色香欲综合网老头| 久久新电视剧免费观看| 色综合欧美在线视频区| 日韩高清不卡一区| 中文字幕精品一区| 欧美日韩电影在线| 国产二区国产一区在线观看| 一区二区高清视频在线观看| 日韩一区二区三免费高清| 成人激情电影免费在线观看| 午夜精品久久久久久久久久| 久久免费精品国产久精品久久久久| 99精品黄色片免费大全| 久久精品国产澳门| 亚洲精品精品亚洲| 日韩欧美123| 国产精品久久三区| 麻豆精品久久精品色综合| 欧美日韩一级二级三级| 日韩高清在线一区| 久久影视一区二区| proumb性欧美在线观看| 亚洲少妇中出一区| 在线观看一区日韩| 高清成人免费视频| 欧美伊人精品成人久久综合97| 综合在线观看色| 国产精品99久| 亚洲妇熟xx妇色黄| 亚洲欧美欧美一区二区三区| 欧美精品一区二区不卡 | 99久久久久久99| 婷婷中文字幕一区三区| 26uuu精品一区二区三区四区在线| gogo大胆日本视频一区| 国产一区二区精品久久91| 亚洲成在人线在线播放| 国产欧美日韩激情| 欧美一区二区精品在线| 欧美日韩一区二区三区高清| 91久久国产最好的精华液| 成人性生交大片免费看中文网站| 美女脱光内衣内裤视频久久网站| 亚洲小说春色综合另类电影| 亚洲乱码国产乱码精品精可以看| 国产精品久久久久久户外露出| 2020日本不卡一区二区视频| 欧美成人午夜电影| 欧美电影免费观看高清完整版 | 久久99深爱久久99精品| 午夜精品一区二区三区免费视频 | 亚洲日本一区二区| 日本一区二区三区视频视频| 成人禁用看黄a在线| 国产风韵犹存在线视精品| 理论电影国产精品| 麻豆精品在线看| 激情深爱一区二区| 久久激情五月激情| 国产乱国产乱300精品| 国产精品18久久久久久久久久久久| 美日韩一级片在线观看| 美女视频黄a大片欧美| 日本vs亚洲vs韩国一区三区二区| 三级欧美韩日大片在线看| 午夜精品久久久久久久久| 天天免费综合色| 奇米色一区二区三区四区| 精品一区二区影视| 国产精品一区二区视频| 成人免费不卡视频| 欧美中文字幕久久| 久久一区二区三区国产精品| 久久久蜜臀国产一区二区| 欧美一区二区三区在线视频| 欧美精品一区二区蜜臀亚洲| 不卡av在线网| 精品一区二区三区欧美| 国产露脸91国语对白| 99精品视频在线播放观看| 色94色欧美sute亚洲线路一ni| 欧美人伦禁忌dvd放荡欲情| 精品精品国产高清a毛片牛牛 | www.日本不卡| 欧美日韩一区二区在线观看| 欧美不卡一区二区三区四区| 国产精品美女久久久久久久久 | 亚洲欧洲精品成人久久奇米网| 尤物在线观看一区| 蜜桃视频在线观看一区| 国产高清视频一区| 欧美吻胸吃奶大尺度电影| 欧美精品一区二区三| 亚洲美腿欧美偷拍| 久久99精品国产麻豆婷婷洗澡| 成人激情黄色小说| 日韩一二三区不卡| 亚洲欧洲av色图| 久久综合综合久久综合| bt7086福利一区国产| 日韩欧美久久久| 一区二区三区日韩在线观看| 国产麻豆91精品| 欧美日韩国产首页在线观看| 国产无一区二区| 三级影片在线观看欧美日韩一区二区| 丁香婷婷综合激情五月色| 欧美群妇大交群中文字幕| 国产精品久久久久桃色tv| 裸体在线国模精品偷拍| 在线精品观看国产| 国产精品久久99| 国产精品综合av一区二区国产馆| 欧美日韩中字一区| 亚洲欧洲三级电影| 国产乱码精品一区二区三区av | 成人一道本在线| 日韩欧美国产麻豆| 亚洲国产精品麻豆| 91麻豆免费观看| 国产精品午夜在线观看| 男人的天堂亚洲一区| 欧美色图一区二区三区| 1区2区3区欧美| 成人蜜臀av电影| 国产人成亚洲第一网站在线播放| 免费xxxx性欧美18vr| 欧美日韩一区二区三区视频 | 欧美日韩在线观看一区二区 | 亚洲成人av资源| 色88888久久久久久影院按摩| 亚洲国产精品成人综合色在线婷婷| 免费欧美日韩国产三级电影| 欧美性猛交xxxx乱大交退制版| 国产精品电影院| 成人a级免费电影| 国产精品婷婷午夜在线观看| 欧美亚洲国产一区在线观看网站| 成人免费在线视频观看| 91在线国产观看| 亚洲精选免费视频| 在线观看亚洲专区| 亚洲国产成人porn|