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

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

?? os_mutex.c

?? uc/os2.83最新源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                  MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2006, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_MUTEX.C
* By      : Jean J. Labrosse
* Version : V2.83
*********************************************************************************************************
*/

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


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

#define  OS_MUTEX_KEEP_LOWER_8   0x00FFu
#define  OS_MUTEX_KEEP_UPPER_8   0xFF00u

#define  OS_MUTEX_AVAILABLE      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
*
*              err        is a pointer to an error code which will be returned to your application:
*                            OS_NO_ERR          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    : == 1       if the resource is available, the mutual exclusion semaphore is acquired
*              == 0       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
INT8U  OSMutexAccept (OS_EVENT *pevent, INT8U *err)
{
    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 (err == (INT8U *)0) {                           /* Validate 'err'                               */
        return (0);
    }
    if (pevent == (OS_EVENT *)0) {                     /* Validate 'pevent'                            */
        *err = OS_ERR_PEVENT_NULL;
        return (0);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) {  /* Validate event block type                    */
        *err = OS_ERR_EVENT_TYPE;
        return (0);
    }
    if (OSIntNesting > 0) {                            /* Make sure it's not called from an ISR        */
        *err = OS_ERR_PEND_ISR;
        return (0);
    }
    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!                  */
            *err  = OS_ERR_PIP_LOWER;
        } else {
            OS_EXIT_CRITICAL();
            *err  = OS_NO_ERR;
        }
        return (1);
    }
    OS_EXIT_CRITICAL();
    *err = OS_NO_ERR;
    return (0);
}
#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.
*
*              err           is a pointer to an error code which will be returned to your application:
*                               OS_NO_ERR           if the call was successful.
*                               OS_ERR_CREATE_ISR   if you attempted to create a MUTEX from an ISR
*                               OS_PRIO_EXIST       if a task at the priority inheritance priority
*                                                   already exist.
*                               OS_ERR_PEVENT_NULL  No more event control blocks available.
*                               OS_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 *err)
{
    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 (err == (INT8U *)0) {                               /* Validate 'err'                           */
        return ((OS_EVENT *)0);
    }
    if (prio >= OS_LOWEST_PRIO) {                          /* Validate PIP                             */
        *err = OS_PRIO_INVALID;
        return ((OS_EVENT *)0);
    }
#endif
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = 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 ...       */
        *err = OS_PRIO_EXIST;                              /* ... inheritance priority                 */
        return ((OS_EVENT *)0);
    }
    OSTCBPrioTbl[prio] = (OS_TCB *)1;                      /* 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();
        *err               = 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);
    *err                   = OS_NO_ERR;
    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.
*
*              err           is a pointer to an error code that can contain one of the following values:
*                            OS_NO_ERR               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
*              (OS_EVENT *)0 if the mutex was successfully deleted.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美激情综合五月色丁香小说| 国产一区二区三区视频在线播放| 亚洲丝袜制服诱惑| 国产精品对白交换视频 | 久久精品人人做人人综合| 欧美大度的电影原声| 日韩女优毛片在线| 26uuu另类欧美| 久久精品视频一区二区| 久久久精品黄色| 欧美激情在线一区二区三区| 国产日韩欧美精品电影三级在线| 国产女同互慰高潮91漫画| 国产精品国产三级国产普通话蜜臀 | 国产精品网站在线| 椎名由奈av一区二区三区| 日韩伦理电影网| 亚洲与欧洲av电影| 日本视频一区二区| 久久99国产精品免费| 国产一区二区三区精品欧美日韩一区二区三区 | 91精品国产91久久综合桃花| 欧美日韩不卡在线| 精品91自产拍在线观看一区| 国产欧美日韩视频在线观看| 亚洲日本电影在线| 日韩影院免费视频| 狠狠v欧美v日韩v亚洲ⅴ| 成人精品视频.| 欧美在线观看18| 日韩精品专区在线| 国产精品久久久久影院亚瑟 | 国产最新精品精品你懂的| 成人av影视在线观看| 欧美视频你懂的| 日韩精品一区二区三区三区免费 | 亚洲色图色小说| 免费高清在线视频一区·| 国产精品中文字幕欧美| 色哟哟日韩精品| 欧美精品一区二区三区蜜桃| 中文字幕一区二区视频| 日本人妖一区二区| 成人综合婷婷国产精品久久蜜臀 | 亚洲国产成人自拍| 午夜电影网亚洲视频| 国产传媒久久文化传媒| 欧美性视频一区二区三区| 精品不卡在线视频| 亚洲永久精品大片| 国产精品996| 3d成人动漫网站| 亚洲欧美综合网| 久久99热狠狠色一区二区| 91成人国产精品| 久久久影院官网| 香蕉久久夜色精品国产使用方法 | 欧美性做爰猛烈叫床潮| 2019国产精品| 亚洲va国产天堂va久久en| 豆国产96在线|亚洲| 欧美一区二区高清| 亚洲视频免费在线观看| 国模一区二区三区白浆| 欧美美女激情18p| 亚洲啪啪综合av一区二区三区| 精品系列免费在线观看| 欧美日韩你懂得| 亚洲免费视频中文字幕| 国产一区999| 日韩欧美国产1| 丝袜美腿高跟呻吟高潮一区| 91网页版在线| 国产精品久久久久久户外露出 | 麻豆一区二区在线| 欧美男男青年gay1069videost| 1区2区3区欧美| 风流少妇一区二区| 日韩久久免费av| 视频一区二区国产| 在线免费一区三区| 一区二区三区自拍| 99免费精品在线观看| 国产人久久人人人人爽| 精东粉嫩av免费一区二区三区| 91麻豆精品国产91久久久资源速度 | 日韩在线a电影| 欧美三级中文字幕在线观看| 国产精品不卡视频| 成人精品小蝌蚪| 欧美激情一区二区三区不卡| 国内精品久久久久影院色| 日韩视频免费直播| 三级在线观看一区二区| 欧日韩精品视频| 亚洲国产精品久久人人爱 | 亚洲精品久久嫩草网站秘色| a美女胸又www黄视频久久| 国产精品色在线观看| 国产99久久久精品| 国产精品麻豆网站| 91亚洲精品久久久蜜桃| 亚洲免费在线视频| 欧亚一区二区三区| 婷婷一区二区三区| 欧美一区二区视频在线观看| 日韩激情在线观看| 日韩免费观看高清完整版 | 精品国产乱码久久久久久牛牛 | 欧美久久久久免费| 六月婷婷色综合| 久久久久久综合| 豆国产96在线|亚洲| 国产精品国产三级国产有无不卡 | 国产精品久久久久aaaa| www.综合网.com| 一区二区三区免费看视频| 色久综合一二码| 丝袜脚交一区二区| 欧美大片一区二区三区| 国产一区二区三区蝌蚪| 国产精品天美传媒沈樵| 色综合天天综合网天天看片| 亚洲国产美女搞黄色| 欧美一区二区三区日韩| 精品夜夜嗨av一区二区三区| 国产亚洲1区2区3区| 91网页版在线| 免费在线观看精品| 久久精品视频一区| 日本乱码高清不卡字幕| 日韩二区在线观看| 国产日韩欧美不卡在线| 日本福利一区二区| 久久69国产一区二区蜜臀| 国产区在线观看成人精品| 色一情一伦一子一伦一区| 日韩成人av影视| 国产欧美一区二区三区在线老狼| 91在线porny国产在线看| 日日嗨av一区二区三区四区| 久久中文字幕电影| 色狠狠桃花综合| 老司机精品视频在线| 亚洲欧洲av另类| 欧美二区三区的天堂| 欧美狂野另类xxxxoooo| 九色porny丨国产精品| 亚洲欧洲精品一区二区三区 | 日韩一区二区免费高清| 床上的激情91.| 日产欧产美韩系列久久99| 国产亚洲欧美一级| 欧美自拍丝袜亚洲| 国产乱人伦精品一区二区在线观看 | 欧美日韩国产电影| 大桥未久av一区二区三区中文| 亚洲国产美女搞黄色| 国产精品亲子伦对白| 日韩午夜在线播放| 日本韩国欧美国产| 国产成人精品在线看| 丝袜a∨在线一区二区三区不卡| 欧美国产丝袜视频| 日韩免费高清av| 欧美在线影院一区二区| 国产综合久久久久久久久久久久| 亚洲一区二区三区在线播放| 欧美国产亚洲另类动漫| 日韩视频一区二区三区在线播放| 色妞www精品视频| 成人午夜精品一区二区三区| 美脚の诱脚舐め脚责91| 亚洲综合激情另类小说区| 国产精品色呦呦| 久久先锋影音av| 日韩欧美成人激情| 欧美二区乱c少妇| 欧美亚洲免费在线一区| 91在线视频播放地址| 国产成人亚洲精品狼色在线| 久久99久久久欧美国产| 视频一区中文字幕| 亚洲国产日韩综合久久精品| 国产精品久久久一本精品| 国产日韩在线不卡| 精品国产免费一区二区三区四区| 欧美久久一二区| 精品视频1区2区| 欧美视频在线不卡| 在线欧美一区二区| 91电影在线观看| 在线免费亚洲电影| 日本韩国一区二区| 色菇凉天天综合网| 色婷婷久久久综合中文字幕| 99精品视频中文字幕| 成人一道本在线| 成人福利视频网站| 成人手机电影网|