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

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

?? os_sem.c

?? ucos2.8 系統的源代碼 我找到的 可以使用
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2005, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.80
*********************************************************************************************************
*/

#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 = 0;
#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 = 0;
#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;
    OS_EVENT  *pevent_return;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (err == (INT8U *)0) {                               /* Validate 'err'                           */
        return (pevent);
    }
    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);
    }
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0) {                         /* 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;
                 pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *err                   = OS_ERR_TASK_WAITING;
                 pevent_return          = pevent;
             }
             break;

        case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
             while (pevent->OSEventGrp != 0) {             /* 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;
             pevent_return          = (OS_EVENT *)0;       /* Semaphore has been deleted               */
             break;

        default:
             OS_EXIT_CRITICAL();
             *err                   = OS_ERR_INVALID_OPT;
             pevent_return          = pevent;
             break;
    }
    return (pevent_return);
}
#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.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
五月天久久比比资源色| 亚洲精品第一国产综合野| 欧美精品第1页| 91久久精品一区二区二区| 成人精品小蝌蚪| 菠萝蜜视频在线观看一区| 成人高清视频免费观看| 成人中文字幕合集| aa级大片欧美| 欧洲日韩一区二区三区| 欧美性生活久久| 欧美夫妻性生活| 3d动漫精品啪啪一区二区竹菊| 欧美日韩高清在线播放| 91精品国产91久久久久久最新毛片 | www激情久久| 久久精品视频免费| 中文字幕日本不卡| 亚洲国产中文字幕在线视频综合| 天堂一区二区在线| 久久精品99国产精品| 国产精品456| 一本大道av一区二区在线播放| 91亚洲精品久久久蜜桃网站 | 亚洲一二三四区| 丝袜诱惑亚洲看片| 国产jizzjizz一区二区| 97se亚洲国产综合在线| 欧美精品 国产精品| 国产亚洲成年网址在线观看| 亚洲欧洲综合另类| 久久电影国产免费久久电影| 国产精品综合av一区二区国产馆| 97久久精品人人做人人爽| 欧美日韩国产乱码电影| 国产人成一区二区三区影院| 亚洲女与黑人做爰| 国产制服丝袜一区| 色婷婷久久久久swag精品| 日韩精品专区在线影院重磅| 中文字幕一区二区三| 天天综合天天做天天综合| 国产美女精品人人做人人爽| 色呦呦网站一区| 精品国精品自拍自在线| 亚洲精品视频在线看| 精品亚洲aⅴ乱码一区二区三区| 色综合天天综合色综合av| 日韩一区二区高清| 亚洲精品自拍动漫在线| 国产精品自拍在线| 欧美mv日韩mv国产| 亚洲成人av资源| 色吊一区二区三区| 国产精品日产欧美久久久久| 丝袜a∨在线一区二区三区不卡| 成人一区二区视频| 日韩欧美国产精品一区| 性欧美大战久久久久久久久| 成人h动漫精品一区二区| 精品国产三级a在线观看| 午夜激情一区二区三区| 91免费版pro下载短视频| 日本一区二区三区在线观看| 精品一区二区三区在线视频| 884aa四虎影成人精品一区| 亚洲精品成人精品456| av资源站一区| 亚洲欧美综合在线精品| 不卡的av电影在线观看| 国产精品久久久久久久久免费樱桃| 韩国女主播成人在线| 日韩欧美色综合网站| 麻豆精品一二三| 精品精品国产高清a毛片牛牛 | 一区二区三区四区国产精品| a亚洲天堂av| 综合久久给合久久狠狠狠97色| 丰满亚洲少妇av| 综合网在线视频| 在线观看亚洲专区| 日韩经典中文字幕一区| 欧美一区二区在线免费观看| 午夜精品久久久久| 欧美疯狂做受xxxx富婆| 天天色图综合网| 日韩欧美在线1卡| 蜜桃视频免费观看一区| 精品国产髙清在线看国产毛片| 蜜桃视频在线观看一区二区| 日韩三区在线观看| 国产黄色精品视频| 亚洲激情在线播放| 欧美性极品少妇| 香蕉成人伊视频在线观看| 欧美久久一二区| 国产精品综合一区二区| 中文字幕在线观看不卡视频| 91色乱码一区二区三区| 偷窥少妇高潮呻吟av久久免费| 555夜色666亚洲国产免| 国产福利精品一区二区| 亚洲精品视频在线| 日韩精品一区二区三区视频| 风间由美一区二区三区在线观看 | 亚洲一区日韩精品中文字幕| 91麻豆精品国产91久久久使用方法| 蜜臀91精品一区二区三区| 国产精品美女一区二区三区| 欧美制服丝袜第一页| 久久国产乱子精品免费女| 国产精品白丝在线| 51精品国自产在线| 99麻豆久久久国产精品免费优播| 亚洲综合在线视频| 2020国产精品久久精品美国| 色综合久久66| 国产成人免费视频精品含羞草妖精| 亚洲免费观看高清完整版在线| 欧美另类久久久品| 成人午夜av影视| 欧美aa在线视频| 夜夜精品浪潮av一区二区三区| 精品捆绑美女sm三区| 99久精品国产| 国产精品系列在线播放| 日韩av在线发布| 亚洲日本免费电影| 国产三级欧美三级日产三级99| 欧美日韩精品是欧美日韩精品| 国产成人精品一区二| 美女视频黄 久久| 亚洲成a人片在线不卡一二三区 | 亚洲综合激情网| 欧美国产综合一区二区| 欧美一卡2卡3卡4卡| 91福利在线免费观看| 高清不卡一区二区在线| 激情丁香综合五月| 久久国产夜色精品鲁鲁99| 午夜私人影院久久久久| 亚洲免费观看高清完整版在线观看| 国产午夜精品一区二区三区嫩草| 7777精品久久久大香线蕉| 欧美调教femdomvk| 欧洲视频一区二区| 欧美少妇性性性| 在线观看一区二区视频| 91成人在线观看喷潮| 99久精品国产| 色综合久久中文字幕综合网| 成人av在线影院| 成人午夜视频免费看| 成人av电影在线网| 成人av影视在线观看| www.视频一区| 日本韩国欧美国产| 日本韩国一区二区| 欧美老肥妇做.爰bbww视频| 欧美在线观看禁18| 精品视频999| 欧美理论电影在线| 精品国产一区二区三区不卡 | 天天综合天天做天天综合| 亚洲国产成人va在线观看天堂| 亚洲国产毛片aaaaa无费看| 亚洲大型综合色站| 蜜臀av性久久久久蜜臀aⅴ流畅| 久久精品国产网站| 国产**成人网毛片九色 | 欧洲一区二区三区在线| 欧美亚洲一区二区在线| 91精品国产色综合久久不卡蜜臀| 欧美视频一区二| 日韩精品一区二区三区在线观看 | 国产日韩精品一区| 亚洲欧洲精品一区二区三区| 亚洲午夜激情av| 蓝色福利精品导航| 成人av手机在线观看| 欧美人牲a欧美精品| 久久免费电影网| 一区二区三区在线免费播放| 奇米亚洲午夜久久精品| av亚洲精华国产精华精| 欧美久久久久久久久中文字幕| 久久影音资源网| av成人老司机| 欧美一级欧美一级在线播放| 国产欧美日韩亚州综合 | 亚洲三级在线观看| 天天色天天爱天天射综合| 国产精品一二三区在线| 欧洲一区二区三区在线| ww亚洲ww在线观看国产| 亚洲精品成a人| 国产麻豆视频精品| 717成人午夜免费福利电影| 中文字幕亚洲欧美在线不卡| 亚洲高清三级视频|