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

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

?? os_sem.c

?? ucos2/2.90-STM32
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                              (c) Copyright 1992-2009, Micrium, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.91
*
* 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 > 0u
/*$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 > 0u
INT16U  OSSemAccept (OS_EVENT *pevent)
{
    INT16U     cnt;
#if OS_CRITICAL_METHOD == 3u                          /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#if OS_ARG_CHK_EN > 0u
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        return (0u);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0u);
    }
    OS_ENTER_CRITICAL();
    cnt = pevent->OSEventCnt;
    if (cnt > 0u) {                                   /* 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 == 3u                               /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL_IEC61508
    if (OSSafetyCriticalStartFlag == OS_TRUE) {
        OS_SAFETY_CRITICAL_EXCEPTION();
    }
#endif

    if (OSIntNesting > 0u) {                               /* 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_EN > 0u
        pevent->OSEventName    = (INT8U *)(void *)"?";
#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 > 0u
OS_EVENT  *OSSemDel (OS_EVENT  *pevent,
                     INT8U      opt,
                     INT8U     *perr)
{
    BOOLEAN    tasks_waiting;
    OS_EVENT  *pevent_return;
#if OS_CRITICAL_METHOD == 3u                               /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL
    if (perr == (INT8U *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
    }
#endif

#if OS_ARG_CHK_EN > 0u
    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 > 0u) {                               /* See if called from ISR ...               */
        *perr = OS_ERR_DEL_ISR;                            /* ... can't DELETE from an ISR             */
        return (pevent);
    }
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0u) {                        /* 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_EN > 0u
                 pevent->OSEventName    = (INT8U *)(void *)"?";
#endif
                 pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr     = OSEventFreeList; /* Return Event Control Block to free list  */
                 pevent->OSEventCnt     = 0u;
                 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 != 0u) {            /* Ready ALL tasks waiting for semaphore    */
                 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
             }
#if OS_EVENT_NAME_EN > 0u
             pevent->OSEventName    = (INT8U *)(void *)"?";
