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

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

?? os_sem.c

?? keil mdk 3.22下移植的uCOS II 2.83
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2006, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.83
*********************************************************************************************************
*/

#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 = OS_TRUE;                           /* Yes                                      */
    } else {
        tasks_waiting = OS_FALSE;                          /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
             if (tasks_waiting == OS_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 == OS_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.
*
*              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆成人久久精品二区三区红| 国产精品少妇自拍| 91精品综合久久久久久| 国产婷婷色一区二区三区 | 成人的网站免费观看| 一本久久精品一区二区 | 欧美性猛交xxxxxxxx| 国产女人18水真多18精品一级做| 午夜私人影院久久久久| 国产91精品入口| 6080日韩午夜伦伦午夜伦| 综合中文字幕亚洲| 国产xxx精品视频大全| 成人高清在线视频| 99re视频这里只有精品| 26uuu国产一区二区三区| 亚洲18影院在线观看| 色狠狠一区二区| 亚洲午夜久久久久久久久电影院 | 国产精品一区二区果冻传媒| 日韩一区二区三区四区五区六区| 一区二区三区四区在线播放| av在线播放一区二区三区| 久久久亚洲精品一区二区三区| 日韩av网站在线观看| 欧美日本一区二区三区四区| 亚洲最新视频在线观看| 91麻豆精品视频| 欧美激情一区不卡| 99久久亚洲一区二区三区青草| 国产丝袜欧美中文另类| 成人精品高清在线| 国产精品免费av| 成人深夜福利app| 国产欧美中文在线| k8久久久一区二区三区| 国产精品麻豆一区二区 | 亚洲精品国产一区二区精华液 | 国产专区综合网| 久久蜜桃av一区精品变态类天堂| 精品一区二区精品| 久久综合五月天婷婷伊人| 国产一区二区中文字幕| 欧美激情综合网| 一本到不卡免费一区二区| 亚洲国产欧美日韩另类综合| 91麻豆精品国产无毒不卡在线观看| 偷窥少妇高潮呻吟av久久免费| 日韩一区二区视频在线观看| 久久97超碰国产精品超碰| 日本一区二区三区高清不卡| 99麻豆久久久国产精品免费| 亚洲欧美日韩中文播放| 欧美人与性动xxxx| 国产一区91精品张津瑜| 亚洲免费在线电影| 日韩西西人体444www| 成人小视频在线| 亚洲国产精品麻豆| 精品少妇一区二区三区在线播放| 国产suv精品一区二区三区| 亚洲欧美偷拍卡通变态| 日韩精品中文字幕在线不卡尤物| 国产91精品在线观看| 亚洲一区二区三区四区在线| 日韩精品一区二区三区老鸭窝| 成人av免费在线| 日韩精品一级中文字幕精品视频免费观看 | 成人免费毛片a| 欧美日韩久久一区| 久久99精品国产.久久久久久| 国产欧美日韩视频一区二区 | 亚洲精品一区二区三区香蕉| 不卡的看片网站| 日韩高清国产一区在线| 国产精品水嫩水嫩| 欧美精品一二三区| 成人av电影免费观看| 天天综合天天综合色| 国产精品区一区二区三区| 欧美美女黄视频| 99精品视频在线免费观看| 另类欧美日韩国产在线| 亚洲无人区一区| 中文字幕欧美日韩一区| 欧美变态凌虐bdsm| 欧美视频在线播放| 成人av网站免费观看| 国产一区二区三区电影在线观看| 亚洲一二三四在线观看| 中文字幕欧美一| www国产精品av| 欧美剧情电影在线观看完整版免费励志电影| 国产一区二区不卡老阿姨| 欧美aaaaaa午夜精品| 亚洲国产美国国产综合一区二区| 亚洲欧洲成人精品av97| 国产欧美一区视频| 欧美精品一区二区三区蜜桃| 欧美精品自拍偷拍动漫精品| 91麻豆国产精品久久| 成人免费视频网站在线观看| 国产乱码一区二区三区| 久久99精品国产.久久久久久| 免费黄网站欧美| 男女性色大片免费观看一区二区| 亚洲一区av在线| 亚洲电影第三页| 亚洲国产视频直播| 亚洲国产日韩在线一区模特| 亚洲国产一区二区在线播放| 亚洲午夜久久久久| 亚洲chinese男男1069| 亚洲高清免费视频| 天堂影院一区二区| 日本aⅴ亚洲精品中文乱码| 日本女优在线视频一区二区 | 欧美肥妇bbw| 666欧美在线视频| 欧美一区二区三区日韩视频| 在线播放亚洲一区| 欧美一区二区三区播放老司机| 欧美一区二区三区公司| 精品美女一区二区三区| 精品99一区二区三区| 国产欧美视频一区二区| 国产精品五月天| 亚洲男同性恋视频| 亚洲大尺度视频在线观看| 日本不卡一区二区三区| 国模套图日韩精品一区二区| 成人午夜在线视频| 欧美天堂一区二区三区| 日韩一级高清毛片| 国产精品毛片高清在线完整版| 一区二区三区影院| 蜜桃av一区二区| www.亚洲人| 欧美猛男超大videosgay| 精品国产乱子伦一区| 国产精品久久久久久久久免费樱桃| 成人免费一区二区三区视频 | 亚洲美女电影在线| 日韩精品乱码免费| 国产在线精品免费| 色哟哟国产精品| 欧美一区二区三区视频| 国产精品国产馆在线真实露脸| 亚洲午夜精品久久久久久久久| 精品一二三四区| 色呦呦网站一区| 久久综合色综合88| 亚洲欧美日韩国产手机在线| 久久精品国产第一区二区三区| 99这里都是精品| 欧美一级片在线看| 自拍视频在线观看一区二区| 免费精品视频在线| 91小视频在线免费看| 日韩三级精品电影久久久| 亚洲丝袜另类动漫二区| 极品美女销魂一区二区三区免费| 91美女片黄在线观看91美女| 久久久久久久久久久久久女国产乱 | 日韩综合小视频| 成人一区二区三区| 日韩亚洲欧美成人一区| 一区二区三区在线高清| 成人免费看片app下载| 日韩美一区二区三区| 亚洲国产乱码最新视频| 不卡一二三区首页| 久久丝袜美腿综合| 日韩电影在线免费看| 色婷婷久久久综合中文字幕 | 久久综合久久鬼色中文字| 一区二区三区在线视频播放| 国产精品白丝av| 日韩欧美中文一区| 五月婷婷另类国产| 91成人在线观看喷潮| 综合久久综合久久| 不卡的看片网站| 国产亚洲成av人在线观看导航| 日本sm残虐另类| 欧美福利电影网| 亚洲国产欧美在线| 欧洲精品在线观看| 亚洲综合丝袜美腿| 色婷婷亚洲综合| 一区二区三区久久| 在线观看日韩毛片| 亚洲精品美国一| 日本道在线观看一区二区| 日韩一区欧美小说| caoporn国产一区二区| 中文字幕亚洲在| 99久久精品国产一区二区三区 | 久久蜜桃香蕉精品一区二区三区| 久久精品国产亚洲一区二区三区|