亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
日韩美女一区二区三区四区| 欧美日韩免费在线视频| 舔着乳尖日韩一区| 日韩码欧中文字| 国产精品久久久久精k8| 国产欧美日韩激情| 久久九九全国免费| 亚洲国产经典视频| 日本一区二区三区国色天香| 国产女人aaa级久久久级| 欧美激情一区二区| 国产精品久久久久一区 | 国产一区二区视频在线| 午夜精品一区二区三区免费视频| 亚洲一卡二卡三卡四卡五卡| 一区二区三区日韩欧美精品 | 日韩电影免费一区| 日韩电影一区二区三区四区| 韩国女主播成人在线观看| 国产一区二区h| jiyouzz国产精品久久| 91麻豆视频网站| 欧美日韩激情一区| 久久婷婷久久一区二区三区| 国产精品女同互慰在线看| 亚洲麻豆国产自偷在线| 日本欧美在线看| 成人综合婷婷国产精品久久免费| 一本色道久久综合亚洲91| 欧美一区二区三区在线观看| 国产亚洲综合av| 亚洲综合区在线| 国产老妇另类xxxxx| 一本色道久久综合亚洲aⅴ蜜桃 | 精品免费日韩av| 日本一区二区综合亚洲| 亚洲制服丝袜av| 国产成人啪午夜精品网站男同| 色综合久久综合网| 26uuu国产一区二区三区| 亚洲综合一二三区| 国产成人一区在线| 欧美一区二区久久| 亚洲欧美福利一区二区| 国产一区二区剧情av在线| 欧美综合色免费| 国产精品色呦呦| 久久se精品一区精品二区| 在线免费观看视频一区| 久久久久国产精品麻豆ai换脸| 午夜欧美电影在线观看| 成人免费看黄yyy456| 欧美tk丨vk视频| 午夜欧美一区二区三区在线播放| www.亚洲色图.com| 久久久精品国产免大香伊| 日韩激情视频在线观看| 色欧美片视频在线观看| 中文字幕国产一区| 国产综合色在线| 日韩一区国产二区欧美三区| 亚洲最新视频在线观看| a美女胸又www黄视频久久| 久久久精品tv| 国产麻豆成人传媒免费观看| 日韩一区二区视频在线观看| 亚洲成a人v欧美综合天堂| 欧美刺激脚交jootjob| 日韩精品免费专区| 欧美午夜精品一区二区蜜桃| 亚洲女同ⅹxx女同tv| 成人免费电影视频| 中文字幕av一区 二区| 国产精品一区二区视频| 久久蜜桃av一区精品变态类天堂| 精品制服美女丁香| 精品久久一区二区| 国内精品免费**视频| 欧美精品一区二区不卡| 麻豆精品视频在线| 久久久噜噜噜久噜久久综合| 国产一区二区视频在线播放| 久久青草欧美一区二区三区| 国产成人亚洲综合a∨猫咪| 久久久久97国产精华液好用吗| 久久99久久久久| 久久香蕉国产线看观看99| 国产精品亚洲第一区在线暖暖韩国| 久久久777精品电影网影网 | 日韩电影一区二区三区四区| 欧美精品在线一区二区三区| 日本一道高清亚洲日美韩| 欧美成人性战久久| 国产黑丝在线一区二区三区| 欧美国产精品劲爆| 色菇凉天天综合网| 免费观看在线色综合| 久久先锋影音av| 色综合天天视频在线观看| 亚洲国产成人高清精品| 精品久久久久久无| 成人黄色av网站在线| 国产精品亚洲一区二区三区在线 | 亚洲成人动漫在线观看| 欧美一区二区视频在线观看2022 | 欧亚洲嫩模精品一区三区| 日韩制服丝袜av| 国产日韩欧美在线一区| 色诱亚洲精品久久久久久| 日本视频一区二区| 中文字幕 久热精品 视频在线| 欧美天天综合网| 国产福利一区二区三区在线视频| 亚洲精品免费播放| 亚洲精品在线免费观看视频| 在线观看日韩精品| 国产精品一二二区| 亚洲制服丝袜av| 国产精品色一区二区三区| 欧美网站一区二区| 国产69精品久久99不卡| 婷婷综合在线观看| 中文字幕一区二区三区乱码在线 | 91色乱码一区二区三区| 男男gaygay亚洲| 一区二区三区欧美久久| 国产亚洲一区字幕| 在线91免费看| 91麻豆自制传媒国产之光| 国产一区二区三区av电影| 丝袜美腿亚洲一区| 亚洲小少妇裸体bbw| 欧美极品xxx| 91麻豆精品国产91久久久久久| www.欧美日韩| 国产sm精品调教视频网站| 美日韩一区二区三区| 午夜精品福利在线| 夜夜精品视频一区二区| 最新久久zyz资源站| 国产欧美精品一区| ww亚洲ww在线观看国产| 欧美电影免费观看高清完整版在线观看| 一本一道久久a久久精品| 99免费精品在线| 成人免费黄色大片| 成人sese在线| 波多野结衣视频一区| 成人天堂资源www在线| 激情av综合网| 国产一区二区调教| 国产精品99久久久久久久女警 | 自拍偷自拍亚洲精品播放| 国产午夜精品在线观看| 国产蜜臀97一区二区三区| 国产亚洲综合在线| 亚洲国产成人在线| 一色屋精品亚洲香蕉网站| 亚洲日本青草视频在线怡红院| 一色桃子久久精品亚洲| 亚洲欧美日韩中文播放| 一区二区三区高清在线| 香蕉加勒比综合久久| 日精品一区二区| 久久国产精品99久久人人澡| 韩国欧美一区二区| 成人激情小说乱人伦| 91热门视频在线观看| 欧美三级欧美一级| 日韩三区在线观看| 国产日韩欧美精品电影三级在线| 国产欧美一区二区精品性色| 亚洲欧洲一区二区在线播放| 一区二区三区欧美| 美女网站一区二区| 国产精品99久久久久久宅男| 91蜜桃免费观看视频| 欧美久久久久久久久久| 久久久不卡网国产精品二区 | 欧美一区二区视频在线观看2022| 欧美成人a∨高清免费观看| 久久精品欧美一区二区三区麻豆| 国产精品美女久久久久高潮| 一区二区三区高清| 久久97超碰色| 色香色香欲天天天影视综合网| 欧美福利视频导航| 国产精品三级电影| 亚洲国产美国国产综合一区二区| 精品一区二区国语对白| 94-欧美-setu| 精品少妇一区二区三区在线视频| 国产精品另类一区| 美腿丝袜一区二区三区| 一本到一区二区三区| 久久免费精品国产久精品久久久久| 一区二区日韩av| 成人福利在线看| 26uuu精品一区二区三区四区在线| 亚洲综合色自拍一区|