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

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

?? os_mutex.c

?? avr相關知識,該單元包括數據與地址移位寄存器TWDR
?? 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一区二区三区免费野_久草精品视频
亚洲欧美日韩一区| 欧美一区二区人人喊爽| 国产日韩欧美精品在线| 美女在线一区二区| 91精品国产91久久久久久一区二区 | 在线视频综合导航| 亚洲伦在线观看| 日本国产一区二区| 亚洲成av人片在线观看| 欧美美女一区二区| 日本成人在线一区| 欧美成人国产一区二区| 国产精品一区二区三区四区| 国产日韩欧美电影| 91视频91自| 丝袜a∨在线一区二区三区不卡| 欧美人妇做爰xxxⅹ性高电影| 六月婷婷色综合| 欧美激情一区二区三区四区| 93久久精品日日躁夜夜躁欧美| 亚洲免费毛片网站| 91精品国产综合久久福利软件| 老司机午夜精品| 中文欧美字幕免费| 欧美色窝79yyyycom| 久久99精品一区二区三区三区| 国产午夜精品一区二区三区嫩草 | 麻豆精品精品国产自在97香蕉| 欧美精品一区二区三区一线天视频| 国产精品456| 亚洲精品福利视频网站| 欧美一区二区三区成人| 国产不卡高清在线观看视频| 亚洲九九爱视频| 日韩欧美一二三四区| 成人ar影院免费观看视频| 亚洲第一福利视频在线| www久久精品| 色激情天天射综合网| 久久av资源站| 亚洲欧美日韩国产综合在线| 日韩欧美成人一区| 日本道免费精品一区二区三区| 久久精品国产**网站演员| 日韩美女啊v在线免费观看| 欧美一区二区视频在线观看| a4yy欧美一区二区三区| 久久国产综合精品| 亚洲高清一区二区三区| 亚洲国产电影在线观看| 日韩精品中文字幕在线不卡尤物| 成人av综合在线| 精品一区二区精品| 午夜精品一区二区三区三上悠亚 | 精品一区二区三区蜜桃| 亚洲三级久久久| 国产欧美综合在线观看第十页| 欧美老女人第四色| 色激情天天射综合网| 成人午夜在线免费| 狠狠色综合播放一区二区| 午夜一区二区三区视频| 一区二区三区在线观看动漫| 欧美激情一区二区三区四区| 久久综合九色综合97婷婷| 91精品午夜视频| 欧美日韩一区二区在线视频| 91麻豆精品在线观看| 成人精品在线视频观看| 国产精品一级二级三级| 久久99这里只有精品| 奇米影视一区二区三区小说| 亚洲一区二区三区视频在线| 亚洲欧美日韩久久| 综合激情成人伊人| 国产精品成人网| 国产精品久久久久久久久晋中| 久久一日本道色综合| 精品三级在线看| 欧美大尺度电影在线| 欧美一级在线免费| 日韩一级二级三级精品视频| 欧美一区二区视频网站| 欧美一级日韩不卡播放免费| 欧美日本韩国一区| 91精品国产91久久久久久一区二区| 欧美日韩一区在线| 3d动漫精品啪啪| 91精品国产欧美一区二区成人| 欧美日韩一级二级| 制服丝袜亚洲色图| 日韩精品一区二区在线| 精品伦理精品一区| 久久久久久久久一| 国产女人18水真多18精品一级做 | 国产在线国偷精品免费看| 国产精品一二三区在线| a美女胸又www黄视频久久| 9i在线看片成人免费| 一本久久精品一区二区| 欧美视频一区二区三区在线观看| 欧美人伦禁忌dvd放荡欲情| 欧美一级久久久| 久久视频一区二区| 综合久久一区二区三区| 亚洲韩国精品一区| 免费成人美女在线观看| 风流少妇一区二区| 91蝌蚪porny| 91麻豆精品国产| 国产日韩精品一区| 亚洲综合区在线| 免费高清在线一区| 国产98色在线|日韩| 色老汉av一区二区三区| 日韩欧美一区二区三区在线| 国产日韩亚洲欧美综合| 亚洲图片欧美一区| 国产一区二三区好的| 一本久久综合亚洲鲁鲁五月天| 制服丝袜日韩国产| 国产精品二三区| 视频一区中文字幕国产| 粉嫩av亚洲一区二区图片| 久久久天堂av| 中文字幕视频一区| 男男gaygay亚洲| 99国内精品久久| 日韩一本二本av| 亚洲精品视频在线看| 精品一区二区免费看| 欧美又粗又大又爽| 亚洲国产精品激情在线观看| 亚洲动漫第一页| 成人一道本在线| 日韩欧美自拍偷拍| 一区二区三区四区不卡在线| 精品午夜久久福利影院| 欧美视频在线一区二区三区| 国产亚洲va综合人人澡精品| 日本色综合中文字幕| 91理论电影在线观看| 国产视频视频一区| 麻豆精品视频在线观看免费 | 色噜噜久久综合| 久久久99精品免费观看| 日韩电影在线观看网站| 91在线一区二区| 国产欧美日韩不卡| 久久成人免费日本黄色| 欧美高清一级片在线| 亚洲精品午夜久久久| 粉嫩蜜臀av国产精品网站| 精品卡一卡二卡三卡四在线| 亚洲va欧美va国产va天堂影院| 99精品视频免费在线观看| 国产日韩欧美亚洲| 国产又黄又大久久| 欧美成人性福生活免费看| 日日摸夜夜添夜夜添国产精品 | 日韩经典中文字幕一区| 在线免费观看成人短视频| 国产精品护士白丝一区av| 韩国毛片一区二区三区| 日韩欧美成人一区| 免费在线一区观看| 在线观看欧美日本| 一区二区三区日韩在线观看| av在线播放一区二区三区| 日本一区二区成人| 国产宾馆实践打屁股91| 国产午夜精品一区二区三区四区| 久久激情五月婷婷| 欧美成人福利视频| 精品一二三四区| 26uuuu精品一区二区| 捆绑调教一区二区三区| 精品毛片乱码1区2区3区| 国内精品视频666| 久久中文字幕电影| 懂色av中文一区二区三区| 久久久精品国产99久久精品芒果| 国产在线视视频有精品| 国产亚洲成年网址在线观看| 成人在线综合网站| 亚洲欧美视频在线观看| 在线观看日韩av先锋影音电影院| 亚洲高清不卡在线观看| 欧美一区二区精品久久911| 国产在线播精品第三| 国产精品麻豆久久久| 91亚洲精品乱码久久久久久蜜桃| 亚洲男同性视频| 884aa四虎影成人精品一区| 免费的成人av| 国产精品你懂的在线欣赏| 91看片淫黄大片一级| 日韩电影在线一区| 国产日韩成人精品| 精品婷婷伊人一区三区三|