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

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

?? os_mutex.c

?? ucosIIV283,from The company
?? 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一区二区三区免费野_久草精品视频
欧美亚洲一区二区在线| 亚洲第一精品在线| 欧美日韩一区二区三区四区 | 欧美伊人久久久久久久久影院| 国产精品亚洲第一区在线暖暖韩国| 视频一区二区三区在线| 亚洲国产视频在线| 国产精品国产精品国产专区不片| 欧美高清在线一区| 日韩美女一区二区三区四区| 欧美一区二区三区视频在线| 欧美一区二区三区视频在线| 欧美大片在线观看| 久久亚洲综合av| 国产精品理论片| 亚洲韩国精品一区| 亚洲一区影音先锋| 日产精品久久久久久久性色| 久久国产精品99久久久久久老狼 | 夜夜嗨av一区二区三区四季av| 日韩伦理av电影| 亚洲国产一二三| 日本欧美肥老太交大片| 狠狠色丁香婷婷综合久久片| 国产99久久久久久免费看农村| 成人精品高清在线| 成人精品小蝌蚪| 色综合久久99| 欧美日韩国产精品自在自线| 4438亚洲最大| 久久精品亚洲麻豆av一区二区| 中文字幕一区二区三中文字幕| 一区在线中文字幕| 亚洲精品少妇30p| 香蕉久久夜色精品国产使用方法| 日韩精品欧美成人高清一区二区| 国产精品一区二区三区99| av爱爱亚洲一区| 日韩午夜激情电影| 亚洲精品视频免费观看| 韩国视频一区二区| 色噜噜狠狠色综合欧洲selulu| 日韩欧美在线不卡| 亚洲激情六月丁香| 国产一区二区在线影院| 欧美色图在线观看| 国产精品黄色在线观看| 免费观看91视频大全| 国产成人av一区二区三区在线 | 成人免费电影视频| 91精品欧美综合在线观看最新| 国产精品美女久久久久av爽李琼| 美女一区二区久久| 欧美这里有精品| 综合色天天鬼久久鬼色| 久久精品国产亚洲高清剧情介绍| 在线观看日韩毛片| 中文字幕日韩一区| 国产91丝袜在线播放0| 日韩欧美一级二级三级久久久| 亚洲一区中文日韩| 99riav一区二区三区| 中文字幕精品一区二区精品绿巨人 | 精品成人一区二区| 婷婷中文字幕综合| 欧美视频在线播放| 亚洲最大成人综合| 色婷婷激情综合| 亚洲欧美日韩系列| www..com久久爱| 亚洲欧洲日韩一区二区三区| 国产+成+人+亚洲欧洲自线| 久久久影视传媒| 国产精品一区二区视频| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 亚洲精品在线免费观看视频| 亚洲aaa精品| av在线这里只有精品| 中文字幕不卡在线播放| 菠萝蜜视频在线观看一区| 亚洲欧洲精品天堂一级| 94-欧美-setu| 天堂成人免费av电影一区| 欧美日本一区二区| 免费观看在线综合| 日韩精品一区二区三区四区视频 | 欧美日韩久久久| 一区二区三区日韩在线观看| 欧美主播一区二区三区| 亚洲午夜免费电影| 日韩一区二区三区免费观看| 亚洲综合在线观看视频| 91蜜桃免费观看视频| 一区二区三区影院| 欧美日本在线一区| 国内成+人亚洲+欧美+综合在线| 欧美mv日韩mv国产网站app| 裸体健美xxxx欧美裸体表演| 日韩精品综合一本久道在线视频| 久久超碰97中文字幕| 国产丝袜美腿一区二区三区| 成人爱爱电影网址| 亚洲午夜影视影院在线观看| 91麻豆精品久久久久蜜臀| 国产精品一区二区三区乱码| 综合久久一区二区三区| 欧美图片一区二区三区| 国产精品1024| 午夜精品影院在线观看| 欧美极品aⅴ影院| 欧美日本一区二区在线观看| 国产毛片精品国产一区二区三区| 国产精品久久久久久一区二区三区| 欧美午夜宅男影院| 国产精品99久久久久久有的能看| 亚洲欧美激情小说另类| 欧美哺乳videos| 在线观看成人小视频| 国产精品亚洲а∨天堂免在线| 亚洲最大成人网4388xx| 中文一区一区三区高中清不卡| 欧美伊人久久久久久午夜久久久久| 国产经典欧美精品| 午夜视频一区二区三区| 国产精品三级视频| 精品日韩av一区二区| 欧美色精品天天在线观看视频| 国产成人午夜精品5599| 美女性感视频久久| 亚洲v日本v欧美v久久精品| 国产女同互慰高潮91漫画| 欧美一区二区黄| 欧美日韩亚洲综合在线| 91欧美一区二区| thepron国产精品| 国产不卡视频一区| 老司机精品视频线观看86| 天天综合网 天天综合色| 亚洲免费在线视频| 日韩毛片一二三区| 国产精品国产三级国产普通话蜜臀 | 亚洲国产美女搞黄色| 中文字幕一区在线观看| 国产欧美日韩中文久久| 亚洲精品一区二区三区99| 91精品国产入口| 91精品国产日韩91久久久久久| 欧美剧情片在线观看| 欧美日韩视频专区在线播放| 在线观看91视频| 欧美在线视频日韩| 欧洲精品在线观看| 欧美在线观看视频一区二区 | 日韩欧美黄色影院| 91精品福利在线一区二区三区 | 亚洲精品中文在线观看| 国产亚洲精品久| 欧美激情综合在线| 国产农村妇女毛片精品久久麻豆| 国产亚洲综合在线| 久久人人超碰精品| 中文成人av在线| 一区二区三区影院| 青青草精品视频| 国产精品主播直播| 成人av影视在线观看| 欧美专区日韩专区| 日韩视频国产视频| 久久久久久毛片| 国产婷婷一区二区| 亚洲色图欧美在线| 午夜精品久久久久久不卡8050| 日韩av午夜在线观看| 国产精品一线二线三线精华| 懂色一区二区三区免费观看| 91免费视频网| 337p亚洲精品色噜噜狠狠| 精品国产一区二区三区四区四| 久久久精品免费免费| 亚洲永久精品国产| 狠狠色狠狠色综合系列| 不卡一二三区首页| 7799精品视频| 欧美精彩视频一区二区三区| 亚洲美女一区二区三区| 日本不卡一二三区黄网| 国产成人av自拍| 91精品国产福利在线观看| 中文子幕无线码一区tr| 日韩电影在线观看网站| 成人精品高清在线| 日韩色在线观看| 亚洲婷婷综合色高清在线| 日韩国产欧美在线视频| av在线一区二区| www国产精品av| 午夜电影久久久| 99久久久国产精品免费蜜臀| 精品国产在天天线2019| 午夜久久久影院|