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

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

?? os_sem.c

?? uCOSKeillpc22xx系統(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一区二区三区免费野_久草精品视频
婷婷综合久久一区二区三区| 99久久久久免费精品国产| 亚洲18影院在线观看| 一区二区三区四区高清精品免费观看| 国产日韩欧美综合一区| 久久蜜桃香蕉精品一区二区三区| 日韩美一区二区三区| 欧美一个色资源| 精品三级在线看| 久久久久青草大香线综合精品| xvideos.蜜桃一区二区| 久久美女艺术照精彩视频福利播放| 精品欧美一区二区在线观看 | 久久精品一区四区| 久久精品网站免费观看| 国产欧美日韩综合精品一区二区| 中文一区二区在线观看| 国产精品久久久久久久久免费桃花| 亚洲国产精品二十页| 国产精品免费看片| 亚洲欧美一区二区久久| 亚洲国产一区二区三区 | 色婷婷综合久久久久中文| 色婷婷综合久久久中文字幕| 精品视频色一区| 亚洲激情校园春色| 夜夜嗨av一区二区三区网页| 午夜精品爽啪视频| 久久国产剧场电影| 不卡电影一区二区三区| 欧美中文字幕不卡| 欧美电视剧在线看免费| 国产精品久久久久9999吃药| 夜夜嗨av一区二区三区| 日本一区中文字幕| 国产成人精品影视| 欧美在线一区二区三区| 欧美一级午夜免费电影| 久久久久国产精品麻豆ai换脸 | 久久狠狠亚洲综合| 国产成人综合视频| 欧美在线看片a免费观看| 日韩网站在线看片你懂的| 中文字幕乱码亚洲精品一区| 亚洲一区在线视频观看| 国产在线国偷精品产拍免费yy| 91丝袜美女网| 日韩欧美视频一区| 亚洲人成小说网站色在线| 日韩高清在线一区| av资源网一区| 日韩精品一区二区三区中文精品| 1024亚洲合集| 美美哒免费高清在线观看视频一区二区 | 91精品国产综合久久福利| 久久精品视频在线看| 亚洲成a人片综合在线| 国产精品综合一区二区| 欧美日韩一区 二区 三区 久久精品| 久久综合成人精品亚洲另类欧美| 亚洲夂夂婷婷色拍ww47| 国产麻豆午夜三级精品| 精品视频一区二区不卡| 国产精品不卡视频| 久久99精品久久久久久久久久久久| 97超碰欧美中文字幕| 精品国产sm最大网站| 午夜精品在线视频一区| 91污片在线观看| 久久久久国色av免费看影院| 日韩精品电影一区亚洲| av动漫一区二区| 久久久久九九视频| 日本视频在线一区| 欧美三级日本三级少妇99| 亚洲天堂2014| 国产·精品毛片| 亚洲精品一区二区在线观看| 日韩高清在线电影| 欧美视频一区在线| 亚洲码国产岛国毛片在线| 国产aⅴ综合色| www成人在线观看| 日精品一区二区三区| 色国产综合视频| 亚洲色大成网站www久久九九| 国产成人aaa| 国产午夜精品理论片a级大结局| 日韩av在线免费观看不卡| 欧美性猛交xxxx黑人交| 亚洲人成网站影音先锋播放| 成人av网址在线| 亚洲国产成人午夜在线一区| 国产美女精品在线| 久久综合精品国产一区二区三区 | 在线视频欧美精品| 亚洲免费在线视频| www.日韩在线| 中文字幕亚洲一区二区av在线| 东方aⅴ免费观看久久av| 久久先锋资源网| 国产乱对白刺激视频不卡| www激情久久| 26uuu色噜噜精品一区| 久草精品在线观看| 精品裸体舞一区二区三区| 精品亚洲欧美一区| 久久久久久久久久久电影| 国产福利一区在线| 日本一二三不卡| 99视频超级精品| 一区二区三区在线免费播放| 欧美在线三级电影| 亚洲成人自拍偷拍| 欧美一区二区三区男人的天堂| 日本欧美加勒比视频| 欧美成人精品二区三区99精品| 精品一区二区三区蜜桃| 久久久精品国产99久久精品芒果 | 色综合天天狠狠| 亚洲已满18点击进入久久| 欧美日韩国产综合久久| 日韩av中文字幕一区二区三区| 精品三级av在线| 成人免费看片app下载| 亚洲日本va午夜在线电影| 欧美视频自拍偷拍| 精品一区二区三区免费毛片爱| 国产日本欧美一区二区| 色婷婷国产精品| 日韩成人午夜电影| 国产日产亚洲精品系列| 色伊人久久综合中文字幕| 亚洲成人资源网| 久久先锋影音av鲁色资源网| av男人天堂一区| 亚瑟在线精品视频| 日韩免费性生活视频播放| 丁香六月久久综合狠狠色| 亚洲久本草在线中文字幕| 欧美欧美欧美欧美首页| 韩国一区二区在线观看| 亚洲伦理在线精品| 3atv在线一区二区三区| 国产成人在线网站| 亚洲成人www| 国产欧美日韩在线看| 欧美日韩一区不卡| 福利91精品一区二区三区| 亚洲电影第三页| 欧美国产精品v| 欧美一三区三区四区免费在线看| 国产精品88888| 欧美午夜免费电影| 国产另类ts人妖一区二区| 一区二区三区在线视频观看| 欧美成人一区二区| 91电影在线观看| 国产美女精品在线| 午夜精品免费在线观看| 中文字幕在线一区免费| 制服丝袜av成人在线看| 不卡的av网站| 黄色小说综合网站| 天堂蜜桃一区二区三区| 国产精品美女久久久久久| 日韩欧美中文字幕制服| 91麻豆成人久久精品二区三区| 极品少妇一区二区| 亚洲成人动漫精品| 亚洲乱码日产精品bd| 久久综合九色综合欧美98| 欧美顶级少妇做爰| 色婷婷av一区二区三区之一色屋| 国产精品中文字幕一区二区三区| 午夜久久久影院| 亚洲精品ww久久久久久p站| 国产欧美精品一区二区色综合| 欧美一级高清大全免费观看| 91激情五月电影| www.欧美.com| 国产精品18久久久久久久网站| 视频一区二区三区中文字幕| 亚洲欧美日韩一区二区 | 偷拍亚洲欧洲综合| 综合激情网...| 国产精品萝li| 久久久久久久久久久久久夜| 日韩欧美一区在线| 欧美精选一区二区| 欧美日韩在线观看一区二区| 91蝌蚪porny成人天涯| 国产sm精品调教视频网站| 国产一区二区在线影院| 免费精品视频在线| 欧美bbbbb| 麻豆精品久久久| 麻豆freexxxx性91精品| 青娱乐精品视频| 男人的天堂亚洲一区|