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

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

?? os_mutex.c

?? UCOS-ii最新版源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                  MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2005, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_MUTEX.C
* By      : Jean J. Labrosse
* Version : V2.80
*********************************************************************************************************
*/

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

/*
*********************************************************************************************************
*                                            LOCAL CONSTANTS
*********************************************************************************************************
*/

#define  OS_MUTEX_KEEP_LOWER_8   0x00FFu
#define  OS_MUTEX_KEEP_UPPER_8   0xFF00u

#define  OS_MUTEX_AVAILABLE      0x00FFu


#if OS_MUTEX_EN > 0
/*
*********************************************************************************************************
*                                   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
*
* 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)
{
#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                  */
    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           */
        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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品一区一区三区| 99在线精品一区二区三区| 在线播放欧美女士性生活| 夜夜精品视频一区二区 | 日韩一区二区三区在线观看| 一级日本不卡的影视| 欧美色爱综合网| 免费成人在线影院| 久久久国产精华| av电影在线不卡| 亚洲第一电影网| 精品国精品国产尤物美女| 国产成人精品亚洲午夜麻豆| 一区在线播放视频| 欧美麻豆精品久久久久久| 久久se精品一区精品二区| 日本一区二区三区四区在线视频| 成人在线视频一区二区| 一区二区三区在线免费视频| 欧美日韩精品一区二区| 精品制服美女丁香| 亚洲视频1区2区| 91麻豆精品国产自产在线观看一区 | 欧美一级二级三级乱码| 国产麻豆精品95视频| 亚洲人精品一区| 日韩精品一区二区三区老鸭窝| 成人综合婷婷国产精品久久蜜臀 | www.日本不卡| 欧美aaaaa成人免费观看视频| 国产性做久久久久久| 色美美综合视频| 国产在线视频一区二区| 亚洲激情五月婷婷| 精品久久五月天| 91久久精品一区二区| 黄一区二区三区| 一区二区三区四区视频精品免费 | 中文字幕第一页久久| 欧美日韩精品一区二区三区| 成人午夜激情片| 奇米精品一区二区三区在线观看| 国产精品美女一区二区在线观看| 欧美美女直播网站| 99久久精品免费精品国产| 久久精品噜噜噜成人av农村| 一区二区视频在线| 国产亚洲自拍一区| 日韩免费观看高清完整版在线观看| 99re这里只有精品6| 捆绑变态av一区二区三区| 亚洲美女区一区| 欧美国产一区二区| 精品精品国产高清一毛片一天堂| 欧美视频在线观看一区二区| 成人激情免费电影网址| 国内精品国产成人国产三级粉色 | 色欧美片视频在线观看| 国产成人av一区二区| 美女精品一区二区| 天堂va蜜桃一区二区三区| 亚洲欧美电影一区二区| 中日韩av电影| 国产午夜精品美女毛片视频| 欧美一级精品在线| 欧美电影在线免费观看| 欧美日韩一级黄| 在线亚洲精品福利网址导航| 91丨九色丨尤物| 99精品在线免费| eeuss鲁片一区二区三区在线看| 国产精品中文字幕日韩精品 | 国产一区二区精品久久| 免费高清成人在线| 日本中文字幕一区二区视频| 日本女优在线视频一区二区 | 国产精品美女一区二区三区 | 亚洲人123区| 亚洲婷婷综合色高清在线| 亚洲欧美综合另类在线卡通| 国产精品激情偷乱一区二区∴| 国产调教视频一区| 国产精品素人一区二区| 国产精品嫩草影院com| 国产精品久久久久久久久晋中| 国产精品久久久久四虎| 亚洲日穴在线视频| 亚洲综合在线观看视频| 亚洲国产精品久久人人爱| 亚洲成人手机在线| 视频一区二区中文字幕| 精品一区二区三区在线播放| 国产精品88888| 成人永久aaa| 在线欧美日韩精品| 欧美精品少妇一区二区三区| 日韩一卡二卡三卡国产欧美| 亚洲精品一区二区三区蜜桃下载| 久久精品夜色噜噜亚洲aⅴ| 国产精品三级av| 一区二区三区国产| 免费久久精品视频| 福利一区二区在线观看| 色欧美日韩亚洲| 精品三级在线看| 国产精品久久久久婷婷二区次| 亚洲韩国精品一区| 麻豆一区二区三| 成人黄色小视频| 欧美日本免费一区二区三区| 久久综合给合久久狠狠狠97色69| 日韩电影在线免费观看| 国产成人精品影视| 欧美日韩在线三区| 国产亚洲一区二区三区四区| 亚洲愉拍自拍另类高清精品| 婷婷国产在线综合| 丁香网亚洲国际| 91麻豆精品国产自产在线观看一区| 国产日韩精品久久久| 亚洲一二三区在线观看| 国产成人免费在线视频| 欧美三级蜜桃2在线观看| 国产亚洲成av人在线观看导航| 亚洲成人综合视频| 成人h动漫精品一区二| 91精品国产综合久久久久久久| 日本一区二区成人| 日本vs亚洲vs韩国一区三区| 91美女福利视频| 2021久久国产精品不只是精品| 伊人一区二区三区| 国产不卡高清在线观看视频| 欧美色图12p| 中文字幕一区二区三区四区 | 欧美巨大另类极品videosbest| 久久欧美一区二区| 天堂资源在线中文精品| av不卡免费电影| 久久久久久久久99精品| 日本伊人午夜精品| 欧美丝袜第三区| 一区二区三区自拍| 99re热这里只有精品免费视频| 久久无码av三级| 欧美aⅴ一区二区三区视频| 色欧美片视频在线观看在线视频| 日本一区二区三区四区在线视频| 久久 天天综合| 欧美另类z0zxhd电影| 成人欧美一区二区三区小说| 激情六月婷婷久久| 欧美岛国在线观看| 日本视频一区二区三区| 欧美理论在线播放| 午夜电影网亚洲视频| 欧美色图激情小说| 亚洲第一久久影院| 欧美日韩视频在线一区二区| 亚洲综合色在线| 在线观看日韩国产| 一区二区三区高清| 欧美亚洲自拍偷拍| 亚洲综合色网站| 欧美日韩在线不卡| 亚洲第一综合色| 欧美福利视频一区| 免费看日韩a级影片| 日韩三区在线观看| 狠狠色丁香婷婷综合久久片| 亚洲精品在线网站| 国产裸体歌舞团一区二区| 久久亚洲影视婷婷| 国产综合久久久久影院| 国产性色一区二区| 99re成人在线| 亚洲国产日韩综合久久精品| 欧美日韩精品专区| 精品一区二区免费视频| 久久久国产午夜精品| 成人久久18免费网站麻豆 | 欧美激情综合网| 不卡的av电影在线观看| 成人欧美一区二区三区小说 | 国产成人亚洲综合a∨婷婷图片| 久久久欧美精品sm网站| 成人激情图片网| 亚洲精品欧美激情| 9191成人精品久久| 美美哒免费高清在线观看视频一区二区| 日韩欧美久久久| 成人小视频在线| 亚洲综合区在线| 日韩欧美国产一区在线观看| 国产精品1024| 亚洲六月丁香色婷婷综合久久| 欧美老年两性高潮| 国产一区二区三区电影在线观看 | 91九色02白丝porn| 日本vs亚洲vs韩国一区三区二区|