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

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

?? os_sem.c

?? ucos2/2.90-STM32
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                              (c) Copyright 1992-2009, Micrium, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.91
*
* 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_SEM_EN > 0u
/*$PAGE*/
/*
*********************************************************************************************************
*                                           ACCEPT SEMAPHORE
*
* Description: This function checks the semaphore to see if a resource is available or, if an event
*              occurred.  Unlike OSSemPend(), OSSemAccept() 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
*
* Returns    : >  0       if the resource is available or the event did not occur the semaphore is
*                         decremented to obtain the resource.
*              == 0       if the resource is not available or the event did not occur or,
*                         if 'pevent' is a NULL pointer or,
*                         if you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/

#if OS_SEM_ACCEPT_EN > 0u
INT16U  OSSemAccept (OS_EVENT *pevent)
{
    INT16U     cnt;
#if OS_CRITICAL_METHOD == 3u                          /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#if OS_ARG_CHK_EN > 0u
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        return (0u);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0u);
    }
    OS_ENTER_CRITICAL();
    cnt = pevent->OSEventCnt;
    if (cnt > 0u) {                                   /* See if resource is available                  */
        pevent->OSEventCnt--;                         /* Yes, decrement semaphore and notify caller    */
    }
    OS_EXIT_CRITICAL();
    return (cnt);                                     /* Return semaphore count                        */
}
#endif

/*$PAGE*/
/*
*********************************************************************************************************
*                                           CREATE A SEMAPHORE
*
* Description: This function creates a semaphore.
*
* Arguments  : cnt           is the initial value for the semaphore.  If the value is 0, no resource is
*                            available (or no event has occurred).  You initialize the semaphore to a
*                            non-zero value to specify how many resources are available (e.g. if you have
*                            10 resources, you would initialize the semaphore to 10).
*
* Returns    : != (void *)0  is a pointer to the event control block (OS_EVENT) associated with the
*                            created semaphore
*              == (void *)0  if no event control blocks were available
*********************************************************************************************************
*/

OS_EVENT  *OSSemCreate (INT16U cnt)
{
    OS_EVENT  *pevent;
#if OS_CRITICAL_METHOD == 3u                               /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL_IEC61508
    if (OSSafetyCriticalStartFlag == OS_TRUE) {
        OS_SAFETY_CRITICAL_EXCEPTION();
    }
#endif

    if (OSIntNesting > 0u) {                               /* See if called from ISR ...               */
        return ((OS_EVENT *)0);                            /* ... can't CREATE from an ISR             */
    }
    OS_ENTER_CRITICAL();
    pevent = OSEventFreeList;                              /* Get next free event control block        */
    if (OSEventFreeList != (OS_EVENT *)0) {                /* See if pool of free ECB pool was empty   */
        OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
    }
    OS_EXIT_CRITICAL();
    if (pevent != (OS_EVENT *)0) {                         /* Get an event control block               */
        pevent->OSEventType    = OS_EVENT_TYPE_SEM;
        pevent->OSEventCnt     = cnt;                      /* Set semaphore value                      */
        pevent->OSEventPtr     = (void *)0;                /* Unlink from ECB free list                */
#if OS_EVENT_NAME_EN > 0u
        pevent->OSEventName    = (INT8U *)(void *)"?";
#endif
        OS_EventWaitListInit(pevent);                      /* Initialize to 'nobody waiting' on sem.   */
    }
    return (pevent);
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                         DELETE A SEMAPHORE
*
* Description: This function deletes a semaphore and readies all tasks pending on the semaphore.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired
*                            semaphore.
*
*              opt           determines delete options as follows:
*                            opt == OS_DEL_NO_PEND   Delete semaphore ONLY if no task pending
*                            opt == OS_DEL_ALWAYS    Deletes the semaphore 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 semaphore was deleted
*                            OS_ERR_DEL_ISR          If you attempted to delete the semaphore from an ISR
*                            OS_ERR_INVALID_OPT      An invalid option was specified
*                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the semaphore
*                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a semaphore
*                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
*
* Returns    : pevent        upon error
*              (OS_EVENT *)0 if the semaphore was successfully deleted.
*
* Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the presence of
*                 the semaphore MUST check the return code of OSSemPend().
*              2) OSSemAccept() callers will not know that the intended semaphore has been deleted unless
*                 they check 'pevent' to see that it's a NULL pointer.
*              3) This call can potentially disable interrupts for a long time.  The interrupt disable
*                 time is directly proportional to the number of tasks waiting on the semaphore.
*              4) Because ALL tasks pending on the semaphore will be readied, you MUST be careful in
*                 applications where the semaphore is used for mutual exclusion because the resource(s)
*                 will no longer be guarded by the semaphore.
*********************************************************************************************************
*/