#endif
             pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr     = OSEventFreeList;     /* Return Event Control Block to free list  */
             pevent->OSEventCnt     = 0u;
             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,
                 INT32U     timeout,
                 INT8U     *perr)
{
#if OS_CRITICAL_METHOD == 3u                          /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL
    if (perr == (INT8U *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
    }
#endif

#if OS_ARG_CHK_EN > 0u
    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 > 0u) {                          /* See if called from ISR ...                    */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
不卡一区二区中文字幕| 成人少妇影院yyyy| 制服视频三区第一页精品| 亚洲国产欧美在线| 欧美综合一区二区| 亚洲专区一二三| 色94色欧美sute亚洲线路一久| 综合欧美一区二区三区| av在线不卡电影| 国产精品国产三级国产普通话蜜臀 | 精品国内片67194| 男女男精品视频| 欧美成人aa大片| 激情深爱一区二区| 久久精品无码一区二区三区| 国产麻豆精品95视频| 久久精品视频在线看| 国产 欧美在线| 国产精品区一区二区三区 | 日日夜夜免费精品| 91精品免费观看| 韩国三级在线一区| 国产视频911| 成人动漫在线一区| 亚洲欧美日韩国产手机在线| 在线免费观看一区| 日韩高清在线电影| 亚洲精品一区二区在线观看| 国产高清成人在线| 中文字幕欧美一| 欧美日韩一区二区在线观看| 日韩福利视频导航| 久久夜色精品国产欧美乱极品| 国产精品综合av一区二区国产馆| 国产精品少妇自拍| 91成人免费电影| 日韩电影在线观看电影| 欧美tickling挠脚心丨vk| 国产寡妇亲子伦一区二区| 国产精品久99| 欧美视频一区二区在线观看| 日日摸夜夜添夜夜添国产精品| 日韩美女一区二区三区| 国产激情偷乱视频一区二区三区| 亚洲欧洲综合另类| 51午夜精品国产| 国产精品一二三四五| 亚洲视频图片小说| 欧美久久一二三四区| 国产成人亚洲精品青草天美| 亚洲精品欧美激情| 欧美一级电影网站| 成人免费观看av| 亚洲五月六月丁香激情| 精品国产三级电影在线观看| 99久久国产免费看| 日本欧美韩国一区三区| 日本一区二区三区免费乱视频 | 99精品视频在线免费观看| 五月天一区二区三区| 国产午夜精品一区二区三区嫩草 | 老汉av免费一区二区三区| 国产精品久久久久久久蜜臀| 欧美日本在线看| 国产不卡在线播放| 午夜亚洲福利老司机| 国产婷婷色一区二区三区四区| 91传媒视频在线播放| 国产精品一区二区黑丝| 亚洲综合免费观看高清完整版在线| 日韩精品中文字幕一区| 色天天综合色天天久久| 精品综合免费视频观看| 亚洲激情在线播放| 久久久久国产成人精品亚洲午夜| 欧美亚洲国产怡红院影院| 国内精品视频一区二区三区八戒| 一区二区在线观看av| 久久婷婷国产综合国色天香| 欧美在线观看18| 成人黄色在线视频| 蜜桃精品视频在线| 亚洲精品美国一| 国产欧美精品一区| 91精品国产色综合久久| 91丨porny丨户外露出| 国精产品一区一区三区mba桃花 | 免费在线观看视频一区| 亚洲婷婷在线视频| 精品电影一区二区| 欧美精品三级在线观看| 91在线观看下载| 国产一区二区三区黄视频 | 日韩视频在线你懂得| 欧美性色黄大片| 成人av免费在线观看| 国产精品夜夜爽| 日本不卡的三区四区五区| 一区二区三区四区视频精品免费| 国产三级久久久| 26uuuu精品一区二区| 在线不卡中文字幕播放| 在线观看精品一区| 99久久婷婷国产| 成人一道本在线| 国产精品亚洲综合一区在线观看| 日本欧美大码aⅴ在线播放| 亚洲成人激情av| 亚洲精品乱码久久久久久黑人| 中文一区二区完整视频在线观看| 精品999在线播放| 日韩欧美另类在线| 91精品国产综合久久精品app| 欧美性大战xxxxx久久久| 97精品久久久久中文字幕| 成人午夜在线免费| 国产福利一区二区三区视频在线| 久久综合综合久久综合| 日本va欧美va精品发布| 水蜜桃久久夜色精品一区的特点| 一区二区三区久久| 亚洲一区二区精品久久av| 一区二区三区中文字幕| 亚洲欧美另类久久久精品| 亚洲欧美激情一区二区| 亚洲欧美一区二区三区孕妇| 亚洲美腿欧美偷拍| 亚洲精品视频在线看| 亚洲一区二区三区不卡国产欧美| 亚洲精品成人悠悠色影视| 亚洲裸体在线观看| 亚洲精品国久久99热| 亚洲免费观看高清完整版在线观看| 亚洲三级在线观看| 一区二区免费在线| 亚洲最新视频在线播放| 亚洲国产色一区| 婷婷久久综合九色综合绿巨人| 亚洲不卡av一区二区三区| 午夜视黄欧洲亚洲| 琪琪一区二区三区| 久88久久88久久久| 国产精选一区二区三区| 国产高清精品久久久久| www.激情成人| 色88888久久久久久影院野外 | 91一区在线观看| 欧美在线短视频| 日韩一区二区三区av| 久久这里只有精品视频网| 国产精品三级av在线播放| 亚洲女厕所小便bbb| 爽好多水快深点欧美视频| 老鸭窝一区二区久久精品| 国产成人无遮挡在线视频| 色综合亚洲欧洲| 欧美精品久久久久久久多人混战 | 日本在线不卡一区| 国产在线国偷精品产拍免费yy| 高清日韩电视剧大全免费| 99视频有精品| 欧美日韩三级一区| 欧美videofree性高清杂交| 中文字幕精品一区| 一区二区三区色| 蜜臀久久99精品久久久久宅男| 国产一二三精品| 91免费版在线看| 日韩欧美精品在线视频| 国产精品丝袜91| 午夜精品aaa| 国产精品资源在线| 色激情天天射综合网| 日韩一级黄色大片| 国产日韩高清在线| 亚洲午夜一区二区| 国产精品影视在线观看| 色综合欧美在线| 日韩精品一区二| 亚洲男女一区二区三区| 麻豆精品一区二区综合av| 成人精品视频.| 欧美精品一二三四| 亚洲国产成人午夜在线一区| 午夜电影网亚洲视频| 国产精品一级二级三级| 欧美私模裸体表演在线观看| 精品国产凹凸成av人网站| 亚洲色图另类专区| 老司机一区二区| 色88888久久久久久影院按摩| 欧美变态tickle挠乳网站| 亚洲婷婷在线视频| 韩国女主播一区| 欧美日韩一区二区三区视频| 久久久久久久综合| 香蕉加勒比综合久久| 高清国产一区二区三区| 欧美一区二区免费观在线| **性色生活片久久毛片|