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

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

?? os_mutex.c

?? uCos-ii 2.86 在C8051F410單片機上移植成功!!! 其中包括:UART驅動
?? 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 "..\header files\includes.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) reentrant
{
    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) reentrant
{
    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一区二区三区免费野_久草精品视频
久久精品二区亚洲w码| 欧美性videosxxxxx| av电影在线观看完整版一区二区 | 国产精品高清亚洲| 日韩电影网1区2区| 91老司机福利 在线| 2017欧美狠狠色| 亚洲www啪成人一区二区麻豆| 福利一区二区在线观看| 日韩欧美高清dvd碟片| 亚洲影院理伦片| 91亚洲精华国产精华精华液| 久久综合成人精品亚洲另类欧美 | 欧美一区二区女人| 综合久久综合久久| 成人黄色网址在线观看| 久久久久久免费网| 极品美女销魂一区二区三区| 6080国产精品一区二区| 亚洲国产综合人成综合网站| 91网址在线看| 国产精品久久久久国产精品日日| 国产在线观看一区二区| 精品少妇一区二区三区在线视频 | 亚洲人成网站影音先锋播放| 粉嫩蜜臀av国产精品网站| 久久综合色综合88| 极品少妇xxxx精品少妇偷拍| 日韩精品在线一区二区| 欧美aaaaaa午夜精品| 欧美日韩一二三区| 天天做天天摸天天爽国产一区| 欧洲一区二区av| 亚洲综合成人在线视频| 欧美午夜影院一区| 性欧美疯狂xxxxbbbb| 欧美日韩国产高清一区二区| 婷婷中文字幕综合| 日韩女优视频免费观看| 看电影不卡的网站| 久久免费午夜影院| 99视频在线精品| 亚洲综合成人在线| 日韩欧美一区二区久久婷婷| 韩国精品在线观看| 国产日韩精品一区二区三区| 成人黄色网址在线观看| 日本va欧美va精品| 日韩丝袜情趣美女图片| 精品综合久久久久久8888| 国产亚洲欧美色| 91麻豆免费观看| 丝袜a∨在线一区二区三区不卡| 91精品国产福利在线观看| 经典三级在线一区| 国产精品毛片久久久久久| 91亚洲国产成人精品一区二区三 | 亚洲另类在线一区| 欧美电影一区二区| 国产在线播放一区三区四| 国产精品久久久久四虎| 91福利国产成人精品照片| 日韩国产欧美在线观看| 2024国产精品| 日本电影亚洲天堂一区| 免费亚洲电影在线| 国产精品美女久久久久久2018| 欧美视频在线观看一区| 国产一区二区中文字幕| 一区二区视频在线看| 精品成人一区二区| 色999日韩国产欧美一区二区| 日韩不卡一区二区| 亚洲欧美激情插| 久久久久久久久蜜桃| 欧美色精品天天在线观看视频| 国产美女av一区二区三区| 亚洲第一久久影院| 国产视频一区不卡| 在线电影一区二区三区| 成人三级伦理片| 蜜桃视频一区二区| 中文字幕综合网| 精品国产sm最大网站| 欧美婷婷六月丁香综合色| 粉嫩久久99精品久久久久久夜| 日本中文字幕一区| 亚洲人成7777| 国产色91在线| 欧美精品一区二区久久婷婷| 欧美午夜片在线观看| 不卡电影免费在线播放一区| 久久成人18免费观看| 亚洲电影在线播放| 亚洲情趣在线观看| 国产欧美日韩亚州综合| 精品国产制服丝袜高跟| 欧美嫩在线观看| 91黄视频在线| 99国产精品一区| 成人国产精品免费观看| 国产乱码精品一区二区三区五月婷| 日韩精品福利网| 亚洲一区在线观看视频| 亚洲欧美国产高清| 亚洲欧美激情插| 亚洲色图在线视频| 最新不卡av在线| 中文字幕在线播放不卡一区| 亚洲精品一线二线三线| 日韩一级欧美一级| 在线成人免费观看| 欧美日韩国产首页| 欧美日韩五月天| 欧美日韩日日摸| 欧美精品色一区二区三区| 欧美日韩国产小视频在线观看| 欧美三日本三级三级在线播放| 日本福利一区二区| 欧美日韩日日骚| 在线播放日韩导航| 日韩欧美在线网站| 日韩欧美激情在线| 久久综合久色欧美综合狠狠| 精品国产1区2区3区| 国产午夜精品久久久久久久| 国产精品三级av| 亚洲男人的天堂在线aⅴ视频| 有码一区二区三区| 丝袜诱惑亚洲看片| 黑人巨大精品欧美一区| 国产不卡在线视频| 97精品国产露脸对白| 欧美日精品一区视频| 91精品中文字幕一区二区三区| 欧美成人性战久久| 久久久久久久电影| 亚洲欧美日韩中文播放| 亚洲国产人成综合网站| 美国精品在线观看| 国产激情视频一区二区在线观看| 粉嫩欧美一区二区三区高清影视 | 欧美一区二区三区的| 26uuu国产电影一区二区| 中文字幕欧美日韩一区| 亚洲精品老司机| 日本伊人精品一区二区三区观看方式| 九色综合国产一区二区三区| 成人黄页毛片网站| 这里只有精品免费| 国产精品丝袜黑色高跟| 亚洲一二三专区| 国产成都精品91一区二区三| 91高清视频在线| 欧美精品一区二区三区蜜桃| 一区二区三区在线视频免费观看| 视频一区二区三区中文字幕| 国产东北露脸精品视频| 欧美理论在线播放| 欧美激情一区二区在线| 亚洲一区二区高清| 国产福利一区二区三区在线视频| 色噜噜狠狠色综合欧洲selulu| 精品国产一区久久| 夜夜嗨av一区二区三区中文字幕| 精品伊人久久久久7777人| 色老汉一区二区三区| 精品国产电影一区二区| 亚洲在线观看免费| 成人性生交大片免费看视频在线 | 久久久99精品免费观看| 亚洲国产wwwccc36天堂| 成人永久aaa| 欧美一区午夜精品| 亚洲国产成人精品视频| 成年人网站91| 久久久精品tv| 日韩av一级片| 欧美手机在线视频| 中文字幕亚洲精品在线观看| 激情另类小说区图片区视频区| 欧美日韩大陆一区二区| 亚洲免费在线观看视频| 成人久久18免费网站麻豆| 2020国产精品| 狠狠色综合色综合网络| 欧美一区二区三区视频在线| 亚洲一区在线观看网站| 色综合久久中文综合久久97| 中文幕一区二区三区久久蜜桃| 国产一区二区网址| 精品99久久久久久| 极品尤物av久久免费看| 欧美成人精品高清在线播放| 婷婷国产v国产偷v亚洲高清| 欧美日韩在线三级| 亚洲影院在线观看| 欧美性欧美巨大黑白大战| 亚洲va国产va欧美va观看| 欧美三级午夜理伦三级中视频|