#if OS_SEM_DEL_EN > 0u
OS_EVENT  *OSSemDel (OS_EVENT  *pevent,
                     INT8U      opt,
                     INT8U     *perr)
{
    BOOLEAN    tasks_waiting;
    OS_EVENT  *pevent_return;
#if OS_CRITICAL_METHOD == 3u                               /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL
    if (perr == (INT8U *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
    }
#endif

#if OS_ARG_CHK_EN > 0u
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *perr = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *perr = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    if (OSIntNesting > 0u) {                               /* See if called from ISR ...               */
        *perr = OS_ERR_DEL_ISR;                            /* ... can't DELETE from an ISR             */
        return (pevent);
    }
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0u) {                        /* See if any tasks waiting on semaphore    */
        tasks_waiting = OS_TRUE;                           /* Yes                                      */
    } else {
        tasks_waiting = OS_FALSE;                          /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
             if (tasks_waiting == OS_FALSE) {
#if OS_EVENT_NAME_EN > 0u
                 pevent->OSEventName    = (INT8U *)(void *)"?";
#endif
                 pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr     = OSEventFreeList; /* Return Event Control Block to free list  */
                 pevent->OSEventCnt     = 0u;
                 OSEventFreeList        = pevent;          /* Get next free event control block        */
                 OS_EXIT_CRITICAL();
                 *perr                  = OS_ERR_NONE;
                 pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *perr                  = OS_ERR_TASK_WAITING;
                 pevent_return          = pevent;
             }
             break;

        case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
             while (pevent->OSEventGrp != 0u) {            /* Ready ALL tasks waiting for semaphore    */
                 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
             }
#if OS_EVENT_NAME_EN > 0u
             pevent->OSEventName    = (INT8U *)(void *)"?";
#endif
             pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr     = OSEventFreeList;     /* Return Event Control Block to free list  */
             pevent->OSEventCnt     = 0u;
             OSEventFreeList        = pevent;              /* Get next free event control block        */
             OS_EXIT_CRITICAL();
             if (tasks_waiting == OS_TRUE) {               /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *perr                  = OS_ERR_NONE;
             pevent_return          = (OS_EVENT *)0;       /* Semaphore has been deleted               */
             break;

        default:
             OS_EXIT_CRITICAL();
             *perr                  = OS_ERR_INVALID_OPT;
             pevent_return          = pevent;
             break;
    }
    return (pevent_return);
}
#endif

/*$PAGE*/
/*
*********************************************************************************************************
*                                           PEND ON SEMAPHORE
*
* Description: This function waits for a semaphore.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired
*                            semaphore.
*
*              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
*                            wait for the resource up to the amount of time specified by this argument.
*                            If you specify 0, however, your task will wait forever at the specified
*                            semaphore or, until the resource becomes available (or the event occurs).
*
*              perr          is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*
*                            OS_ERR_NONE         The call was successful and your task owns the resource
*                                                or, the event you are waiting for occurred.
*                            OS_ERR_TIMEOUT      The semaphore was not received within the specified
*                                                'timeout'.
*                            OS_ERR_PEND_ABORT   The wait on the semaphore was aborted.
*                            OS_ERR_EVENT_TYPE   If you didn't pass a pointer to a semaphore.
*                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
*                                                would lead to a suspension.
*                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer.
*                            OS_ERR_PEND_LOCKED  If you called this function when the scheduler is locked
*
* Returns    : none
*********************************************************************************************************
*/
/*$PAGE*/
void  OSSemPend (OS_EVENT  *pevent,
                 INT32U     timeout,
                 INT8U     *perr)
{
#if OS_CRITICAL_METHOD == 3u                          /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL
    if (perr == (INT8U *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
    }
#endif

#if OS_ARG_CHK_EN > 0u
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        *perr = OS_ERR_PEVENT_NULL;
        return;
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        *perr = OS_ERR_EVENT_TYPE;
        return;
    }
    if (OSIntNesting > 0u) {                          /* See if called from ISR ...                    */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
怡红院av一区二区三区| 91国产成人在线| 99久久99久久精品免费看蜜桃| 色成人在线视频| 国产日韩欧美a| 久久精品国产亚洲一区二区三区| 97se狠狠狠综合亚洲狠狠| 欧美不卡激情三级在线观看| 亚洲综合丝袜美腿| 成人精品小蝌蚪| 久久亚洲影视婷婷| 日韩av中文在线观看| 在线视频欧美精品| |精品福利一区二区三区| 国产原创一区二区| 日韩一级黄色片| 三级影片在线观看欧美日韩一区二区| 99久久er热在这里只有精品66| 日本一区二区三区电影| 国内一区二区在线| 91精品婷婷国产综合久久竹菊| 一区二区三区久久| 91久久精品一区二区三| 国产精品久久久久一区| 国产suv一区二区三区88区| 精品久久99ma| 国产一区二区h| 精品国产乱码久久久久久1区2区| 蜜桃精品在线观看| 91麻豆精品国产综合久久久久久| 国产精一品亚洲二区在线视频| 精品88久久久久88久久久| 日韩中文字幕不卡| 91精品国产高清一区二区三区蜜臀| 亚洲一级二级三级| 欧美日韩精品一二三区| 婷婷综合五月天| 日韩欧美一二三四区| 久久99精品视频| 国产视频视频一区| 大美女一区二区三区| 中文字幕一区二区在线播放| eeuss鲁一区二区三区| 亚洲色图制服诱惑 | 亚洲免费在线播放| 成人性色生活片| 亚洲免费观看在线观看| 欧美日本精品一区二区三区| 视频在线观看一区二区三区| 欧美一区二区美女| 国产成人av一区二区三区在线| 国产欧美精品日韩区二区麻豆天美| 成人免费黄色大片| 夜夜爽夜夜爽精品视频| 777xxx欧美| 国产精品香蕉一区二区三区| 国产精品久久99| 欧美日韩高清不卡| 激情文学综合网| 国产精品大尺度| 欧美色图免费看| 国产一区二区三区免费看| 亚洲精品一二三四区| 日韩一区二区三区在线观看| 国产成人av资源| 五月婷婷综合激情| 国产午夜精品福利| 欧美少妇bbb| 国产精品资源网| 亚洲午夜免费福利视频| 久久精品夜色噜噜亚洲aⅴ| 在线亚洲高清视频| 国产一区二区三区高清播放| 亚洲愉拍自拍另类高清精品| 久久久一区二区| 欧美视频三区在线播放| 国产精品88888| 亚洲1区2区3区4区| 国产精品久久久一区麻豆最新章节| 7777精品伊人久久久大香线蕉的 | 久久精品国产77777蜜臀| 国产精品免费人成网站| 91精品国产乱码| 色婷婷综合中文久久一本| 久88久久88久久久| 一区二区三区日本| 国产亚洲综合在线| 欧美一激情一区二区三区| 色婷婷精品大视频在线蜜桃视频 | 无码av中文一区二区三区桃花岛| 国产视频一区二区在线观看| 日韩欧美中文字幕公布| 欧美色爱综合网| 不卡的电影网站| 国产精品一区二区你懂的| 日本午夜精品一区二区三区电影 | 亚洲欧洲精品天堂一级 | 欧美探花视频资源| 成人av网址在线| 国产成人亚洲综合a∨婷婷| 日本伊人色综合网| 亚洲综合一二区| 亚洲精品综合在线| 国产精品成人网| 欧美国产视频在线| 久久久激情视频| 久久影院午夜论| 久久久久久久一区| 精品日韩一区二区| 精品国产污网站| 欧美成人欧美edvon| 欧美日韩不卡在线| 欧美肥胖老妇做爰| 欧美酷刑日本凌虐凌虐| 欧美日本一区二区| 欧美剧情片在线观看| 欧美精品一卡两卡| 欧美一区二区在线视频| 91精品国产综合久久久久| 欧美一区二区三区视频| 日韩视频一区二区| 精品少妇一区二区三区免费观看| ww久久中文字幕| 国产女主播视频一区二区| 国产精品热久久久久夜色精品三区| 国产精品天天看| 中文字幕亚洲在| 亚洲综合图片区| 日韩成人免费在线| 经典三级在线一区| 成人妖精视频yjsp地址| 91视频国产资源| 欧美在线你懂的| 日韩欧美在线123| 日韩欧美国产一区在线观看| 久久久高清一区二区三区| 中文无字幕一区二区三区| 亚洲欧美电影院| 亚洲成人午夜电影| 国产伦精品一区二区三区免费迷 | 亚洲一区二区在线播放相泽| 无码av中文一区二区三区桃花岛| 视频一区在线视频| 国产成人8x视频一区二区 | 丁香啪啪综合成人亚洲小说 | 成人福利视频在线| 欧美午夜精品久久久久久超碰 | 欧美熟乱第一页| 日韩欧美亚洲一区二区| 国产精品久久影院| 亚洲成av人影院| 国产精品小仙女| 欧美色图12p| 国产亚洲成年网址在线观看| 一区二区在线看| 国产精品亚洲人在线观看| 欧美在线观看一区| 国产亚洲欧洲一区高清在线观看| 一区二区三区四区中文字幕| 精品一区二区三区免费毛片爱| 色悠悠亚洲一区二区| 精品国产凹凸成av人导航| 亚洲一区在线播放| 成人一级黄色片| 日韩女优制服丝袜电影| 一区二区三区日韩在线观看| 国产suv精品一区二区三区| 在线成人高清不卡| 自拍偷自拍亚洲精品播放| 国产美女娇喘av呻吟久久 | 色综合久久88色综合天天| 日韩午夜激情电影| 亚洲精品日产精品乱码不卡| 国产一区二区三区四区五区入口| 欧美日韩一区高清| 亚洲欧美激情插| 成人一区在线看| 久久久久久久久久美女| 日本亚洲最大的色成网站www| 欧洲亚洲国产日韩| 亚洲视频免费看| 成人国产视频在线观看| 国产欧美日韩三区| 国产中文一区二区三区| 欧美一区二区网站| 亚洲福利一区二区| 色视频成人在线观看免| 亚洲婷婷综合色高清在线| 国产在线一区观看| 久久亚洲影视婷婷| 久久99国产精品免费| 欧美一级久久久久久久大片| 日本亚洲视频在线| 欧美一区二区三区在| 日本欧美一区二区三区| 91麻豆精品国产91久久久资源速度| 一区二区三区在线观看欧美| 91丝袜美腿高跟国产极品老师| 中文字幕不卡一区| 成a人片国产精品|