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

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

?? 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:
*

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕一区二区三区四区| 亚洲乱码精品一二三四区日韩在线| 国产视频亚洲色图| 久久国产精品无码网站| 韩国精品主播一区二区在线观看| 成人av动漫网站| 69p69国产精品| 中文在线一区二区| 五月天网站亚洲| 9色porny自拍视频一区二区| 91精品黄色片免费大全| 亚洲乱码国产乱码精品精98午夜 | 精品一区二区三区在线视频| 欧美在线不卡一区| 国产欧美综合在线| 午夜精品123| 在线观看一区二区精品视频| 欧美—级在线免费片| 久久国产精品99精品国产| 91免费观看视频| 国产日韩欧美一区二区三区乱码| 亚洲视频每日更新| 国产成人aaa| 欧美精品一区二区三区在线| 免费成人小视频| 欧美日韩国产一级二级| 国产亚洲精品超碰| 久久国产福利国产秒拍| 69成人精品免费视频| 无码av中文一区二区三区桃花岛| 欧美视频中文一区二区三区在线观看| 国产色一区二区| 国产一区二区三区最好精华液| 精品日韩成人av| 精品夜夜嗨av一区二区三区| 欧美精品99久久久**| 国产黄人亚洲片| 欧美一区二区三区在线看| 亚洲精品国产a| 欧洲一区二区av| 亚洲国产日韩在线一区模特| 欧美日韩精品一区二区天天拍小说 | 亚洲另类在线视频| 国产成a人亚洲| 国产视频一区在线播放| 99re在线视频这里只有精品| 一区二区在线电影| 欧美久久久久中文字幕| 韩国精品免费视频| 亚洲欧美国产三级| 欧美成人伊人久久综合网| 国产成人精品免费在线| 亚洲午夜久久久久久久久电影院| 日韩免费视频线观看| 国产成人精品免费看| 亚洲欧洲日本在线| 6080午夜不卡| 99久久99久久综合| 成人免费视频视频| 午夜视频一区在线观看| 国产区在线观看成人精品| 欧美酷刑日本凌虐凌虐| 91丨九色丨国产丨porny| 亚洲美女视频在线观看| 日韩毛片精品高清免费| 欧美日韩国产免费一区二区| 麻豆91精品视频| 欧美高清在线精品一区| 日韩欧美在线综合网| 欧美剧情片在线观看| 欧美在线短视频| 91理论电影在线观看| 黄页视频在线91| 亚洲成人av免费| 亚洲欧美一区二区在线观看| 精品国免费一区二区三区| 欧美日韩一区三区四区| 不卡的av在线| 国产精品 日产精品 欧美精品| 亚洲成a人片综合在线| 国产精品夫妻自拍| 久久美女艺术照精彩视频福利播放 | 欧美天堂亚洲电影院在线播放| 成人的网站免费观看| 粉嫩嫩av羞羞动漫久久久| 另类小说一区二区三区| 亚洲精品国产视频| 国产精品久久国产精麻豆99网站| 精品国产一区二区三区忘忧草| 欧美亚洲动漫精品| 色激情天天射综合网| eeuss鲁一区二区三区| 国产成人精品在线看| 国模大尺度一区二区三区| 久久99国产精品免费| 日韩精品欧美成人高清一区二区| 午夜精品一区二区三区免费视频| 亚洲午夜精品在线| 日产精品久久久久久久性色| 亚州成人在线电影| 亚洲在线中文字幕| 免费观看30秒视频久久| 国产99久久久久| 成人手机在线视频| www.在线成人| 波多野结衣在线一区| 欧美中文字幕一区二区三区亚洲| 在线视频亚洲一区| 日韩视频123| 欧美国产欧美综合| 一区二区三区四区国产精品| 日日摸夜夜添夜夜添亚洲女人| 免费精品视频在线| 国产麻豆精品95视频| 暴力调教一区二区三区| 欧美视频你懂的| 久久亚洲综合色一区二区三区| 中文字幕一区二区三区在线观看| 婷婷一区二区三区| 国产精品白丝jk白祙喷水网站| 色综合久久久久网| 91精品国产综合久久国产大片| 国产视频一区二区在线| 午夜精品福利一区二区蜜股av| 国产91精品一区二区| 欧美一区二区三区四区视频| 国产精品国模大尺度视频| 秋霞影院一区二区| 色天使色偷偷av一区二区| 精品久久免费看| 免费在线一区观看| 91在线观看免费视频| 欧美大白屁股肥臀xxxxxx| 国产精品免费av| 国产在线精品一区二区夜色| 欧美精品亚洲二区| 亚洲永久精品大片| 成人激情小说乱人伦| 精品国产第一区二区三区观看体验| 一区二区三区在线视频免费 | 北条麻妃国产九九精品视频| 26uuu欧美| 六月丁香婷婷色狠狠久久| 555夜色666亚洲国产免| 午夜精品福利一区二区三区av| 欧美中文一区二区三区| 亚洲手机成人高清视频| 99视频有精品| 亚洲欧洲日韩综合一区二区| 成人午夜视频免费看| 欧美激情综合在线| 99久久99久久精品免费观看| 日本一区二区高清| 成人免费不卡视频| 亚洲欧洲精品天堂一级| 91色九色蝌蚪| 香港成人在线视频| 日韩免费性生活视频播放| 久久99国产精品尤物| 国产三级欧美三级日产三级99| 成人午夜视频福利| 一区二区三区 在线观看视频| 在线不卡免费欧美| 精品一区二区免费在线观看| 国产亚洲一区二区在线观看| 国产成人在线免费| 亚洲色图一区二区三区| 中文字幕亚洲视频| 欧美日韩二区三区| 国产一区二区h| 亚洲精品成人天堂一二三| 91精品免费观看| 成人美女视频在线观看18| 亚洲午夜久久久久久久久久久| 日韩亚洲欧美综合| gogo大胆日本视频一区| 美女视频一区二区| 亚洲九九爱视频| 日韩美女主播在线视频一区二区三区| 国内精品免费**视频| 亚洲综合色在线| 久久人人爽爽爽人久久久| 色婷婷久久一区二区三区麻豆| 精品一区二区三区影院在线午夜| 亚洲丝袜精品丝袜在线| 国产三级精品三级在线专区| 日韩一区二区三区观看| 在线看国产一区二区| 国产成人精品网址| 极品少妇一区二区三区精品视频| 一区二区在线看| 自拍偷拍国产精品| 久久久久国产精品人| 精品国内二区三区| 精品国产伦一区二区三区免费 | 一区二区中文字幕在线| 精品国产伦一区二区三区观看方式| 欧美日韩免费不卡视频一区二区三区| 99麻豆久久久国产精品免费| 成人av午夜影院|