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

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

?? os_sem.c

?? 嵌入式實(shí)時(shí)操作系統(tǒng)uCOS-II源碼
?? 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一区二区三区免费野_久草精品视频
亚洲精品中文在线观看| 在线视频一区二区三区| 99久久99久久免费精品蜜臀| 欧美日韩亚洲综合一区二区三区 | 男男成人高潮片免费网站| 成人性色生活片| 日韩欧美综合在线| 亚洲国产wwwccc36天堂| av激情成人网| 欧美电视剧免费全集观看| 亚洲综合激情另类小说区| 国产精品888| 精品欧美一区二区三区精品久久| 亚洲欧美色图小说| 成人午夜电影网站| 国产亚洲欧美色| 久久se精品一区二区| 欧美色综合影院| 亚洲麻豆国产自偷在线| 欧美电视剧免费全集观看| 一区二区不卡在线视频 午夜欧美不卡在| 经典三级视频一区| 精品少妇一区二区| 麻豆国产91在线播放| 日韩视频一区二区三区| 日韩成人免费在线| 欧美日韩一区二区在线观看 | 不卡一区在线观看| 久久精品在线免费观看| 韩日精品视频一区| 精品99999| 国产精品综合网| 国产色综合久久| 成人免费高清在线| 国产精品毛片高清在线完整版| 国产suv精品一区二区883| 久久久美女毛片| 国产精品18久久久久久久久久久久| www国产成人| 国产精品一二一区| 中文字幕av在线一区二区三区| 粉嫩av一区二区三区粉嫩| 国产精品毛片高清在线完整版| 国产福利精品导航| 亚洲欧洲性图库| 欧美日韩免费观看一区二区三区 | 欧美三级欧美一级| 舔着乳尖日韩一区| 精品欧美黑人一区二区三区| 欧美视频完全免费看| 日本成人在线看| 久久综合九色综合97婷婷女人 | 蜜桃视频在线一区| 2021国产精品久久精品 | 蜜臀精品一区二区三区在线观看| 91精品国产麻豆国产自产在线 | 天堂蜜桃91精品| 精品国产成人系列| 成人动漫在线一区| 日本不卡一区二区三区| 久久久三级国产网站| 91久久精品网| 久久69国产一区二区蜜臀| 国产精品美女久久久久久| 欧美日韩精品一区二区| 久久se精品一区二区| 亚洲欧美国产毛片在线| 欧美一级xxx| 99vv1com这只有精品| 日韩电影在线观看电影| 国产精品色噜噜| 777精品伊人久久久久大香线蕉| 国产九九视频一区二区三区| 亚洲激情一二三区| 国产午夜精品一区二区三区四区| 91影院在线观看| 激情欧美日韩一区二区| 亚洲综合免费观看高清完整版在线| 欧美va天堂va视频va在线| 色哟哟国产精品| 国产乱码精品一区二区三区五月婷 | 国产精品视频一二三区| 欧美日本在线播放| 不卡av电影在线播放| 日本va欧美va瓶| 一区二区理论电影在线观看| 久久久www免费人成精品| 在线不卡欧美精品一区二区三区| 成人涩涩免费视频| 国产综合成人久久大片91| 午夜精品久久久久| 伊人色综合久久天天| 欧美精彩视频一区二区三区| 日韩欧美久久一区| 欧美日韩国产小视频| 91麻豆国产香蕉久久精品| 国产高清无密码一区二区三区| 奇米一区二区三区| 午夜日韩在线观看| 亚洲大型综合色站| 一区二区不卡在线播放 | 亚洲乱码中文字幕| 中文字幕va一区二区三区| 久久夜色精品一区| 日韩欧美卡一卡二| 日韩精品中文字幕在线一区| 在线播放日韩导航| 欧洲一区二区三区在线| 色婷婷av一区| 欧美性大战xxxxx久久久| 色94色欧美sute亚洲线路一久| 99视频精品在线| 99re这里只有精品首页| av电影在线观看不卡| 成人av电影在线播放| www.久久久久久久久| 成人精品视频网站| 99九九99九九九视频精品| 97久久超碰国产精品| 一本色道久久综合狠狠躁的推荐 | 国产一区二区三区精品欧美日韩一区二区三区| 亚洲成人激情综合网| 亚洲午夜视频在线| 午夜精品福利在线| 日韩av网站在线观看| 久久99精品国产麻豆婷婷洗澡| 欧美日韩视频不卡| 91精品国产综合久久精品性色| 91精品欧美久久久久久动漫| 日韩免费福利电影在线观看| 精品国产乱码久久久久久闺蜜| 久久精品一区蜜桃臀影院| 国产精品毛片a∨一区二区三区| 综合在线观看色| 亚洲电影一级片| 国内精品久久久久影院一蜜桃| 国产69精品久久99不卡| 日本福利一区二区| 制服丝袜在线91| 国产日产欧美一区二区视频| 国产精品免费久久久久| 一区二区三区免费| 久久精品国产一区二区三区免费看| 国产美女精品人人做人人爽 | 国产乱淫av一区二区三区| 成人app下载| 欧美日韩亚洲国产综合| 日韩精品中文字幕一区二区三区 | 亚洲一区二区三区四区五区黄| 日韩高清国产一区在线| 国产伦精品一区二区三区免费 | 亚洲国产精品一区二区www| 精品一区二区三区在线观看国产 | 欧美美女一区二区三区| 国产亚洲美州欧州综合国| 一区二区三区久久久| 激情五月播播久久久精品| 在线观看精品一区| 欧美mv日韩mv国产| 亚洲成av人片一区二区梦乃| 成人中文字幕电影| 日韩视频一区二区三区在线播放| 亚洲欧洲av在线| 国产在线一区二区综合免费视频| 91麻豆精东视频| 欧美国产欧美综合| 奇米一区二区三区| 久久久av毛片精品| 日韩精品一二区| 99久久精品国产毛片| 精品免费99久久| 天堂久久一区二区三区| 91麻豆免费观看| 中文字幕高清不卡| 精品无人区卡一卡二卡三乱码免费卡| 一本大道久久a久久精品综合| 久久久久久久综合| 蜜乳av一区二区| 欧美日韩激情一区二区三区| 日韩理论片网站| 成人午夜伦理影院| 国产无人区一区二区三区| 热久久久久久久| 在线不卡欧美精品一区二区三区| 亚洲精品国产a久久久久久| 不卡的av网站| 中文字幕在线观看不卡视频| 国产老肥熟一区二区三区| 精品国产欧美一区二区| 日韩 欧美一区二区三区| 欧美视频三区在线播放| 亚洲综合一区二区精品导航| 色综合色狠狠综合色| 亚洲欧美成人一区二区三区| 99精品视频在线播放观看| 国产精品另类一区| 97精品国产露脸对白| 亚洲欧洲性图库| 在线免费观看日本欧美| 亚洲一区二区三区不卡国产欧美|