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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_mutex.c

?? 本人寫的ATMEL 128 UC/OSII移植程序
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                  MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2006, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_MUTEX.C
* By      : Jean J. Labrosse
* Version : V2.83
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include <ucos_ii.h>
#endif


#if OS_MUTEX_EN > 0
/*
*********************************************************************************************************
*                                            LOCAL CONSTANTS
*********************************************************************************************************
*/

#define  OS_MUTEX_KEEP_LOWER_8   0x00FFu
#define  OS_MUTEX_KEEP_UPPER_8   0xFF00u

#define  OS_MUTEX_AVAILABLE      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
*
*              err        is a pointer to an error code which will be returned to your application:
*                            OS_NO_ERR          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    : == 1       if the resource is available, the mutual exclusion semaphore is acquired
*              == 0       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
INT8U  OSMutexAccept (OS_EVENT *pevent, INT8U *err)
{
    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 (err == (INT8U *)0) {                           /* Validate 'err'                               */
        return (0);
    }
    if (pevent == (OS_EVENT *)0) {                     /* Validate 'pevent'                            */
        *err = OS_ERR_PEVENT_NULL;
        return (0);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) {  /* Validate event block type                    */
        *err = OS_ERR_EVENT_TYPE;
        return (0);
    }
    if (OSIntNesting > 0) {                            /* Make sure it's not called from an ISR        */
        *err = OS_ERR_PEND_ISR;
        return (0);
    }
    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!                  */
            *err  = OS_ERR_PIP_LOWER;
        } else {
            OS_EXIT_CRITICAL();
            *err  = OS_NO_ERR;
        }
        return (1);
    }
    OS_EXIT_CRITICAL();
    *err = OS_NO_ERR;
    return (0);
}
#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.
*
*              err           is a pointer to an error code which will be returned to your application:
*                               OS_NO_ERR           if the call was successful.
*                               OS_ERR_CREATE_ISR   if you attempted to create a MUTEX from an ISR
*                               OS_PRIO_EXIST       if a task at the priority inheritance priority
*                                                   already exist.
*                               OS_ERR_PEVENT_NULL  No more event control blocks available.
*                               OS_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 *err)
{
    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 (err == (INT8U *)0) {                               /* Validate 'err'                           */
        return ((OS_EVENT *)0);
    }
    if (prio >= OS_LOWEST_PRIO) {                          /* Validate PIP                             */
        *err = OS_PRIO_INVALID;
        return ((OS_EVENT *)0);
    }
#endif
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = 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 ...       */
        *err = OS_PRIO_EXIST;                              /* ... inheritance priority                 */
        return ((OS_EVENT *)0);
    }
    OSTCBPrioTbl[prio] = (OS_TCB *)1;                      /* 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();
        *err               = 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);
    *err                   = OS_NO_ERR;
    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.
*
*              err           is a pointer to an error code that can contain one of the following values:
*                            OS_NO_ERR               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一区二区三区免费野_久草精品视频
av亚洲精华国产精华精| 欧美成人精品福利| 亚洲免费观看在线观看| 91在线观看高清| 亚洲日本护士毛茸茸| 色94色欧美sute亚洲线路二| 一区2区3区在线看| 日韩一区二区三区电影在线观看 | 日日摸夜夜添夜夜添国产精品| 粗大黑人巨茎大战欧美成人| 中文字幕第一区综合| 国产成人激情av| 国产精品沙发午睡系列990531| 免费观看成人鲁鲁鲁鲁鲁视频| 日韩精品一区二区三区在线| 国产毛片精品视频| 国产精品女主播av| 91小宝寻花一区二区三区| 亚洲天堂网中文字| 欧美日韩黄色影视| 麻豆免费看一区二区三区| 欧美成人高清电影在线| 国产91露脸合集magnet| 亚洲三级在线观看| 欧美美女直播网站| 精品一区二区在线播放| 欧美国产精品一区二区| 色成年激情久久综合| 日韩黄色免费电影| 久久欧美一区二区| 在线精品观看国产| 麻豆91在线观看| 国产精品萝li| 3d动漫精品啪啪一区二区竹菊| 紧缚奴在线一区二区三区| 亚洲欧洲无码一区二区三区| 欧美三级电影精品| 91丝袜呻吟高潮美腿白嫩在线观看| 国产永久精品大片wwwapp| 欧美精品高清视频| 国产欧美视频一区二区三区| 亚洲午夜精品一区二区三区他趣| 美女任你摸久久 | 久久嫩草精品久久久久| 国产亚洲婷婷免费| 国产精品一区二区三区乱码| 一区二区三区四区国产精品| 777午夜精品视频在线播放| 日韩av一区二区三区四区| 久久精品夜色噜噜亚洲a∨| 成a人片亚洲日本久久| 亚洲欧洲av另类| 91福利视频久久久久| 麻豆成人免费电影| 国产精品久久精品日日| 在线不卡a资源高清| 福利一区福利二区| 午夜视频在线观看一区二区 | 久久久噜噜噜久噜久久综合| 91久久精品一区二区| 国产乱码精品一区二区三| 亚洲成人免费看| 国产精品区一区二区三| 日韩亚洲欧美高清| 欧美午夜精品久久久| 成年人国产精品| 国产一区二区0| 蜜臀av性久久久久蜜臀aⅴ四虎 | 欧美电影精品一区二区| 欧洲中文字幕精品| 成人毛片老司机大片| 九九热在线视频观看这里只有精品| 亚洲男女一区二区三区| 欧美激情一区三区| 精品毛片乱码1区2区3区| 欧美日韩小视频| 色丁香久综合在线久综合在线观看| 国产suv精品一区二区6| 激情文学综合网| 日本v片在线高清不卡在线观看| 亚洲在线成人精品| 亚洲视频一区二区在线| 国产精品女上位| 国产精品免费av| 欧美剧在线免费观看网站| 奇米精品一区二区三区在线观看 | 亚洲一区免费视频| 在线观看日韩国产| 亚洲一区自拍偷拍| 精品国产精品网麻豆系列| 风间由美中文字幕在线看视频国产欧美| 午夜亚洲福利老司机| 日本午夜精品一区二区三区电影| 亚洲综合成人在线视频| 欧美一区二区在线免费播放| 久久99精品一区二区三区三区| 亚洲免费观看高清完整版在线观看| 欧美巨大另类极品videosbest | 日韩欧美一级二级三级久久久| 播五月开心婷婷综合| 亚洲毛片av在线| 中文字幕一区二区不卡| 欧美高清性hdvideosex| 在线观看成人小视频| www.一区二区| 91精品国产日韩91久久久久久| 91香蕉视频在线| 国产在线精品一区在线观看麻豆| 日韩福利电影在线观看| 亚洲精品乱码久久久久久久久| 久久久久久久久97黄色工厂| 高清在线观看日韩| 亚洲成a人片在线不卡一二三区| 欧美成人女星排名| 日韩视频在线永久播放| 日韩精品影音先锋| 日韩欧美国产电影| 日本一二三不卡| 中文字幕乱码日本亚洲一区二区 | 91精品国产全国免费观看 | 麻豆国产精品一区二区三区| 国产99久久久国产精品| 极品少妇xxxx精品少妇| 亚洲码国产岛国毛片在线| 精品国产sm最大网站| 欧美视频一二三区| 色综合久久88色综合天天6| 精品一区二区三区久久久| 亚洲香肠在线观看| 亚洲曰韩产成在线| 五月激情综合色| 国产精品久久久久影院亚瑟| 国产欧美中文在线| 国产亚洲欧美色| 一区二区不卡在线视频 午夜欧美不卡在 | 国产福利一区在线| 精久久久久久久久久久| 国产精品系列在线播放| 国产成人精品综合在线观看| 成人免费视频视频在线观看免费 | 日韩美女主播在线视频一区二区三区| 久久奇米777| 亚洲一区二区在线观看视频 | 中文字幕国产一区| 欧美激情综合网| 日本不卡在线视频| 91视视频在线观看入口直接观看www| 欧美一区二区三区性视频| 国产精品网站在线播放| 麻豆精品视频在线观看| 成人精品国产一区二区4080| 久久久蜜桃精品| 蜜臀91精品一区二区三区| 欧美在线观看一区二区| 国产人久久人人人人爽| 青娱乐精品视频| 欧美视频日韩视频在线观看| 国产精品你懂的在线| 精品一区二区影视| 狠狠色丁香婷婷综合久久片| 91精品国产综合久久精品图片 | 欧美无人高清视频在线观看| 亚洲欧美偷拍另类a∨色屁股| 日本久久电影网| 蜜桃视频一区二区三区在线观看| 欧美性videosxxxxx| 亚洲国产成人高清精品| 久久久国产一区二区三区四区小说 | 欧美天天综合网| 中文字幕在线免费不卡| 国产成人av电影在线| 国产欧美精品日韩区二区麻豆天美| 日日摸夜夜添夜夜添精品视频| 欧美精品久久一区二区三区| 三级在线观看一区二区 | 91老司机福利 在线| 亚洲另类在线制服丝袜| 欧美视频你懂的| 亚洲成av人片一区二区三区| 欧美日韩国产高清一区二区三区 | 欧美韩国日本综合| 暴力调教一区二区三区| 亚洲精品日韩专区silk| 欧美亚洲综合在线| 奇米一区二区三区av| 久久综合色综合88| 不卡区在线中文字幕| 洋洋av久久久久久久一区| 欧美一区二区视频在线观看2020| 国精产品一区一区三区mba桃花| 欧美国产日韩a欧美在线观看| av在线不卡观看免费观看| 亚洲图片一区二区| 久久久五月婷婷| 在线视频亚洲一区| 久久av中文字幕片| 亚洲欧美国产三级| 日韩午夜在线观看| 99精品久久只有精品| 日韩精品一级中文字幕精品视频免费观看 |