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

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

?? os_mutex.c

?? 最新版ucos2.86源碼和程序說明文件
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                  MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
*
*                              (c) Copyright 1992-2007, Micrium, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_MUTEX.C
* By      : Jean J. Labrosse
* Version : V2.86
*
* 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
*              (OS_EVENT *)0 if the mutex was successfully deleted.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
石原莉奈一区二区三区在线观看 | 久久嫩草精品久久久久| 色8久久精品久久久久久蜜 | 国产精品欧美一级免费| 国产午夜精品一区二区| 国产欧美精品在线观看| 国产偷国产偷亚洲高清人白洁 | 美女网站在线免费欧美精品| 天天影视涩香欲综合网| 亚洲成a人片在线不卡一二三区| 国产精品美女久久久久久久| 国产亚洲欧美日韩在线一区| 国产三级一区二区| 国产精品丝袜一区| 亚洲精品综合在线| 亚洲国产成人tv| 日韩av电影天堂| 日本不卡在线视频| 国产河南妇女毛片精品久久久| 国产成人在线色| 91视频免费观看| 欧美日韩在线综合| 精品电影一区二区| 国产精品国产三级国产a| 亚洲欧美福利一区二区| 亚洲成人午夜电影| 精品在线免费观看| 波多野结衣91| 欧美一区二区在线免费播放| 精品少妇一区二区| 中文字幕制服丝袜一区二区三区 | 一区二区三区视频在线观看| 亚洲mv在线观看| 精品一区二区三区香蕉蜜桃| 91丨九色丨国产丨porny| 欧美一区二区三区喷汁尤物| 久久久精品2019中文字幕之3| 亚洲欧美日韩国产综合在线| 免费成人在线网站| 91在线看国产| 日韩欧美在线1卡| 亚洲人亚洲人成电影网站色| 日av在线不卡| 色综合天天综合网天天狠天天| 欧美一区二区三区啪啪| 亚洲人精品一区| 国产一区二区主播在线| 欧美性极品少妇| 中文一区二区在线观看| 亚洲国产一区视频| 成人av在线播放网站| 精品国产91乱码一区二区三区| 国产精品久久久99| 极品尤物av久久免费看| 91福利资源站| 亚洲婷婷国产精品电影人久久| 韩国成人精品a∨在线观看| 欧美色综合影院| 国产精品国产a级| 国产精品一区二区视频| 欧美一区二区视频网站| 亚洲午夜一区二区三区| 色8久久人人97超碰香蕉987| 国产欧美一区二区三区鸳鸯浴 | 日韩一区国产二区欧美三区| 一区二区三区在线视频观看58 | 日韩一区二区三区四区 | 欧美一区二区高清| 亚洲成人激情综合网| 91色九色蝌蚪| 自拍视频在线观看一区二区| av在线不卡观看免费观看| 久久精品夜色噜噜亚洲a∨| 国产一区激情在线| 久久中文字幕电影| 国产一区二区在线看| 久久久久国产一区二区三区四区| 美女网站在线免费欧美精品| 欧美大胆一级视频| 国产在线观看一区二区| 欧美成人在线直播| 国产乱码精品一品二品| 欧美激情一区二区| av在线播放一区二区三区| 国产精品乱码人人做人人爱 | 色欧美88888久久久久久影院| 成人免费在线视频| 日本韩国一区二区| 亚洲大型综合色站| 日韩欧美国产综合在线一区二区三区| 水野朝阳av一区二区三区| 日韩欧美高清dvd碟片| 精品一区二区日韩| 国产女同性恋一区二区| 99热在这里有精品免费| 一区二区三区加勒比av| 欧美日韩国产综合一区二区 | 亚洲高清三级视频| 777xxx欧美| 粉嫩一区二区三区在线看| 国产精品久久久一本精品| 色婷婷av一区二区| 免费日韩伦理电影| 中文字幕精品—区二区四季| 91久久精品一区二区| 天天综合日日夜夜精品| 久久精品视频在线看| 色婷婷av一区二区三区软件| 日韩电影在线看| 欧美极品少妇xxxxⅹ高跟鞋| 色综合久久中文综合久久牛| 奇米777欧美一区二区| 国产精品三级电影| 欧美猛男男办公室激情| 丁香另类激情小说| 日韩影院免费视频| 中文字幕不卡三区| 欧美一区二区三级| 99久久777色| 国产一区二区毛片| 亚洲国产婷婷综合在线精品| 国产日本欧洲亚洲| 欧美一区二区三区免费| 一本色道综合亚洲| 国产**成人网毛片九色 | 欧美精品色综合| 国产精品亚洲一区二区三区妖精| 樱花草国产18久久久久| 国产亚洲精品7777| 欧美一级二级三级蜜桃| 色综合久久天天| 国产一区二区三区美女| 午夜电影久久久| 亚洲日韩欧美一区二区在线| 精品99999| 欧美福利视频导航| 欧美中文字幕一区| 99久久精品国产一区| 国产成人在线影院| 国产精品99久久久久久久女警| 日韩国产欧美视频| 亚洲第一会所有码转帖| 亚洲天堂福利av| 国产嫩草影院久久久久| 久久先锋资源网| 精品国产91亚洲一区二区三区婷婷| 欧美亚洲图片小说| 欧美午夜不卡在线观看免费| 91小视频在线| 91在线播放网址| 91麻豆国产香蕉久久精品| 成人精品一区二区三区中文字幕| 国产精品一品视频| 国产成人免费av在线| 福利视频网站一区二区三区| 国产成人免费视频精品含羞草妖精| 经典一区二区三区| 国产专区综合网| 国产91清纯白嫩初高中在线观看| 国产99久久久国产精品免费看| 国产美女娇喘av呻吟久久 | 亚洲视频一区二区免费在线观看| 国产精品久久午夜| 亚洲欧美日韩国产另类专区| 亚洲区小说区图片区qvod| 亚洲美女一区二区三区| 亚洲专区一二三| 日本色综合中文字幕| 久久99国产精品尤物| 国产精品一区二区久激情瑜伽| 国产一区二区美女| av在线播放一区二区三区| 在线视频一区二区三| 日韩一级黄色片| 国产日韩欧美激情| 亚洲日本欧美天堂| 天堂成人免费av电影一区| 久久成人久久爱| 国产高清亚洲一区| 在线观看欧美日本| 日韩欧美色综合| 国产精品美女一区二区在线观看| 一区二区日韩av| 精品在线免费观看| 色88888久久久久久影院按摩| 欧美日韩精品系列| 久久亚区不卡日本| 亚洲午夜久久久久久久久电影网| 裸体健美xxxx欧美裸体表演| 成人免费福利片| 欧美精品 国产精品| 久久久不卡网国产精品一区| 亚洲国产精品久久人人爱蜜臀| 国产一区亚洲一区| 欧美性色综合网| 欧美高清在线一区| 麻豆精品视频在线观看免费| av福利精品导航| 欧美精品一区二区三区蜜桃视频| 亚洲同性同志一二三专区|