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

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

?? os_mutex.c

?? ucos2.86版本結合STM板極支持包
?? 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.85
*
* 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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
av激情亚洲男人天堂| 国产亚洲精久久久久久| 国产日韩综合av| 亚洲午夜av在线| 成人激情动漫在线观看| 欧美电影在哪看比较好| 国产精品美女久久久久aⅴ| 美国十次综合导航| 欧美群妇大交群中文字幕| 国产蜜臀av在线一区二区三区| 日本一不卡视频| 日本大香伊一区二区三区| 国产欧美中文在线| 久久99国产精品久久| 国产清纯白嫩初高生在线观看91| 亚洲一区二区三区四区中文字幕| 国产成人超碰人人澡人人澡| 日韩欧美色电影| 日日摸夜夜添夜夜添精品视频| 99视频热这里只有精品免费| 国产亚洲人成网站| 国内精品写真在线观看| 欧美一区二区三区在线观看| 天堂va蜜桃一区二区三区漫画版 | 亚洲一区在线播放| 96av麻豆蜜桃一区二区| 国产精品久久久久毛片软件| 国产成人精品免费| 国产亲近乱来精品视频| 成人性生交大合| 中文字幕精品一区二区三区精品 | 久久久蜜桃精品| 极品少妇xxxx精品少妇| 精品欧美一区二区三区精品久久| 偷拍与自拍一区| 欧美日韩精品一区二区在线播放| 一区二区三区日韩欧美| 在线视频欧美精品| 午夜久久久影院| 欧美一卡2卡3卡4卡| 日本亚洲免费观看| 26uuu国产一区二区三区| 九九精品一区二区| 欧美国产日韩精品免费观看| 成人av免费在线播放| **网站欧美大片在线观看| 91色porny在线视频| 亚洲一区二区av在线| 3d成人动漫网站| 精品一区中文字幕| 国产精品丝袜91| 不卡一区在线观看| 一区二区三区成人在线视频| 4438成人网| 国产91在线观看丝袜| 亚洲日本在线a| 欧美日韩一区二区不卡| 麻豆精品在线视频| 中文字幕在线不卡一区二区三区| 色8久久人人97超碰香蕉987| 日韩电影免费在线看| 国产午夜亚洲精品羞羞网站| 91免费在线播放| 蜜桃免费网站一区二区三区| 日本一区二区三区dvd视频在线| 91网站在线播放| 日韩精品视频网| 国产精品久久午夜夜伦鲁鲁| 欧美精品xxxxbbbb| 成人免费看的视频| 青青草97国产精品免费观看| 中日韩免费视频中文字幕| 欧美日韩综合一区| 国产成人av在线影院| 亚洲国产精品一区二区www在线| 精品国产1区二区| 在线亚洲一区观看| 国产高清精品网站| 亚洲国产日产av| 国产精品不卡一区二区三区| 91精品视频网| 色噜噜久久综合| 91精品福利在线| 激情图区综合网| 天堂一区二区在线免费观看| 国产亚洲美州欧州综合国| 欧美日韩国产大片| 91亚洲资源网| 粉嫩av亚洲一区二区图片| 老司机午夜精品| 亚洲网友自拍偷拍| 亚洲婷婷国产精品电影人久久| 久久网站最新地址| 欧美一二三四区在线| 在线视频中文字幕一区二区| eeuss鲁一区二区三区| 国产乱码字幕精品高清av| 亚洲第一成人在线| 一区二区三区四区激情 | 亚洲不卡在线观看| 亚洲视频在线一区观看| 国产午夜精品一区二区三区嫩草| 日韩三级中文字幕| 69堂精品视频| 在线观看91av| 欧美久久久一区| 欧美精品tushy高清| 欧美亚洲自拍偷拍| 欧美揉bbbbb揉bbbbb| 欧美伊人久久大香线蕉综合69| 欧美一区二区啪啪| 精品视频999| 欧美日韩午夜在线视频| 欧美三级在线播放| 欧美日韩日日摸| 欧美久久久一区| 日韩一区二区在线观看| 日韩美女一区二区三区| 欧美电影免费观看高清完整版在线| 欧美日韩综合在线| 欧美卡1卡2卡| 日韩一区二区电影在线| 欧美mv和日韩mv的网站| 精品成人a区在线观看| 久久一二三国产| 国产精品二三区| 亚洲制服丝袜在线| 日韩va亚洲va欧美va久久| 免播放器亚洲一区| 国产精品伊人色| 97se亚洲国产综合自在线观| 在线观看亚洲a| 日韩一二在线观看| 国产亚洲1区2区3区| 亚洲乱码国产乱码精品精98午夜 | 一区视频在线播放| 亚洲精品成a人| 琪琪久久久久日韩精品| 国产精品自拍av| 欧洲av一区二区嗯嗯嗯啊| 91精品国产高清一区二区三区蜜臀| 日韩精品一区二区三区在线观看 | 日韩一区二区视频在线观看| 久久免费的精品国产v∧| 中文字幕制服丝袜一区二区三区| 一区二区三区不卡视频| 激情综合五月天| 色av综合在线| 精品国产3级a| 亚洲一区二区不卡免费| 韩国视频一区二区| 欧美综合久久久| 久久久久久亚洲综合影院红桃| 一区二区免费在线播放| 久热成人在线视频| 色综合久久99| 久久久激情视频| 精品一区二区三区免费播放| 91影视在线播放| 精品国产精品一区二区夜夜嗨| 亚洲少妇30p| 国产一区二区三区免费在线观看| 色婷婷av一区二区三区gif| 久久影音资源网| 日韩和欧美一区二区三区| 99精品国产热久久91蜜凸| 欧美精品一区二区三区一线天视频| 亚洲欧美偷拍三级| 国产传媒日韩欧美成人| 欧美区在线观看| 亚洲激情图片小说视频| 高清shemale亚洲人妖| 日韩欧美国产一区在线观看| 一区二区三区四区在线播放| 国产jizzjizz一区二区| 欧美电影免费提供在线观看| 五月天一区二区三区| 在线中文字幕一区| 日韩理论电影院| 成人v精品蜜桃久久一区| 久久蜜桃av一区二区天堂| 奇米777欧美一区二区| 欧美日韩免费在线视频| 一区二区三区四区在线免费观看 | 91 com成人网| 亚洲电影你懂得| 色婷婷久久99综合精品jk白丝| 国产视频一区不卡| 国产精品一区专区| 久久人人爽爽爽人久久久| 久久99精品国产| 欧美大片在线观看一区二区| 青椒成人免费视频| 日韩精品在线一区| 麻豆久久久久久| 精品精品国产高清一毛片一天堂| 视频在线观看国产精品| 91精品国产乱码久久蜜臀| 免费观看一级欧美片| 日韩欧美一区在线|