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

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

?? 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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色一情一乱一乱一91av| 国产一区二区三区四区五区美女| 91女神在线视频| 国产精品你懂的在线欣赏| 99精品欧美一区二区蜜桃免费| 亚洲精品视频在线观看网站| 在线观看91精品国产入口| 视频一区二区三区在线| 精品国产乱码久久久久久夜甘婷婷| 国产精品一区二区黑丝| 中文字幕不卡一区| 在线影视一区二区三区| 日本不卡中文字幕| 亚洲国产精品成人久久综合一区| 色一区在线观看| 日韩不卡一区二区三区| 国产无一区二区| 欧美视频一二三区| 久久国产人妖系列| 国产精品五月天| 欧美日韩一级二级| 国产自产v一区二区三区c| 亚洲欧美偷拍卡通变态| 日韩视频在线你懂得| 成人福利在线看| 奇米影视在线99精品| 国产精品拍天天在线| 欧美另类久久久品| 国产91综合网| 免费高清视频精品| 亚洲天堂网中文字| 精品国产一区二区国模嫣然| 99热这里都是精品| 久久精品72免费观看| 亚洲免费伊人电影| 美女网站色91| 国产精品白丝在线| 亚洲精品一区二区三区99| 91传媒视频在线播放| 国产福利不卡视频| 蜜桃精品视频在线| 亚洲成人免费在线观看| 国产精品你懂的在线欣赏| 欧美成人免费网站| 欧美色倩网站大全免费| www.久久久久久久久| 极品少妇一区二区| 性久久久久久久| 亚洲视频香蕉人妖| 久久久av毛片精品| 欧美www视频| 欧美日韩精品一区二区三区 | 亚洲一卡二卡三卡四卡| 久久蜜桃香蕉精品一区二区三区| 欧美群妇大交群中文字幕| 色综合久久久久综合体| av一区二区三区四区| 国产大片一区二区| 国产一区二区主播在线| 久久国产综合精品| 麻豆成人免费电影| 日韩不卡一区二区| 亚洲电影一级片| 亚洲一二三四久久| 依依成人综合视频| 亚洲精品一二三四区| 亚洲美女屁股眼交3| 亚洲欧美色综合| 中文字幕日本不卡| 亚洲婷婷国产精品电影人久久| 国产精品久久午夜| 国产精品久久久久久久久快鸭| 中文字幕av在线一区二区三区| 2023国产精品自拍| 久久久激情视频| 欧美激情自拍偷拍| 欧美—级在线免费片| 国产精品电影一区二区| 亚洲视频中文字幕| 亚洲福利视频一区| 日韩精品欧美精品| 蜜芽一区二区三区| 国模大尺度一区二区三区| 国产电影精品久久禁18| 成人高清视频免费观看| 色呦呦网站一区| 欧美日韩在线一区二区| 在线综合亚洲欧美在线视频| 欧美一区午夜精品| 久久婷婷久久一区二区三区| 国产亚洲美州欧州综合国| 国产精品美女久久久久久久| 国产精品久久久久久久久动漫 | 欧美视频一区二| 欧美一区二区三区男人的天堂| 欧美成人性战久久| 久久精品国产99| 高清久久久久久| 91美女视频网站| 777久久久精品| 国产拍欧美日韩视频二区| 国产精品传媒入口麻豆| 亚洲第一福利视频在线| 国模套图日韩精品一区二区 | 狠狠色综合播放一区二区| 成人在线一区二区三区| 欧美日韩一区二区在线观看| 日韩欧美一区二区免费| 国产精品久久毛片av大全日韩| 亚洲一区二区成人在线观看| 黄页网站大全一区二区| av亚洲精华国产精华精华| 欧美三级日韩在线| 国产欧美综合在线观看第十页| 亚洲精品亚洲人成人网| 国产一区二区三区最好精华液| 色综合 综合色| 日韩免费一区二区三区在线播放| 国产精品污网站| 日韩二区在线观看| 99国产精品国产精品毛片| 欧美区在线观看| 亚洲欧洲99久久| 激情久久五月天| 欧美日韩国产大片| 国产精品嫩草99a| 精品一区二区综合| 欧美丝袜丝nylons| 国产精品国产a| 国产乱人伦偷精品视频不卡| 欧美日韩国产在线播放网站| 国产精品久线观看视频| 韩国毛片一区二区三区| 欧美日韩国产小视频| 中文字幕在线视频一区| 国精产品一区一区三区mba视频| 欧美日韩久久久一区| 成人欧美一区二区三区1314| 激情小说亚洲一区| 91精品国产一区二区人妖| 亚洲与欧洲av电影| 97精品视频在线观看自产线路二| 久久精品男人天堂av| 裸体歌舞表演一区二区| 欧美精品九九99久久| 一区二区三区不卡在线观看| 99久久国产综合色|国产精品| 久久亚洲一区二区三区明星换脸 | 中文字幕av资源一区| 久久精品国产亚洲一区二区三区 | 美女免费视频一区二区| 欧美日韩一区二区在线观看视频| 亚洲视频在线一区二区| 成人免费毛片片v| 日本一区二区不卡视频| 国产一区二区三区最好精华液| 日韩欧美电影一二三| 免费国产亚洲视频| 日韩精品一区二区三区蜜臀 | 欧美成人艳星乳罩| 日本亚洲电影天堂| 91精品国产品国语在线不卡 | 欧美日韩亚洲综合一区| 亚洲动漫第一页| 欧美色偷偷大香| 亚洲电影在线播放| 91麻豆精品国产91久久久使用方法| 天天操天天综合网| 欧美另类久久久品| 麻豆成人免费电影| 26uuu国产电影一区二区| 国产综合色精品一区二区三区| 精品国产乱码久久久久久蜜臀| 国精产品一区一区三区mba视频| www国产成人| 成年人国产精品| 亚洲男同性恋视频| 欧美日韩一区二区在线视频| 日本最新不卡在线| 久久香蕉国产线看观看99| 国产91丝袜在线18| 亚洲另类中文字| 在线观看91av| 国产成人亚洲综合a∨猫咪| 国产精品毛片久久久久久| 色嗨嗨av一区二区三区| 日本大胆欧美人术艺术动态| 久久―日本道色综合久久| 成人av网址在线| 亚洲高清一区二区三区| 欧美成人激情免费网| 成人性生交大片免费| 亚洲一区二区三区影院| 欧美成人aa大片| av成人动漫在线观看| 五月激情六月综合| 国产欧美日韩另类一区| 精品视频1区2区| 国产福利电影一区二区三区| 亚洲一区二区视频|