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

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

?? os_mutex.c

?? 大家快來下載。這是目前最新管方版本了,Micrium-uCOS-II-V284.zip
?? 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.84
*
* 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   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_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    : == 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_ERR_NONE;
        }
        return (1);
    }
    OS_EXIT_CRITICAL();
    *err = OS_ERR_NONE;
    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_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 *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_ERR_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_ERR_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_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.
*
*              err           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一区二区三区免费野_久草精品视频
日韩欧美美女一区二区三区| 成人av在线观| 亚洲午夜在线电影| 中文字幕日韩精品一区| 中文字幕+乱码+中文字幕一区| 日韩欧美一区二区在线视频| 欧美精品高清视频| 制服视频三区第一页精品| 欧美日韩一区二区三区在线看| 欧美亚洲综合另类| 欧美日精品一区视频| 欧美精品色一区二区三区| 欧美狂野另类xxxxoooo| 欧美午夜精品一区二区三区| 欧美日韩视频在线观看一区二区三区| 欧美色图在线观看| 91精品国产综合久久精品| 日韩欧美一区二区不卡| 久久综合成人精品亚洲另类欧美| 久久久国产精品不卡| 国产精品久久久久久久久免费桃花 | 亚洲成人自拍网| 亚洲一区二区三区在线看| 日韩中文字幕91| 狠狠久久亚洲欧美| av在线不卡电影| 欧美色视频一区| 精品精品国产高清a毛片牛牛| 国产三级三级三级精品8ⅰ区| 亚洲欧美日韩一区| 日韩专区欧美专区| 成人一区二区视频| 色综合视频在线观看| 91精品国产色综合久久久蜜香臀| 久久久久久久久久电影| 亚洲综合激情网| 精品一区在线看| 91麻豆福利精品推荐| 51精品国自产在线| 综合在线观看色| 青草国产精品久久久久久| 成人的网站免费观看| 日韩一二三四区| 亚洲码国产岛国毛片在线| 狠狠色丁香久久婷婷综| 欧美三级资源在线| 国产蜜臀av在线一区二区三区| 亚洲国产成人porn| www.成人在线| 精品国产乱码久久久久久浪潮| 一区二区三区成人| 国产成人自拍高清视频在线免费播放| 欧美性欧美巨大黑白大战| 久久久www成人免费毛片麻豆 | 首页欧美精品中文字幕| 丁香婷婷综合激情五月色| 欧美理论电影在线| 亚洲人成伊人成综合网小说| 韩国女主播成人在线| 在线综合+亚洲+欧美中文字幕| 亚洲欧美日韩在线播放| 处破女av一区二区| 精品91自产拍在线观看一区| 午夜精品久久久久久不卡8050| 99久久夜色精品国产网站| 久久色在线视频| 久久精品免费观看| 欧美日本韩国一区二区三区视频 | 91在线视频播放地址| 国产亚洲女人久久久久毛片| 麻豆成人91精品二区三区| 欧美日韩国产bt| 亚洲电影在线播放| 欧美综合欧美视频| 一级女性全黄久久生活片免费| 99久久er热在这里只有精品15| 欧美国产一区二区| 国产成人亚洲综合a∨婷婷图片| 精品精品国产高清a毛片牛牛 | 色偷偷成人一区二区三区91| 国产精品三级在线观看| 成人av在线资源| 国产精品久久久久久福利一牛影视 | 欧美aa在线视频| 日韩欧美黄色影院| 久久99精品国产麻豆不卡| 精品国产凹凸成av人网站| 国产在线麻豆精品观看| 国产欧美日韩激情| 97久久超碰精品国产| 亚洲另类春色国产| 欧美日韩中文精品| 美日韩一区二区| 精品国产麻豆免费人成网站| 国产精品一区二区免费不卡 | 丝袜诱惑制服诱惑色一区在线观看| 欧美亚洲一区二区在线| 日韩激情视频在线观看| 精品国产电影一区二区| 高清shemale亚洲人妖| 中文字幕一区不卡| 欧美日韩在线播放三区| 免费视频一区二区| 欧美激情在线一区二区三区| 99久久婷婷国产综合精品| 亚洲成人黄色影院| xf在线a精品一区二区视频网站| 国产精品18久久久久久久久久久久| 亚洲欧洲精品一区二区精品久久久 | 精品写真视频在线观看| 欧美激情综合五月色丁香小说| 91免费看片在线观看| 日本欧美一区二区三区乱码| 欧美国产一区二区| 欧美美女网站色| 国产成人精品亚洲777人妖| 一级中文字幕一区二区| 26uuu欧美日本| 欧美日韩一区二区在线观看视频| 国产美女在线精品| 午夜欧美视频在线观看| 中文子幕无线码一区tr| 欧美一级生活片| 91福利视频在线| 国产.精品.日韩.另类.中文.在线.播放| 亚洲女女做受ⅹxx高潮| 久久无码av三级| 欧美欧美午夜aⅴ在线观看| 成人晚上爱看视频| 美女尤物国产一区| 亚洲成人综合在线| 亚洲你懂的在线视频| 久久色.com| 欧美xfplay| 777亚洲妇女| 欧美日韩一区二区三区四区| 91猫先生在线| 成人免费视频一区二区| 国产在线精品免费| 蜜臀av性久久久久蜜臀aⅴ四虎| 一区二区三区蜜桃| 亚洲欧美激情小说另类| 国产日韩欧美精品一区| 精品国产免费人成在线观看| 欧美精品成人一区二区三区四区| 色婷婷久久99综合精品jk白丝| 国产毛片精品国产一区二区三区| 麻豆精品视频在线| 日韩av二区在线播放| 一区二区三区四区在线播放 | 人人超碰91尤物精品国产| 亚洲综合一区二区三区| 亚洲另类春色校园小说| 亚洲欧美日韩国产中文在线| 自拍偷拍亚洲欧美日韩| 国产精品美女久久久久aⅴ国产馆| 久久在线免费观看| 精品国产伦一区二区三区免费| 日韩午夜电影av| 欧美电视剧免费全集观看| 日韩一级片网站| 欧美mv和日韩mv的网站| 亚洲精品在线网站| 国产日韩影视精品| 国产精品三级视频| 国产精品成人午夜| 一区二区三区四区精品在线视频| 一区二区免费视频| 香蕉久久一区二区不卡无毒影院| 午夜欧美在线一二页| 免费不卡在线观看| 国产乱人伦偷精品视频免下载| 成人免费视频一区| 色8久久人人97超碰香蕉987| 制服丝袜亚洲播放| 久久久国产精品午夜一区ai换脸 | 99久久免费精品高清特色大片| 成人av片在线观看| 欧美怡红院视频| 日韩欧美成人午夜| 国产精品不卡视频| 亚洲高清在线视频| 国产在线精品国自产拍免费| av在线不卡电影| 欧美一区二区三区免费观看视频| 精品少妇一区二区三区日产乱码 | 中文av一区二区| 一区二区三区不卡在线观看| 日产欧产美韩系列久久99| 国产一区二区三区综合| 91视频在线看| 日韩精品一区二区三区在线 | 毛片一区二区三区| a亚洲天堂av| 日韩一区二区在线观看视频| 国产精品麻豆99久久久久久| 婷婷综合在线观看| 成人av综合在线| 欧美成人午夜电影| 一卡二卡欧美日韩|