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

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

?? os_sem.c

?? 大家快來下載。這是目前最新管方版本了,Micrium-uCOS-II-V284.zip
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2007, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.84
*
* 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 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_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 *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_ERR_NONE;
                 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, 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  */
             }
             *err                   = OS_ERR_NONE;
             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
*                            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:
*
*                            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
*********************************************************************************************************
*/

void  OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
{
    INT8U      pend_stat;
#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;
    }
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        *err = OS_ERR_PEVENT_NULL;
        return;
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        *err = OS_ERR_EVENT_TYPE;
        return;
    }
    if (OSIntNesting > 0) {                           /* See if called from ISR ...                    */
        *err = OS_ERR_PEND_ISR;                       /* ... can't PEND from an ISR                    */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲午夜日本在线观看| 五月激情六月综合| 91麻豆精品国产自产在线观看一区 | 国产亚洲精品资源在线26u| 91论坛在线播放| 激情六月婷婷久久| 婷婷综合五月天| 中文字幕一区二区三区精华液| 欧美美女视频在线观看| av不卡在线观看| 久久99精品一区二区三区三区| 一区二区三区在线视频观看58| 久久色视频免费观看| 91国偷自产一区二区使用方法| 国产在线不卡一区| 五月天亚洲婷婷| 亚洲欧美日韩在线| 欧美激情一区二区三区不卡| 欧美一区二区精美| 欧美日韩视频在线观看一区二区三区 | 欧美中文字幕一区| 国产福利精品导航| 久久精品国产精品亚洲精品| 亚洲午夜电影网| 亚洲日本在线视频观看| 精品裸体舞一区二区三区| 欧美色偷偷大香| 日本高清不卡一区| 91麻豆自制传媒国产之光| 国产成人自拍网| 国产一区高清在线| 精品一区二区影视| 美国三级日本三级久久99| 婷婷中文字幕一区三区| 亚洲一区二区精品视频| 一区二区三区国产豹纹内裤在线| 国产精品久久久久久久午夜片 | 国产女主播视频一区二区| 精品久久久久久无| 精品成人在线观看| 精品粉嫩aⅴ一区二区三区四区| 91精品国产一区二区三区香蕉| 欧美日韩一级大片网址| 欧美日韩综合在线免费观看| 欧美中文字幕久久| 欧美日韩国产成人在线91| 欧美日韩一卡二卡三卡| 欧美日韩三级在线| 日韩欧美一区二区久久婷婷| 欧美一区二区三区不卡| 精品人伦一区二区色婷婷| 精品久久久久久亚洲综合网| 久久日韩精品一区二区五区| 欧美精品一区二区精品网| 久久久精品一品道一区| 国产精品人人做人人爽人人添| 国产精品国产三级国产aⅴ无密码| 国产精品白丝jk白祙喷水网站 | 国产精品99久久久久久似苏梦涵| 国产精品白丝jk白祙喷水网站| 国产精品99精品久久免费| 成人妖精视频yjsp地址| av不卡在线播放| 欧美网站一区二区| 日韩欧美在线不卡| 欧美激情中文字幕| 亚洲综合图片区| 日本vs亚洲vs韩国一区三区二区 | 久久综合色8888| 国产精品国产成人国产三级| 亚洲一区在线观看视频| 免费欧美在线视频| 高潮精品一区videoshd| 欧美性极品少妇| 日韩午夜激情av| 国产精品女上位| 亚洲国产va精品久久久不卡综合| 老司机精品视频在线| 国产成人精品免费视频网站| 色综合久久久久网| 日韩美女天天操| 亚洲欧洲制服丝袜| 捆绑变态av一区二区三区| 成人黄色在线看| 7777精品伊人久久久大香线蕉 | 国产成人精品亚洲日本在线桃色| 色狠狠色噜噜噜综合网| 日韩欧美国产不卡| 亚洲免费观看高清完整版在线| 婷婷国产v国产偷v亚洲高清| 国产99久久久久| 欧美日韩大陆在线| 国产精品免费视频网站| 日韩精品三区四区| 91亚洲精品久久久蜜桃| 日韩精品一区二| 亚洲一区二区三区小说| 国产一区二区三区av电影| 欧美亚洲日本国产| 国产精品久久久久久久第一福利 | 欧美大片日本大片免费观看| 亚洲视频一区二区在线| 久久69国产一区二区蜜臀| 欧洲色大大久久| 国产精品麻豆久久久| 精品一区二区久久| 欧美欧美欧美欧美| 亚洲精品久久久蜜桃| 粉嫩av一区二区三区在线播放| 欧美一卡2卡三卡4卡5免费| 亚洲欧美日韩在线播放| 福利视频网站一区二区三区| 日韩三级在线免费观看| 亚洲成人免费视| 色婷婷一区二区| 中文字幕制服丝袜一区二区三区 | 亚洲永久免费视频| 91丨九色丨蝌蚪丨老版| 国产女人aaa级久久久级 | 亚洲乱码国产乱码精品精98午夜| 国产精品小仙女| 精品国产免费人成电影在线观看四季 | 亚洲高清免费一级二级三级| 不卡大黄网站免费看| 久久精品欧美日韩| 激情综合色丁香一区二区| 欧美男男青年gay1069videost| 亚洲免费观看在线观看| 99这里只有精品| 国产精品国产自产拍高清av王其| 国产乱国产乱300精品| 精品欧美一区二区三区精品久久| 日韩精品亚洲一区| 欧美一区二区久久| 久久国产婷婷国产香蕉| 日韩欧美区一区二| 久久成人久久爱| 精品国产91亚洲一区二区三区婷婷 | 不卡视频在线看| 国产精品色噜噜| 不卡一卡二卡三乱码免费网站| 欧美经典三级视频一区二区三区| 国产成人在线影院| 国产精品国产三级国产有无不卡| 成人中文字幕在线| 亚洲欧美中日韩| 在线一区二区三区四区| 亚洲大片一区二区三区| 欧美电影影音先锋| 久久不见久久见免费视频7 | 久久嫩草精品久久久精品| 国产一区二区女| 国产精品国产三级国产aⅴ原创| av高清久久久| 亚洲国产视频一区二区| 欧美高清激情brazzers| 免费高清在线一区| 久久精品日产第一区二区三区高清版 | 亚洲天天做日日做天天谢日日欢| 91老师国产黑色丝袜在线| 亚洲一区二区黄色| 日韩一区二区三区免费看| 国产乱人伦偷精品视频不卡| 中文字幕一区二区三区在线不卡| 色吧成人激情小说| 蜜臀av性久久久久av蜜臀妖精| 久久五月婷婷丁香社区| 91小视频在线| 日本不卡一区二区| 国产蜜臀97一区二区三区| 日本高清成人免费播放| 蜜臀久久99精品久久久久宅男| 国产亚洲精品免费| 在线观看欧美日本| 黄色精品一二区| 亚洲久本草在线中文字幕| 欧美一区二区三区在线观看 | 中文子幕无线码一区tr| 91福利社在线观看| 国产自产v一区二区三区c| 亚洲四区在线观看| 日韩视频免费直播| 一本到一区二区三区| 麻豆精品久久精品色综合| 国产精品国产三级国产a| 欧美福利电影网| 国产**成人网毛片九色 | 舔着乳尖日韩一区| 国产欧美一区二区精品婷婷| 在线精品视频免费观看| 久久国产福利国产秒拍| 亚洲欧美色图小说| 久久久精品tv| 欧美福利视频一区| 一本一道久久a久久精品综合蜜臀| 麻豆成人91精品二区三区| 樱花影视一区二区| 国产精品无圣光一区二区| 日韩欧美成人午夜| 欧美午夜精品久久久久久孕妇|