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

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

?? os_sem.c

?? 最小的嵌入式操作系統(tǒng)
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.76
*********************************************************************************************************
*/

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

#if OS_SEM_EN > 0
/*
*********************************************************************************************************
*                                           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 > 0
INT16U  OSSemAccept (OS_EVENT *pevent)
{
    INT16U     cnt;
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr;



    cpu_sr = 0;                                       /* Prevent compiler warning                      */
#endif    
#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        return (0);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
    OS_ENTER_CRITICAL();
    cnt = pevent->OSEventCnt;
    if (cnt > 0) {                                    /* 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 clock (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 == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;



    cpu_sr = 0;                                            /* Prevent compiler warning                 */
#endif    
    if (OSIntNesting > 0) {                                /* 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_SIZE > 1
        pevent->OSEventName[0] = '?';                      /* Unknown name                             */
        pevent->OSEventName[1] = OS_ASCII_NUL;
#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.
*
*              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 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 > 0
OS_EVENT  *OSSemDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
{
    BOOLEAN    tasks_waiting;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;



    cpu_sr = 0;                                            /* Prevent compiler warning                 */
#endif    
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *err = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0x00) {                      /* See if any tasks waiting on semaphore    */
        tasks_waiting = TRUE;                              /* Yes                                      */
    } else {
        tasks_waiting = FALSE;                             /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
             if (tasks_waiting == FALSE) {
#if OS_EVENT_NAME_SIZE > 1
                 pevent->OSEventName[0] = '?';             /* Unknown name                             */
                 pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
                 pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr     = OSEventFreeList; /* Return Event Control Block to free list  */
                 pevent->OSEventCnt     = 0;
                 OSEventFreeList        = pevent;          /* Get next free event control block        */
                 OS_EXIT_CRITICAL();
                 *err                   = OS_NO_ERR;
                 return ((OS_EVENT *)0);                   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *err                   = OS_ERR_TASK_WAITING;
                 return (pevent);
             }

        case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
             while (pevent->OSEventGrp != 0x00) {          /* Ready ALL tasks waiting for semaphore    */
                 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
#if OS_EVENT_NAME_SIZE > 1
             pevent->OSEventName[0] = '?';                 /* Unknown name                             */
             pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
             pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr     = OSEventFreeList;     /* Return Event Control Block to free list  */
             pevent->OSEventCnt     = 0;
             OSEventFreeList        = pevent;              /* Get next free event control block        */
             OS_EXIT_CRITICAL();
             if (tasks_waiting == TRUE) {                  /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *err = OS_NO_ERR;
             return ((OS_EVENT *)0);                       /* Semaphore has been deleted               */

        default:
             OS_EXIT_CRITICAL();
             *err = OS_ERR_INVALID_OPT;
             return (pevent);
    }
}
#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).
*
*              err           is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美亚洲国产一区二区三区va| 另类专区欧美蜜桃臀第一页| 91色视频在线| 亚洲一线二线三线久久久| 欧美视频日韩视频在线观看| 天使萌一区二区三区免费观看| 日韩欧美亚洲国产精品字幕久久久| 狠狠色综合播放一区二区| 国产日产欧美一区二区视频| 99久久亚洲一区二区三区青草| 一区二区三区中文字幕| 欧美一区二区三区电影| 国产精品一区二区三区四区| 亚洲色图丝袜美腿| 欧美日韩在线观看一区二区 | 91色.com| 五月激情综合网| 国产三级一区二区三区| 欧美中文字幕久久| 中文字幕一区二区三区不卡| 国产无一区二区| 在线欧美日韩国产| 国内成人免费视频| 亚洲一本大道在线| 精品国产免费人成在线观看| 91色婷婷久久久久合中文| 久久99精品国产.久久久久| 中文字幕一区二区三区av| 欧美一区二区精品| 99久久精品久久久久久清纯| 日韩av网站在线观看| 亚洲人精品午夜| 337p日本欧洲亚洲大胆色噜噜| 一本大道久久a久久综合| 免费在线成人网| 亚洲精品国产a久久久久久| 久久伊99综合婷婷久久伊| 91黄色免费观看| 国产精品一二三四| 日韩成人免费看| 亚洲人成精品久久久久久| 日韩欧美国产小视频| 91成人在线精品| 成人国产在线观看| 经典一区二区三区| 日本一不卡视频| 国产白丝精品91爽爽久久| 欧美日韩成人一区| 成人精品一区二区三区中文字幕| 日韩电影免费在线| 亚洲国产精品久久人人爱| 中文在线一区二区| 久久伊99综合婷婷久久伊| 欧美一级理论片| 欧美日韩一区二区在线视频| 91免费看视频| 99久久久免费精品国产一区二区| 国产成人精品亚洲午夜麻豆| 激情综合色综合久久| 美女精品一区二区| 青草国产精品久久久久久| 丝袜美腿成人在线| 亚洲国产精品综合小说图片区| 亚洲精品亚洲人成人网| 最新日韩av在线| 国产精品久久777777| 国产精品理伦片| 欧美韩国一区二区| 中文字幕不卡的av| 欧美国产日韩a欧美在线观看| 欧美在线小视频| 91欧美激情一区二区三区成人| 黄一区二区三区| 老司机一区二区| 蓝色福利精品导航| 精品亚洲免费视频| 国产乱码字幕精品高清av| 韩国午夜理伦三级不卡影院| 精品一区二区三区久久| 狠狠色丁香久久婷婷综合_中 | 亚洲欧美激情在线| 亚洲欧美日韩国产一区二区三区 | 欧美激情一区二区三区全黄| 国产精品色在线| 亚洲人成网站在线| 亚洲丶国产丶欧美一区二区三区| 亚洲成a人片在线观看中文| 婷婷综合另类小说色区| 免费成人av在线| 国产精品自拍一区| 色综合夜色一区| 26uuu亚洲综合色欧美| 中文字幕乱码亚洲精品一区| 亚洲欧洲日本在线| 亚洲成a人片综合在线| 久久精品国产精品青草| 国产91在线看| 欧洲精品一区二区| 欧美成人欧美edvon| 久久久久国产精品麻豆ai换脸| 久久精品亚洲乱码伦伦中文| 亚洲精品日韩专区silk| 日本91福利区| 丁香激情综合五月| 欧美日韩国产电影| 久久久亚洲欧洲日产国码αv| 中文字幕欧美一| 五月天中文字幕一区二区| 国产一区二区毛片| 91久久国产最好的精华液| 日韩欧美的一区| 亚洲精品一二三四区| 久久国产三级精品| 色av综合在线| 久久一留热品黄| 最新日韩av在线| 亚洲愉拍自拍另类高清精品| 日韩经典一区二区| 91视视频在线直接观看在线看网页在线看| 欧美福利电影网| 亚洲国产成人私人影院tom| 亚洲丰满少妇videoshd| 成人免费不卡视频| 日韩精品一区二| 中文字幕永久在线不卡| 久久疯狂做爰流白浆xx| 91小宝寻花一区二区三区| 制服丝袜日韩国产| 一区二区在线观看免费视频播放| 经典三级视频一区| 欧美性生活一区| 1000部国产精品成人观看| 精久久久久久久久久久| 欧美影片第一页| 国产精品人成在线观看免费| 精品制服美女久久| 欧美日韩国产综合视频在线观看| 国产精品丝袜久久久久久app| 男男视频亚洲欧美| 欧美性猛片aaaaaaa做受| 国产精品久久久久久久久免费桃花| 免费不卡在线观看| 欧美肥妇free| 天堂蜜桃一区二区三区| 欧美日韩久久一区二区| 亚洲精品视频自拍| 色诱视频网站一区| 成人免费一区二区三区视频 | 成人动漫中文字幕| 久久先锋影音av| 久久电影网站中文字幕| 日韩视频免费观看高清完整版在线观看 | 国产麻豆精品在线| 精品入口麻豆88视频| 蜜臀av一级做a爰片久久| 欧美卡1卡2卡| 日产欧产美韩系列久久99| 欧美浪妇xxxx高跟鞋交| 日韩av中文字幕一区二区三区| 欧美日韩1区2区| 日韩电影在线免费| 91精品欧美福利在线观看| 午夜电影一区二区| 欧美一二三四区在线| 久久精品国产999大香线蕉| 日韩欧美激情在线| 九色porny丨国产精品| 欧美草草影院在线视频| 久久9热精品视频| 久久亚区不卡日本| 成人h版在线观看| 亚洲丝袜自拍清纯另类| 在线亚洲+欧美+日本专区| 午夜影院在线观看欧美| 91精品国产综合久久精品麻豆| 麻豆国产精品一区二区三区| 26uuu国产在线精品一区二区| 国内精品免费在线观看| 国产精品久久久久久一区二区三区| 97久久精品人人澡人人爽| 一区二区三区.www| 欧美一激情一区二区三区| 国产一区二区三区精品视频| 国产精品成人免费| 欧美日韩精品欧美日韩精品一| 麻豆精品一区二区综合av| 久久久亚洲精品石原莉奈| 91在线观看免费视频| 同产精品九九九| 久久久久久久久99精品| 91在线porny国产在线看| 午夜精品爽啪视频| 久久综合给合久久狠狠狠97色69| 99精品久久只有精品| 水蜜桃久久夜色精品一区的特点| 精品国产电影一区二区| 91视频一区二区| 另类的小说在线视频另类成人小视频在线 | 国产精品白丝av| 洋洋成人永久网站入口|