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

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

?? os_sem.c

?? Micrium-uCOS-II 2.86版
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                              (c) Copyright 1992-2007, Micrium, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.86
*
* LICENSING TERMS:
* ---------------
*   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.  
* If you plan on using  uC/OS-II  in a commercial product you need to contact Micri祄 to properly license 
* its use in your product. We provide ALL the source code for your convenience and to help you experience 
* uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  paying a 
* licensing fee.
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include <ucos_ii.h>
#endif

#if OS_SEM_EN > 0
/*$PAGE*/
/*
*********************************************************************************************************
*                                           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 block (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.
*
*              perr          is a pointer to an error code that can contain one of the following values:
*                            OS_ERR_NONE             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 *perr)
{
    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 (perr == (INT8U *)0) {                              /* Validate 'perr'                          */
        return (pevent);
    }
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *perr = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *perr = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *perr = 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();
                 *perr                  = OS_ERR_NONE;
                 pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *perr                  = 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, OS_STAT_PEND_OK);
             }
#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  */
             }
             *perr                  = OS_ERR_NONE;
             pevent_return          = (OS_EVENT *)0;       /* Semaphore has been deleted               */
             break;

        default:
             OS_EXIT_CRITICAL();
             *perr                  = 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
*                            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).
*
*              perr          is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*
*                            OS_ERR_NONE         The call was successful and your task owns the resource
*                                                or, the event you are waiting for occurred.
*                            OS_ERR_TIMEOUT      The semaphore was not received within the specified
*                                                'timeout'.
*                            OS_ERR_PEND_ABORT   The wait on the semaphore was aborted.
*                            OS_ERR_EVENT_TYPE   If you didn't pass a pointer to a semaphore.
*                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
*                                                would lead to a suspension.
*                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer.
*                            OS_ERR_PEND_LOCKED  If you called this function when the scheduler is locked
*
* Returns    : none
*********************************************************************************************************
*/
/*$PAGE*/
void  OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *perr)
{
#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 (perr == (INT8U *)0) {                         /* Validate 'perr'                               */
        return;
    }
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        *perr = OS_ERR_PEVENT_NULL;
        return;
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        *perr = OS_ERR_EVENT_TYPE;
        return;
    }
    if (OSIntNesting > 0) {                           /* See if called from ISR ...                    */
        *perr = OS_ERR_PEND_ISR;                      /* ... can't PEND from an ISR                    */
        return;
    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美亚洲一区二区在线| 国产福利一区在线| 色综合久久久久久久久久久| 国产精品网站一区| 91在线视频观看| 一区二区三区中文在线| 欧美日韩一卡二卡| 久久电影网电视剧免费观看| 久久综合久色欧美综合狠狠| 成人av网站在线| 亚洲精品国产无天堂网2021| 91精品国模一区二区三区| 韩国中文字幕2020精品| 中文字幕 久热精品 视频在线| av在线综合网| 午夜在线电影亚洲一区| 精品少妇一区二区三区视频免付费 | 亚洲国产精品高清| 91久久人澡人人添人人爽欧美| 天天综合天天做天天综合| 日韩精品一区二区三区视频| yourporn久久国产精品| 亚洲成人综合在线| 久久影院视频免费| 欧美在线视频不卡| 国产精品资源在线看| 亚洲柠檬福利资源导航| 日韩女优毛片在线| 91欧美激情一区二区三区成人| 怡红院av一区二区三区| 精品对白一区国产伦| 91丝袜美腿高跟国产极品老师| 性欧美大战久久久久久久久| 国产日韩欧美一区二区三区乱码 | 欧美日韩免费电影| 国产一区二区三区综合| 亚洲欧美区自拍先锋| 欧美一区二区三区啪啪| 色综合久久综合网欧美综合网| 极品少妇一区二区| 亚洲图片欧美综合| 国产精品久久久久久久久晋中 | 欧美日韩成人综合在线一区二区| 国产精品一区不卡| 日本va欧美va精品发布| 樱花影视一区二区| 国产精品久久久久毛片软件| 日韩一级免费观看| 欧美美女激情18p| 色婷婷综合五月| k8久久久一区二区三区| 国产美女精品一区二区三区| 日韩中文字幕亚洲一区二区va在线| 国产精品麻豆视频| 26uuu色噜噜精品一区| 欧美老肥妇做.爰bbww| 92精品国产成人观看免费| 国产成人高清视频| 狠狠色综合日日| 捆绑紧缚一区二区三区视频| 亚洲成人一二三| 亚洲综合色区另类av| 亚洲精品一二三四区| 国产精品青草综合久久久久99| 亚洲精品在线观看网站| 精品国产免费一区二区三区四区| 欧美久久久久中文字幕| 538prom精品视频线放| 欧美私模裸体表演在线观看| 在线视频国内一区二区| 91一区二区在线观看| 99在线精品观看| 不卡电影免费在线播放一区| 成人性生交大合| 成人国产亚洲欧美成人综合网| 成人午夜在线视频| 丰满放荡岳乱妇91ww| gogogo免费视频观看亚洲一| 成人国产精品视频| 色偷偷88欧美精品久久久| 色婷婷综合激情| 欧美日韩精品欧美日韩精品| 欧美日韩电影在线播放| 日韩午夜在线观看| 精品国产三级电影在线观看| 国产色产综合产在线视频| 国产亚洲一区二区在线观看| 国产精品伦理一区二区| 怡红院av一区二区三区| 天堂午夜影视日韩欧美一区二区| 日韩经典中文字幕一区| 另类小说欧美激情| 国产成人精品亚洲日本在线桃色| 成人h精品动漫一区二区三区| 色婷婷一区二区三区四区| 欧美日韩国产综合一区二区三区| 日韩欧美久久久| 中文字幕成人网| 亚洲一区中文日韩| 九九久久精品视频| 成人午夜电影久久影院| 欧美性猛片xxxx免费看久爱| 欧美成人精品3d动漫h| 国产午夜精品理论片a级大结局| 18欧美亚洲精品| 日韩高清欧美激情| 成人黄色电影在线| 69久久99精品久久久久婷婷| 久久人人超碰精品| 亚洲人成在线观看一区二区| 日韩电影在线观看一区| 国产成人精品aa毛片| 欧美色倩网站大全免费| 久久久久国产精品厨房| 亚洲图片欧美综合| 国产成人免费视频网站| 欧美日韩中字一区| 欧美激情中文不卡| 香蕉成人啪国产精品视频综合网| 国产呦萝稀缺另类资源| 欧美亚男人的天堂| 国产亚洲精品超碰| 婷婷国产v国产偷v亚洲高清| 成人午夜碰碰视频| 欧美日产国产精品| 中文字幕在线观看一区| 日韩精品三区四区| 91亚洲精品久久久蜜桃| 日韩视频在线一区二区| 亚洲乱码国产乱码精品精小说| 激情国产一区二区| 欧美喷水一区二区| 亚洲女同ⅹxx女同tv| 国产一区二区三区免费播放| 在线这里只有精品| 中文字幕欧美一| 国产成人99久久亚洲综合精品| 91精品国产色综合久久不卡电影 | 岛国一区二区在线观看| 51久久夜色精品国产麻豆| 亚洲免费观看高清完整版在线观看熊 | 97se狠狠狠综合亚洲狠狠| 精品国产乱码久久久久久久| 午夜国产精品一区| 一本大道久久a久久精品综合| 久久久久久免费网| 精品在线你懂的| 欧美一区二区福利视频| 一区二区三区欧美| 91亚洲精品久久久蜜桃网站 | 在线一区二区三区做爰视频网站| 久久久久亚洲蜜桃| 精品无人码麻豆乱码1区2区| 欧美日韩国产天堂| 亚洲不卡av一区二区三区| 91视频免费观看| 中文字幕av免费专区久久| 精品亚洲免费视频| 日韩免费一区二区| 老司机精品视频在线| 日韩精品一区在线| 六月丁香婷婷色狠狠久久| 91精品国产91久久久久久最新毛片| 午夜一区二区三区视频| 欧美色电影在线| 日本在线不卡视频一二三区| 欧美日本在线视频| 麻豆成人91精品二区三区| 日韩天堂在线观看| 狠狠色综合日日| 久久综合色综合88| 国产成a人无v码亚洲福利| 中文字幕欧美激情一区| av一本久道久久综合久久鬼色| 国产精品美女久久久久久2018| 99国内精品久久| 一级日本不卡的影视| 欧美久久免费观看| 久久精品国产成人一区二区三区 | 久久品道一品道久久精品| 国产一区二区三区在线观看免费视频 | 日韩电影免费在线看| 日韩午夜小视频| 国产精品 欧美精品| 国产精品成人免费在线| 日本电影亚洲天堂一区| 亚洲成人动漫在线免费观看| 欧美一级久久久久久久大片| 久久99精品国产麻豆婷婷| 亚洲国产精品精华液2区45| 色综合天天综合在线视频| 婷婷国产在线综合| 久久久影院官网| 91美女在线观看| 日日夜夜精品视频免费 | 国产精品丝袜一区| 在线看国产日韩| 老司机精品视频线观看86| 亚洲国产精品传媒在线观看| 在线免费观看日本一区|