亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
2022国产精品视频| 丝袜美腿一区二区三区| 一区二区三区91| 精品一区二区三区在线观看国产| 成人一区二区三区中文字幕| 欧美日韩国产高清一区二区三区| 国产亚洲成av人在线观看导航| 一区二区免费在线播放| 高清不卡在线观看av| 日韩女优毛片在线| 午夜精品福利在线| 色成人在线视频| 国产精品午夜电影| 国产一区二区伦理片| 欧美一区二区精品| 亚洲成人精品一区| 91福利国产成人精品照片| 欧美国产日韩一二三区| 国产麻豆精品在线| 日韩美女一区二区三区| 日韩成人一级片| 欧美日韩免费一区二区三区| 亚洲欧美日韩国产成人精品影院 | 色婷婷激情综合| www国产成人| 激情小说欧美图片| 精品卡一卡二卡三卡四在线| 日产国产高清一区二区三区| 欧美区在线观看| 天堂成人免费av电影一区| 欧美高清视频一二三区 | 国产亚洲欧美在线| 韩国精品主播一区二区在线观看| 日韩欧美一级精品久久| 久久99热这里只有精品| 精品成人佐山爱一区二区| 精品一区二区三区日韩| 久久久影视传媒| 粉嫩aⅴ一区二区三区四区| 国产欧美日韩在线| av不卡在线播放| 玉米视频成人免费看| 欧美色区777第一页| 三级影片在线观看欧美日韩一区二区| 欧美人与z0zoxxxx视频| 捆绑紧缚一区二区三区视频| 久久久久久久综合| 99久久国产综合精品麻豆| 亚洲激情在线激情| 91精品国产免费| 国产精品123区| 亚洲男人电影天堂| 欧美一卡二卡三卡| 国产盗摄视频一区二区三区| 国产精品久久久久久久久快鸭| 色综合久久久久| 麻豆专区一区二区三区四区五区| 精品99一区二区| 99久久免费精品| 日韩电影一区二区三区| 国产亚洲欧美在线| 在线视频一区二区三区| 久久国内精品视频| 亚洲桃色在线一区| 日韩一区二区三区视频| 粉嫩蜜臀av国产精品网站| 一区二区高清在线| 久久久久久久久免费| 欧美影视一区二区三区| 国产乱码精品1区2区3区| 一区二区日韩av| 久久久久久综合| 欧美在线观看一二区| 黄页网站大全一区二区| 亚洲男人天堂一区| 国产日韩欧美综合在线| 欧美午夜在线一二页| 51精品视频一区二区三区| 国产a视频精品免费观看| 亚洲丶国产丶欧美一区二区三区| 久久九九久久九九| 成人黄色综合网站| 夜夜爽夜夜爽精品视频| 国产亚洲一区二区三区在线观看 | 国产精品99久久久| 国产欧美一区二区精品性色| 91精品国产综合久久婷婷香蕉| 911国产精品| 日韩午夜激情视频| 精品国产一区二区精华| 国产午夜亚洲精品不卡| 国产精品麻豆久久久| 亚洲精品精品亚洲| 日日夜夜免费精品| 免费高清在线视频一区·| 久久99热99| 成人的网站免费观看| 欧美最新大片在线看| 欧美挠脚心视频网站| 欧美大胆一级视频| 国产欧美日本一区二区三区| 亚洲情趣在线观看| 日韩电影一区二区三区四区| 国产麻豆9l精品三级站| 99re热视频精品| 欧美日本免费一区二区三区| ww久久中文字幕| 亚洲欧美日韩久久精品| 蜜臀av性久久久久蜜臀aⅴ四虎| 国产成人啪午夜精品网站男同| 日本久久一区二区| 欧美成人午夜电影| 亚洲蜜桃精久久久久久久| 老鸭窝一区二区久久精品| 成人爽a毛片一区二区免费| 在线免费亚洲电影| 久久嫩草精品久久久精品| 亚洲综合在线电影| 狠狠色狠狠色综合系列| 91久久一区二区| 欧美精品一区二区三区在线播放| 亚洲嫩草精品久久| 国产专区综合网| 欧美视频中文字幕| 国产精品丝袜久久久久久app| 亚洲亚洲人成综合网络| 国产91清纯白嫩初高中在线观看| 欧美午夜理伦三级在线观看| 欧美经典三级视频一区二区三区| 五月天亚洲婷婷| av电影在线不卡| 欧美精品一区二区三区高清aⅴ | 一区二区三区中文字幕| 精品综合久久久久久8888| 91久久国产最好的精华液| 久久久久久久久久电影| 日韩专区在线视频| 91精品福利视频| 国产精品美女久久福利网站| 乱中年女人伦av一区二区| 欧洲国产伦久久久久久久| 国产精品每日更新| 国产麻豆精品久久一二三| 911精品产国品一二三产区| 亚洲另类在线制服丝袜| 成人va在线观看| 亚洲精品一区二区三区四区高清| 三级欧美韩日大片在线看| 色老汉一区二区三区| 国产精品伦理在线| 国产精品系列在线播放| 精品少妇一区二区三区| 秋霞午夜鲁丝一区二区老狼| 欧美色窝79yyyycom| 亚洲欧美电影院| 91一区在线观看| 国产精品欧美久久久久一区二区| 国产一区二区三区电影在线观看| 日韩欧美高清dvd碟片| 免费成人在线影院| 91精品国产品国语在线不卡| 天天爽夜夜爽夜夜爽精品视频| 91国产福利在线| 亚洲香肠在线观看| 欧美天堂一区二区三区| 亚洲一区二区四区蜜桃| 欧美性生交片4| 亚洲午夜精品网| 欧美人体做爰大胆视频| 日韩av一级电影| 欧美白人最猛性xxxxx69交| 久久国产精品第一页| 久久午夜色播影院免费高清| 国产一区二区三区最好精华液| 欧美精品一区二区三区蜜臀| 国产精品一区二区在线看| 中日韩免费视频中文字幕| thepron国产精品| 一区二区三区在线观看网站| 欧美日韩国产综合久久| 蜜桃av噜噜一区二区三区小说| 欧美成人精品3d动漫h| 国产精品77777| 亚洲视频一区二区免费在线观看| 日本乱人伦一区| 蜜臀va亚洲va欧美va天堂| 久久亚洲精品小早川怜子| 成人免费视频视频| 亚洲女厕所小便bbb| 9191久久久久久久久久久| 国产一区二区三区高清播放| 综合自拍亚洲综合图不卡区| 欧亚洲嫩模精品一区三区| 奇米影视一区二区三区小说| 久久精品男人的天堂| 色拍拍在线精品视频8848| 日韩av午夜在线观看| 国产日韩欧美亚洲| 欧美午夜视频网站| 狠狠色丁香婷综合久久|