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

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

?? os_mutex.c

?? ucosII實(shí)時(shí)操作系統(tǒng)的2.84官方版本
?? C
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
/*
*********************************************************************************************************
*                                                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.84
*********************************************************************************************************
*/

#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.

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
69成人精品免费视频| 亚洲毛片av在线| 日韩午夜激情免费电影| 欧美日韩亚洲高清一区二区| 在线观看视频一区二区| 欧美性猛交xxxx乱大交退制版| 一本大道久久a久久精品综合| 一本色道综合亚洲| 在线免费观看日本一区| 在线观看三级视频欧美| 欧美在线视频日韩| 欧美日韩色一区| 日韩精品一区二| 国产视频亚洲色图| 中文字幕亚洲一区二区va在线| 国产精品久久久久国产精品日日| 最新国产の精品合集bt伙计| 综合自拍亚洲综合图不卡区| 亚洲午夜久久久久中文字幕久| 一区av在线播放| 日韩**一区毛片| 国产很黄免费观看久久| 成人激情免费网站| 欧美亚一区二区| 日韩欧美在线网站| 久久精品亚洲麻豆av一区二区| 亚洲天堂精品在线观看| 亚洲妇女屁股眼交7| 久久99在线观看| 国产91在线观看丝袜| 在线观看免费视频综合| 日韩一区二区三区视频在线观看| 26uuu精品一区二区| 日本一区二区在线不卡| 一区二区三区**美女毛片| 日本不卡视频在线观看| 国产xxx精品视频大全| 91久久精品午夜一区二区| 91麻豆精品国产91久久久久久| 久久夜色精品国产欧美乱极品| 国产精品国产馆在线真实露脸| 亚洲永久免费视频| 国产精品白丝jk黑袜喷水| 91丝袜美腿高跟国产极品老师| 欧美日韩电影一区| 国产亚洲人成网站| 亚洲二区视频在线| 豆国产96在线|亚洲| 欧美女孩性生活视频| 国产女人aaa级久久久级| 亚洲电影你懂得| 成人黄页毛片网站| 欧美一区二区精品久久911| 国产精品久久久久国产精品日日| 男人的天堂久久精品| 99热这里都是精品| 日韩视频一区二区三区在线播放 | 久久免费看少妇高潮| 最新高清无码专区| 国产制服丝袜一区| 欧美私模裸体表演在线观看| 日本一区二区三区久久久久久久久不 | 精品粉嫩超白一线天av| 一区二区成人在线视频| 成人午夜激情影院| 欧美成人在线直播| 亚洲高清久久久| 91理论电影在线观看| 久久久久国产精品麻豆ai换脸| 日韩中文字幕亚洲一区二区va在线 | 色又黄又爽网站www久久| 久久久亚洲综合| 日韩av一级片| 欧美日本免费一区二区三区| 亚洲欧美另类小说视频| 日本视频中文字幕一区二区三区| 国产精品12区| 在线播放国产精品二区一二区四区| 国产精品视频一二三| 韩国一区二区视频| 日韩一级二级三级| 亚洲国产中文字幕| 91啪在线观看| 一区免费观看视频| 国产精品一区二区在线看| 欧美va亚洲va香蕉在线| 日韩经典中文字幕一区| 欧美中文字幕一区| 亚洲一区二区三区国产| 色综合咪咪久久| 国产精品成人一区二区三区夜夜夜| 国产精品自产自拍| 精品国产乱码久久久久久牛牛| 秋霞成人午夜伦在线观看| 欧美精品三级日韩久久| 亚洲影院理伦片| 欧美日韩国产综合一区二区三区 | 亚洲蜜桃精久久久久久久| 国产91高潮流白浆在线麻豆| 久久婷婷久久一区二区三区| 美女被吸乳得到大胸91| 91精品国产免费| 久久精品国产99| 精品国产乱码久久久久久久久| 久久成人久久鬼色| 亚洲精品一区在线观看| 韩国精品免费视频| 欧美国产精品v| 成人中文字幕合集| 亚洲三级小视频| 在线影院国内精品| 日韩av一区二区三区| 精品卡一卡二卡三卡四在线| 国产一区二区三区日韩| 国产欧美日韩综合| 99精品视频在线播放观看| 亚洲素人一区二区| 欧美精品在欧美一区二区少妇| 视频一区二区欧美| 精品欧美久久久| 国产精品自拍毛片| 亚洲欧美偷拍三级| 欧美日韩美女一区二区| 免费人成在线不卡| 久久久国产午夜精品| 99久久精品国产网站| 亚洲国产成人av网| 精品欧美乱码久久久久久1区2区| 懂色av一区二区三区蜜臀| 亚洲精品国产视频| 日韩欧美高清在线| 成人黄页毛片网站| 午夜久久福利影院| 久久九九久精品国产免费直播| av激情亚洲男人天堂| 亚洲一区视频在线| 精品久久久久一区| heyzo一本久久综合| 视频在线观看一区二区三区| 久久夜色精品国产欧美乱极品| 91色porny蝌蚪| 麻豆久久久久久| 亚洲女厕所小便bbb| 日韩一区二区三区高清免费看看| 国产精品99久| 午夜视频一区二区| 欧美激情一区二区三区蜜桃视频| 欧美午夜片在线观看| 国产美女娇喘av呻吟久久| 亚洲综合视频在线观看| 久久久另类综合| 欧美日韩中文字幕精品| 国产裸体歌舞团一区二区| 亚洲已满18点击进入久久| 国产无一区二区| 7777女厕盗摄久久久| 成人美女在线观看| 免费看日韩a级影片| 亚洲精选视频在线| 亚洲精品一区二区三区福利| 欧美在线视频不卡| 成人激情免费网站| 寂寞少妇一区二区三区| 亚洲中国最大av网站| 国产网站一区二区| 日韩三级精品电影久久久 | 久久嫩草精品久久久久| 欧美色综合久久| 成人激情免费视频| 久久国产婷婷国产香蕉| 亚洲毛片av在线| 国产精品欧美精品| 日韩精品中文字幕一区二区三区| 91麻豆精品秘密| 国产xxx精品视频大全| 麻豆久久久久久| 日韩福利电影在线观看| 一区二区欧美国产| 亚洲欧美区自拍先锋| 国产欧美精品一区二区色综合朱莉 | 欧美乱熟臀69xxxxxx| 91在线视频播放地址| 国产成人综合精品三级| 久久99久久久欧美国产| 日韩高清在线观看| 亚洲福中文字幕伊人影院| 亚洲色图视频免费播放| 欧美激情中文字幕| 国产性做久久久久久| 精品福利一二区| 欧美一区二区久久久| 7878成人国产在线观看| 欧美日本一区二区三区| 欧美日韩亚洲不卡| 欧美色区777第一页| 91免费观看视频在线| 99久久精品情趣| aaa国产一区| 99久久伊人精品| a亚洲天堂av|