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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? os_mutex.c

?? uCOS在Cortex-M3芯片上的移植
?? C
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
/*
*********************************************************************************************************
*                                                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.

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品一区二区三区在线观看| 中文字幕精品—区二区四季| 国产成人精品免费一区二区| 亚洲综合成人网| 久久九九全国免费| 欧美日韩成人综合在线一区二区 | 亚洲高清免费视频| 久久综合九色欧美综合狠狠| 精品视频999| 91香蕉国产在线观看软件| 国产乱淫av一区二区三区| 午夜久久久久久久久久一区二区| 中文字幕亚洲视频| 国产日产欧美一区| 精品日韩在线一区| 欧美一区二区三区影视| 欧美日韩一区成人| 91亚洲国产成人精品一区二区三| 国产成人av电影在线观看| 麻豆视频观看网址久久| 日韩精品亚洲一区| 婷婷亚洲久悠悠色悠在线播放 | 一区二区三区免费观看| 中文av一区特黄| 中文字幕高清不卡| 久久久噜噜噜久久中文字幕色伊伊 | 亚洲午夜精品在线| 18成人在线观看| 国产精品美女视频| 中文av字幕一区| 国产精品免费免费| 国产精品美女久久久久久| 中文在线免费一区三区高中清不卡| 日韩欧美一级片| 91精品国产91久久久久久一区二区 | 99久久精品免费精品国产| 不卡的电影网站| youjizz国产精品| 不卡视频一二三四| 99久久精品免费看国产| 91蜜桃在线免费视频| 92精品国产成人观看免费| 色哟哟欧美精品| 欧洲一区在线观看| 欧美日韩国产综合草草| 91精品国产综合久久精品性色| 欧美日韩国产三级| 日韩欧美自拍偷拍| www国产精品av| 欧美激情在线一区二区| 中文字幕永久在线不卡| 亚洲女人的天堂| 亚洲一区二区不卡免费| 日韩vs国产vs欧美| 蜜桃精品在线观看| 国产精品亚洲第一区在线暖暖韩国| 国产做a爰片久久毛片| 粉嫩av亚洲一区二区图片| 99精品久久99久久久久| 色婷婷激情综合| 91精品视频网| 欧美激情资源网| 一区二区久久久久久| 日韩中文字幕一区二区三区| 美女网站一区二区| eeuss鲁片一区二区三区| 在线观看视频一区二区| 日韩视频123| 中文字幕av一区二区三区| 亚洲精品视频在线看| 日日夜夜精品视频免费| 国产美女视频一区| 欧美制服丝袜第一页| 精品国产精品网麻豆系列| 亚洲视频图片小说| 日日夜夜精品视频免费| 国产精品系列在线观看| 一本到不卡精品视频在线观看| 欧美三级电影网| 欧美国产精品专区| 午夜精品视频一区| 国产大陆亚洲精品国产| 欧美性色综合网| 久久精品免费在线观看| 亚洲国产中文字幕| 丁香婷婷深情五月亚洲| 欧美日韩国产在线播放网站| 欧美国产精品一区二区| 亚洲国产精品麻豆| 成人午夜激情视频| 91精品国产综合久久久蜜臀图片| 国产精品色在线观看| 日本sm残虐另类| 91亚洲国产成人精品一区二区三 | 一区二区在线观看视频| 精品一区二区三区免费毛片爱| 色婷婷综合久久久久中文一区二区 | 国产麻豆成人精品| 欧美丰满美乳xxx高潮www| 国产精品免费丝袜| 国产一区二区不卡| 欧美一级专区免费大片| 亚洲欧美日韩一区二区 | 国产精品理论片| 日本欧美一区二区三区| 91国内精品野花午夜精品 | 美脚の诱脚舐め脚责91| 色婷婷久久久综合中文字幕| 欧美国产激情一区二区三区蜜月 | 在线一区二区三区四区| 久久这里只有精品6| 蜜桃91丨九色丨蝌蚪91桃色| 欧美午夜精品一区二区三区| 国产精品久久久久久久久果冻传媒 | 色老综合老女人久久久| 欧美激情艳妇裸体舞| 黄色精品一二区| 日韩一级免费观看| 日韩电影在线一区二区| 欧美亚洲日本一区| 有码一区二区三区| 日本丶国产丶欧美色综合| 国产精品久久久久久久久免费丝袜| 国产毛片精品一区| 久久中文字幕电影| 国产精品自拍一区| 久久久久国产精品麻豆ai换脸| 日本网站在线观看一区二区三区| 欧美色视频在线观看| 亚洲曰韩产成在线| 欧美日韩视频专区在线播放| 亚洲午夜国产一区99re久久| 91极品美女在线| 亚洲成a人v欧美综合天堂| 欧美色图一区二区三区| 亚洲一区二区三区四区五区黄| 色综合久久综合网97色综合| 亚洲乱码国产乱码精品精可以看 | 国产成人一区二区精品非洲| 欧美精品一区二区高清在线观看 | 欧美视频一区在线| 亚洲不卡在线观看| 欧美一区二区三区不卡| 久久国产精品露脸对白| 久久九九久精品国产免费直播| 国产一区二区三区视频在线播放| 久久久久99精品一区| 国产成人免费在线视频| 成人免费小视频| 欧美午夜片在线看| 免费高清视频精品| 久久综合狠狠综合久久综合88| 国产成人夜色高潮福利影视| 中文字幕一区在线观看| 欧美午夜一区二区三区| 六月丁香婷婷久久| 天堂一区二区在线| 欧美一区日本一区韩国一区| 国产麻豆成人传媒免费观看| 国产精品久久午夜| 欧美三日本三级三级在线播放| 爽好多水快深点欧美视频| 精品日韩在线一区| 成人av电影观看| 亚洲高清在线精品| 亚洲精品在线三区| 91同城在线观看| 奇米影视一区二区三区| 久久久不卡网国产精品一区| 97精品电影院| 人人狠狠综合久久亚洲| 国产亚洲欧美色| 在线观看91视频| 国产一区二区三区在线看麻豆| 亚洲欧洲av在线| 欧美一区二区三区四区五区| 成人一区在线看| 亚洲不卡av一区二区三区| 久久女同精品一区二区| 欧美性大战久久久| 国产麻豆精品theporn| 亚洲成人免费在线| 久久精品一二三| 欧美老年两性高潮| 成人av网在线| 麻豆久久一区二区| 亚洲一区在线免费观看| 久久久久久久久97黄色工厂| 欧美三级韩国三级日本一级| 成人小视频在线观看| 日本亚洲欧美天堂免费| 中文字幕在线一区二区三区| 日韩专区中文字幕一区二区| 中文字幕免费在线观看视频一区| 欧美日韩国产综合草草| 粉嫩嫩av羞羞动漫久久久| 蜜桃一区二区三区在线观看| 一区二区三区在线影院| 国产精品色哟哟| 精品国产乱码久久久久久浪潮|