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

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

?? os_sem.c

?? uCOSKeillpc22xx系統
?? 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一区二区三区免费野_久草精品视频
国产成人亚洲综合色影视| 成人不卡免费av| 国产精品色婷婷久久58| 欧美人与性动xxxx| 国产91精品在线观看| 亚洲成av人片在线观看无码| 国产欧美一区二区在线观看| 欧美日韩中字一区| www.成人网.com| 捆绑变态av一区二区三区| 亚洲免费成人av| 久久精品人人爽人人爽| 欧美一区二区视频在线观看| 色综合久久久网| 成人精品国产一区二区4080| 欧美亚一区二区| 粉嫩一区二区三区在线看| 日韩国产在线观看一区| 亚洲美女视频在线| 中文在线免费一区三区高中清不卡| 91精品婷婷国产综合久久竹菊| 一本色道**综合亚洲精品蜜桃冫| 国产一区二区免费看| 日韩影院在线观看| 亚洲精品成人在线| 中文字幕一区二区三区精华液| 日韩久久久久久| 欧美一二三区在线| 91超碰这里只有精品国产| 欧美综合天天夜夜久久| 色偷偷久久人人79超碰人人澡| 国产传媒日韩欧美成人| 精品一区二区三区影院在线午夜| 日韩福利视频导航| 日韩av中文在线观看| 一区二区激情视频| 夜夜揉揉日日人人青青一国产精品| 亚洲国产激情av| 久久久精品免费观看| 久久久国产精华| 久久精品视频一区二区| 久久久精品2019中文字幕之3| 精品国产三级a在线观看| 欧美大白屁股肥臀xxxxxx| 日韩一二三区不卡| 精品久久久久久久人人人人传媒| 91精品综合久久久久久| 91精品国产综合久久国产大片| 欧美日韩国产综合一区二区| 欧美日韩国产在线观看| 欧美日韩精品综合在线| 欧美肥胖老妇做爰| 日韩欧美不卡在线观看视频| 精品国产一二三| 中文字幕乱码久久午夜不卡| 亚洲欧洲成人精品av97| 亚洲精品国产成人久久av盗摄| 亚洲欧美自拍偷拍| 亚洲综合小说图片| 亚洲高清免费视频| 蜜桃视频在线一区| 国内成+人亚洲+欧美+综合在线| 国产精品一区二区三区乱码| 成人免费黄色大片| 一本久久a久久免费精品不卡| 欧美在线一二三四区| 欧美另类一区二区三区| ww久久中文字幕| 成人免费在线视频观看| 亚洲国产综合91精品麻豆| 日韩成人免费在线| 国产suv精品一区二区883| 一本大道久久精品懂色aⅴ| 欧美日韩综合在线| 久久久午夜电影| 亚洲色图在线看| 日韩国产一区二| 成人免费视频caoporn| 欧美亚洲国产bt| 亚洲精品在线观看网站| 国产mv日韩mv欧美| 欧美制服丝袜第一页| 精品国产一区二区三区忘忧草| 国产欧美一区二区精品性| 亚洲欧美成人一区二区三区| 爽好久久久欧美精品| 国产一区二区不卡老阿姨| 91麻豆123| 亚洲精品一区二区三区蜜桃下载| 国产精品久久一卡二卡| 轻轻草成人在线| 99久久精品一区| 亚洲精品一区二区在线观看| 亚洲一区二区成人在线观看| 国产成人aaa| 欧美浪妇xxxx高跟鞋交| 国产精品网站一区| 蜜桃久久久久久久| 91麻豆免费看片| 久久精品水蜜桃av综合天堂| 天天射综合影视| 99re视频这里只有精品| 久久精品亚洲乱码伦伦中文| 午夜久久电影网| 成人国产一区二区三区精品| 欧美一区二区三区免费在线看| 国产精品乱人伦中文| 蜜臀av一区二区在线免费观看| 色综合久久久网| 国产精品视频观看| 韩国毛片一区二区三区| 欧美一区二区人人喊爽| 亚洲国产成人av| 97精品国产露脸对白| 久久久久国色av免费看影院| 男女性色大片免费观看一区二区| 91黄色小视频| 最新久久zyz资源站| 国产suv精品一区二区883| 精品欧美一区二区久久| 日韩av一区二区三区四区| 国产精品入口麻豆原神| 国产综合色在线| 欧美电视剧免费全集观看| 免费看精品久久片| 欧美浪妇xxxx高跟鞋交| 性欧美疯狂xxxxbbbb| 91久久精品网| 夜夜嗨av一区二区三区中文字幕| 成人禁用看黄a在线| 欧美极品少妇xxxxⅹ高跟鞋| 国产乱码精品1区2区3区| 久久精品人人爽人人爽| 国产精品主播直播| 国产三级久久久| 成人免费黄色在线| 亚洲欧洲成人av每日更新| 99re这里只有精品视频首页| 亚洲日本青草视频在线怡红院| av亚洲精华国产精华精华| 国产精品高潮呻吟| 91在线观看一区二区| 亚洲欧洲日产国码二区| 色婷婷久久久亚洲一区二区三区| 亚洲柠檬福利资源导航| 91精彩视频在线观看| 五月天激情小说综合| 欧美一区二区三区免费在线看| 久久99精品国产麻豆婷婷洗澡| 欧美精品一区二区三区高清aⅴ | 日韩国产欧美在线播放| 欧美精品777| 精品一区二区三区欧美| 久久久久久久久久久久久女国产乱 | 精品国产a毛片| 国产成人精品免费看| 国产精品高潮呻吟| 欧美性猛片xxxx免费看久爱| 舔着乳尖日韩一区| 精品福利一区二区三区| 成人毛片在线观看| 亚洲综合免费观看高清在线观看| 欧美日韩中文字幕精品| 激情综合亚洲精品| 亚洲欧美自拍偷拍色图| 3d成人h动漫网站入口| 国产又粗又猛又爽又黄91精品| 国产精品久久久久久久久动漫| 欧美性大战久久久| 极品少妇xxxx精品少妇偷拍| 中文字幕亚洲一区二区av在线| 91高清在线观看| 激情图片小说一区| 亚洲女女做受ⅹxx高潮| 日韩一区二区三区高清免费看看| 国产精品99久久久久久似苏梦涵| 久久国产精品无码网站| 午夜激情久久久| 91麻豆成人久久精品二区三区| 亚洲成人精品在线观看| 精品久久久久久久人人人人传媒| 成人一区二区三区中文字幕| 亚洲综合丝袜美腿| 久久在线观看免费| 欧美在线|欧美| 国产不卡视频在线观看| 视频在线在亚洲| 国产精品久99| 欧美一级黄色大片| 一本久道中文字幕精品亚洲嫩| 久久成人久久爱| 亚洲一区二区三区四区不卡| 久久久精品黄色| 欧美精品久久一区| 成人app在线| 国产原创一区二区三区| 午夜久久久久久电影| 日韩理论片中文av| 久久综合五月天婷婷伊人| 欧美美女一区二区在线观看|