亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
久久蜜臀中文字幕| 午夜精品久久久久影视| 亚洲免费在线观看| 美女在线观看视频一区二区| 成人黄色电影在线| 欧美不卡一二三| 亚洲国产你懂的| 成人污视频在线观看| 欧美一区三区四区| 性久久久久久久久| 91精彩视频在线观看| 欧美极品美女视频| 国产美女在线精品| 欧美成人午夜电影| 亚洲成人动漫精品| 欧美日韩一区二区不卡| 亚洲视频免费观看| 不卡av电影在线播放| 久久久99精品久久| 精品一区二区三区久久| 欧美精品777| 亚洲va欧美va天堂v国产综合| av一区二区三区在线| 精品国产伦一区二区三区观看方式 | 国产精品99久久久| 欧美在线观看一区二区| 国产精品毛片久久久久久| 国产精品综合久久| 久久久99精品免费观看不卡| 国产精品主播直播| 久久久www成人免费毛片麻豆 | 中文字幕亚洲视频| 国产凹凸在线观看一区二区| 欧美mv日韩mv| 久久99九九99精品| 欧美一三区三区四区免费在线看| 精品国产区一区| 免费观看日韩电影| 日韩丝袜美女视频| 麻豆久久久久久久| 欧美mv和日韩mv国产网站| 国内精品视频666| 日韩午夜av电影| 久久精品国产亚洲高清剧情介绍 | 一本高清dvd不卡在线观看| 中文字幕中文字幕一区二区| 99久久精品国产观看| 一区二区三区欧美日| 99re在线精品| 亚洲专区一二三| 欧美美女一区二区三区| 久久国内精品自在自线400部| 99免费精品在线| 亚洲精品国产一区二区三区四区在线| 亚洲成人你懂的| 欧美一卡二卡在线| 国产精品一区二区无线| 国产精品嫩草影院av蜜臀| 91久久精品一区二区三区| 午夜精品aaa| 国产亚洲精久久久久久| 色综合一个色综合亚洲| 亚洲第一成人在线| 国产性色一区二区| 在线看日本不卡| 免费av成人在线| 中文字幕在线观看不卡| 色诱亚洲精品久久久久久| 首页综合国产亚洲丝袜| 久久精品视频免费| 欧美中文字幕一二三区视频| 精品一区二区三区欧美| 一区二区激情视频| 久久亚洲精品小早川怜子| 一本到不卡精品视频在线观看| 久久久久综合网| 在线观看日产精品| 国产真实精品久久二三区| 亚洲午夜私人影院| 国产欧美一区二区精品性| 色综合一个色综合| 国产精品综合av一区二区国产馆| 精品国产伦一区二区三区观看方式| 香蕉成人伊视频在线观看| 国产精品你懂的在线欣赏| 欧美一级精品大片| 欧美视频你懂的| 成人精品免费视频| 激情丁香综合五月| 午夜精品免费在线| 亚洲国产另类av| 中文无字幕一区二区三区| 欧美日韩aaaaaa| 色狠狠色噜噜噜综合网| 国产不卡一区视频| 国产一区二区三区在线看麻豆| 91精品国产综合久久婷婷香蕉| 亚洲自拍与偷拍| 亚洲欧美一区二区视频| 久久―日本道色综合久久| 色婷婷av一区二区三区软件 | 久久久蜜臀国产一区二区| 91麻豆精品久久久久蜜臀| 在线亚洲一区二区| 色综合久久综合网97色综合 | 日韩激情av在线| 亚洲一区二区成人在线观看| 亚洲人精品午夜| 久久久久久久网| 欧美变态凌虐bdsm| 日韩一区二区三区视频在线观看 | 欧美大片在线观看一区| 欧美精品tushy高清| 欧美三级午夜理伦三级中视频| 亚洲大尺度视频在线观看| 亚洲欧美激情视频在线观看一区二区三区 | 6080yy午夜一二三区久久| 欧美视频一区二区三区在线观看| 亚洲成人精品一区二区| 一区二区三区丝袜| 亚洲激情网站免费观看| 亚洲精品亚洲人成人网| 樱桃国产成人精品视频| 一区二区三区中文字幕| 亚洲国产成人高清精品| 日本不卡一二三| 韩国成人精品a∨在线观看| 国产精品自拍三区| 国产精品一区2区| www.亚洲精品| 欧美在线影院一区二区| 欧美日韩中文一区| 4438x成人网最大色成网站| 欧美不卡在线视频| 中文字幕巨乱亚洲| 亚洲美女屁股眼交| 亚洲一区二区中文在线| 日本aⅴ亚洲精品中文乱码| 秋霞影院一区二区| 丁香啪啪综合成人亚洲小说| 91一区二区三区在线观看| 在线国产电影不卡| 欧美va日韩va| 国产精品麻豆网站| 天天免费综合色| 国产传媒欧美日韩成人| 不卡大黄网站免费看| 5月丁香婷婷综合| 欧美激情一区在线观看| 亚洲综合视频在线观看| 老司机午夜精品99久久| 9久草视频在线视频精品| 欧美在线观看一区| 日韩女优电影在线观看| 中文字幕亚洲视频| 免费观看日韩av| 色综合久久中文字幕| 欧美变态tickle挠乳网站| 综合色天天鬼久久鬼色| 久久精品国产成人一区二区三区 | 成人中文字幕在线| 欧美电影在线免费观看| 日本一区二区三级电影在线观看| 欧美男生操女生| 精品国产三级电影在线观看| 自拍偷拍国产精品| 狠狠v欧美v日韩v亚洲ⅴ| 日本韩国精品在线| 中文字幕第一区| 捆绑变态av一区二区三区| 在线精品视频小说1| 国产精品美女久久久久久久| 精品一区二区久久久| 欧美男女性生活在线直播观看| 在线精品视频免费播放| 国产精品美女一区二区三区| 日本亚洲最大的色成网站www| 伊人婷婷欧美激情| 国产一区中文字幕| 日韩一级视频免费观看在线| 亚洲天堂久久久久久久| 风间由美一区二区av101| 精品国内片67194| 另类小说综合欧美亚洲| 在线播放91灌醉迷j高跟美女 | 久久精品国产999大香线蕉| 欧美日韩卡一卡二| 中文字幕亚洲综合久久菠萝蜜| 亚洲精品高清在线| 丁香一区二区三区| 精品国产乱码久久久久久闺蜜| 久久久久久免费网| 激情六月婷婷久久| 欧美不卡激情三级在线观看| 蜜桃精品在线观看| 日韩欧美亚洲国产精品字幕久久久| 欧美电影免费观看高清完整版在线| 欧美视频一区二| 亚洲风情在线资源站| 欧美色老头old∨ideo|