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

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

?? os_sem.c

?? ucosii-2.76 ucosii 的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                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:
*

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆91精品91久久久的内涵| 久久99蜜桃精品| 欧美岛国在线观看| 99精品国产一区二区三区不卡| 午夜久久久久久久久| 欧美经典三级视频一区二区三区| 在线免费观看不卡av| 国产盗摄女厕一区二区三区| 亚洲伊人色欲综合网| 中文字幕免费不卡在线| 91精品国产全国免费观看| 91在线精品一区二区三区| 韩国女主播一区二区三区| 亚洲国产日日夜夜| 中文字幕一区二区三区在线不卡 | 欧美性大战久久久久久久蜜臀| 韩国女主播一区| 日韩福利视频导航| 亚洲精品中文在线影院| 国产三级欧美三级日产三级99 | 国产精品一级片在线观看| 天天综合天天综合色| 亚洲精品中文在线观看| 国产精品免费视频一区| 久久先锋影音av鲁色资源网| 欧美一区二区成人6969| 欧美日韩一级片网站| 日本高清不卡视频| 91麻豆国产福利在线观看| 成人免费黄色大片| 国产成+人+日韩+欧美+亚洲| 欧美三级中文字| 岛国精品在线播放| 国产suv精品一区二区三区| 极品少妇xxxx精品少妇偷拍 | 成人黄色在线视频| 国产不卡在线播放| 国产成人免费高清| 亚洲精品国产一区二区精华液| 中文字幕+乱码+中文字幕一区| 久久久噜噜噜久噜久久综合| 欧美成人激情免费网| 精品国产一区二区三区av性色| 日韩小视频在线观看专区| 日韩欧美一区二区三区在线| 91麻豆精品国产91久久久久| 69堂国产成人免费视频| 欧美一三区三区四区免费在线看| 在线播放欧美女士性生活| 欧美丰满少妇xxxbbb| 91精品婷婷国产综合久久性色| 777久久久精品| 欧美成人伊人久久综合网| 日韩女优制服丝袜电影| 久久天天做天天爱综合色| 国产欧美日本一区视频| 亚洲欧美怡红院| 亚洲综合男人的天堂| 日日夜夜精品视频免费| 美女mm1313爽爽久久久蜜臀| 国产高清无密码一区二区三区| 99国产精品视频免费观看| 在线精品视频小说1| 日韩一区二区三区精品视频| 精品福利av导航| 国产精品国产自产拍高清av | 欧美性生活久久| 4438x亚洲最大成人网| 精品福利一区二区三区| 国产精品久久久久久久久免费樱桃 | 一本大道久久精品懂色aⅴ| 欧美性受xxxx黑人xyx性爽| 91精品国产乱码| 久久久久9999亚洲精品| 亚洲精品自拍动漫在线| 日本系列欧美系列| 波多野结衣中文字幕一区二区三区 | 日韩一区二区免费在线观看| 欧美mv日韩mv亚洲| 欧美国产成人精品| 亚洲午夜电影在线观看| 久久电影网站中文字幕| 99精品视频在线免费观看| 欧美三日本三级三级在线播放| 欧美v日韩v国产v| 亚洲三级在线看| 麻豆一区二区三| 99热精品一区二区| 欧美疯狂做受xxxx富婆| 中文字幕欧美日韩一区| 香蕉久久一区二区不卡无毒影院| 国产一区二区三区在线观看免费视频 | 亚洲激情av在线| 极品美女销魂一区二区三区免费| 一本大道综合伊人精品热热 | 91色在线porny| 日韩亚洲欧美高清| 亚洲欧美一区二区三区久本道91| 日本中文字幕一区二区视频 | 亚洲人成伊人成综合网小说| 裸体健美xxxx欧美裸体表演| 99久久伊人精品| 精品福利一二区| 天天综合网天天综合色| av一区二区三区黑人| 欧美岛国在线观看| 亚洲高清视频中文字幕| 成人毛片在线观看| 日韩欧美中文字幕精品| 亚洲一区在线观看网站| av亚洲精华国产精华| 337p粉嫩大胆噜噜噜噜噜91av | 日韩主播视频在线| 91蜜桃视频在线| 国产农村妇女精品| 国产在线一区观看| 日韩欧美高清dvd碟片| 亚洲国产一区二区三区青草影视| av中文字幕一区| 亚洲国产精华液网站w| 国产精品一区二区在线观看网站| 91精品综合久久久久久| 亚洲国产精品尤物yw在线观看| 92国产精品观看| 中文字幕中文在线不卡住| 粉嫩aⅴ一区二区三区四区五区 | 精品人在线二区三区| k8久久久一区二区三区| 久久久久久久久99精品| 久久99深爱久久99精品| 日韩午夜在线影院| 日本欧美加勒比视频| 欧美日韩一区 二区 三区 久久精品| 亚洲欧美日韩中文播放| 91国内精品野花午夜精品| 一区二区免费在线| 色婷婷综合久久| 亚洲国产wwwccc36天堂| 911国产精品| 久久国产精品第一页| 久久影院视频免费| 国产麻豆欧美日韩一区| 久久久久国产精品麻豆| 成人毛片老司机大片| 亚洲人xxxx| 欧美在线999| 亚洲va欧美va天堂v国产综合| 欧美视频一区二区三区在线观看| 性欧美疯狂xxxxbbbb| 这里只有精品视频在线观看| 麻豆91精品视频| 国产午夜精品在线观看| 97精品久久久午夜一区二区三区 | 五月天婷婷综合| 日韩一区二区免费电影| 国产在线精品一区二区夜色 | 国产一区二区三区电影在线观看| 久久久噜噜噜久久中文字幕色伊伊 | 亚洲男人的天堂网| 欧美美女直播网站| 精品中文字幕一区二区| 国产三级精品视频| 91美女片黄在线| 免费成人在线影院| 国产偷v国产偷v亚洲高清| 91一区二区三区在线观看| 亚洲高清视频中文字幕| 精品国产乱码久久久久久蜜臀| 国产成人午夜视频| 亚洲国产毛片aaaaa无费看| 日韩精品综合一本久道在线视频| 国产精品一二二区| 亚洲一区二区在线播放相泽| 精品精品欲导航| 9i看片成人免费高清| 亚洲va欧美va人人爽| 久久精品夜色噜噜亚洲a∨ | 国产午夜精品一区二区三区嫩草| 色综合天天综合网天天看片| 天堂成人国产精品一区| 国产性天天综合网| 欧美日韩成人综合在线一区二区| 国产精品一级在线| 亚洲国产日韩一区二区| 国产日韩欧美综合在线| 欧美日韩午夜影院| 国产v综合v亚洲欧| 日韩vs国产vs欧美| 国产成人免费在线观看不卡| 香港成人在线视频| 国产精品午夜久久| 日韩三级在线观看| 91老司机福利 在线| 美国一区二区三区在线播放| 亚洲欧美激情一区二区| 精品国产乱码久久| 欧美日韩免费不卡视频一区二区三区| 高清shemale亚洲人妖| 免费观看久久久4p| 亚洲电影一区二区三区|