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

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

?? os_mutex.c

?? UCOS-II FOR STM32F103XX 1 本程序是我自己移植
?? C
?? 第 1 頁 / 共 3 頁
字號(hào):
/*
*********************************************************************************************************
*                                                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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美午夜片在线看| 亚洲黄网站在线观看| 欧美婷婷六月丁香综合色| 成人精品视频一区二区三区尤物| 久久精品国内一区二区三区| 日韩av不卡一区二区| 亚洲五码中文字幕| 亚洲国产精品久久人人爱| 一区二区三区免费看视频| 中文字幕日韩av资源站| 最新国产の精品合集bt伙计| 日韩毛片视频在线看| 日韩一区欧美一区| 中文字幕亚洲不卡| 亚洲精品日产精品乱码不卡| 亚洲日本青草视频在线怡红院| 中文字幕乱码一区二区免费| 国产欧美一区二区三区在线老狼| 欧美v亚洲v综合ⅴ国产v| www久久久久| 国产精品国产自产拍高清av| 亚洲免费av在线| 亚洲一区二区av在线| 午夜精品福利一区二区蜜股av| 日韩专区在线视频| 精品一区二区三区欧美| 国产成人精品在线看| 99久久精品一区| 欧美亚洲另类激情小说| 宅男噜噜噜66一区二区66| 精品国产乱码91久久久久久网站| 国产区在线观看成人精品| 一区二区三区日韩| 久久99精品久久久久久国产越南 | 国内精品写真在线观看| 亚洲国产另类精品专区| 经典三级在线一区| 成人国产在线观看| 欧美日韩国产大片| 久久久久久夜精品精品免费| 国产亚洲成年网址在线观看| 亚洲欧美激情小说另类| 另类成人小视频在线| 国产91丝袜在线18| 欧美日韩中文字幕精品| 久久久精品欧美丰满| 亚洲线精品一区二区三区 | 亚洲欧美中日韩| 美女高潮久久久| 91啦中文在线观看| 久久久亚洲精品石原莉奈| 亚洲成人免费在线观看| 国产成人精品免费一区二区| 日韩午夜在线观看视频| 伊人性伊人情综合网| 国产91丝袜在线18| 日韩欧美成人一区二区| 樱花草国产18久久久久| 成人午夜私人影院| 欧美中文字幕一二三区视频| 中文一区二区完整视频在线观看| 美女网站色91| 欧美日韩一区二区三区在线| 亚洲欧美一区二区在线观看| 国产成人在线色| 日韩一区二区在线观看| 亚洲国产精品一区二区久久| 97se亚洲国产综合在线| 国产色91在线| 国产一区日韩二区欧美三区| 欧美一区二区精品在线| 日韩福利电影在线| 欧美一区二区三区播放老司机| 亚洲一区二区欧美日韩| 欧美羞羞免费网站| 亚洲一区二区高清| 4hu四虎永久在线影院成人| 亚洲激情成人在线| 欧美性猛交xxxx黑人交| 一区二区在线看| 国产成人av电影在线| 国产女同性恋一区二区| 懂色av中文字幕一区二区三区| 精品国产1区二区| 精品一区二区三区在线视频| 日韩免费一区二区| 国产美女视频91| 3atv在线一区二区三区| 麻豆高清免费国产一区| 日韩午夜精品视频| 老司机午夜精品| 日韩欧美资源站| 极品美女销魂一区二区三区| 久久亚洲综合色一区二区三区 | av午夜精品一区二区三区| 国产女人18水真多18精品一级做| 久久av中文字幕片| 国产亚洲va综合人人澡精品| av亚洲精华国产精华精| 日韩毛片精品高清免费| 欧美日韩国产成人在线91| 精品一区二区久久久| 国产精品免费av| 欧美综合亚洲图片综合区| 美女在线观看视频一区二区| 久久久亚洲精华液精华液精华液 | 韩国理伦片一区二区三区在线播放| 日韩免费观看高清完整版 | 天堂影院一区二区| 久久综合色综合88| 一本久道中文字幕精品亚洲嫩| 亚洲mv在线观看| 久久九九久精品国产免费直播| 99久久99久久免费精品蜜臀| 奇米影视一区二区三区| 日韩美女啊v在线免费观看| 欧美一三区三区四区免费在线看 | 91蜜桃在线免费视频| 亚洲精品成人精品456| 精品久久久久一区二区国产| 91麻豆精品一区二区三区| 精品一区二区三区不卡| 亚洲成人综合网站| 国产精品天美传媒沈樵| 欧美一区二区三区男人的天堂| 成人动漫一区二区| 经典三级视频一区| 日韩中文字幕一区二区三区| 中文字幕亚洲一区二区va在线| 精品国产髙清在线看国产毛片| 色综合久久综合中文综合网| 国产一本一道久久香蕉| 视频在线观看国产精品| 一区二区不卡在线播放 | 成人免费视频一区| 国产在线一区观看| 日韩国产一区二| 亚洲综合视频在线| 亚洲三级电影网站| 亚洲三级在线免费| 国产日韩精品一区二区三区| 精品国产精品一区二区夜夜嗨| 欧美一区二区三区四区五区| 欧美色网一区二区| 欧美午夜电影在线播放| 91欧美一区二区| 色婷婷亚洲综合| 色哟哟国产精品免费观看| 白白色亚洲国产精品| 大桥未久av一区二区三区中文| 国产成人在线免费| 成人免费视频一区| 成人黄页毛片网站| 99久久久免费精品国产一区二区| av在线这里只有精品| 成人动漫在线一区| 色网站国产精品| 欧美色国产精品| 日韩午夜精品视频| 欧美va在线播放| 国产欧美一区二区精品性| 国产欧美精品一区二区色综合| 国产精品人成在线观看免费| 亚洲欧洲一区二区三区| 夜夜嗨av一区二区三区中文字幕| 亚洲综合色丁香婷婷六月图片| 日日骚欧美日韩| 精品亚洲aⅴ乱码一区二区三区| 国产精品一区二区91| 成人午夜碰碰视频| 91麻豆产精品久久久久久| 精品视频全国免费看| 日韩欧美一区二区久久婷婷| 久久久久久97三级| 亚洲欧洲精品一区二区三区不卡| 亚洲一区二区三区影院| 美女脱光内衣内裤视频久久网站 | 久久天天做天天爱综合色| 国产精品―色哟哟| 亚洲国产欧美另类丝袜| 老司机精品视频一区二区三区| 成人夜色视频网站在线观看| 欧美亚洲综合在线| 亚洲精品在线网站| 亚洲日本护士毛茸茸| 日韩av不卡一区二区| 成人激情小说网站| 欧美精品色综合| 国产精品美女久久久久av爽李琼| 亚洲制服丝袜在线| 国产91丝袜在线播放0| 欧美日韩国产高清一区二区| 久久久久综合网| 亚洲sss视频在线视频| 成人夜色视频网站在线观看| 91麻豆精品久久久久蜜臀| 中文字幕日本不卡| 国产乱码精品一区二区三| 91官网在线免费观看| 中文字幕欧美激情|