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

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

?? os_sem.c

?? ads下ucos在9200上的移植
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.76
*********************************************************************************************************
*/

#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;



    cpu_sr = 0;                                       /* Prevent compiler warning                      */
#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;



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



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

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

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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线看国产一区| 91在线观看污| 日韩精品自拍偷拍| 久久精品国产久精国产爱| 7777精品伊人久久久大香线蕉超级流畅 | 国产一区二区影院| 久久久九九九九| 成人国产免费视频| 依依成人综合视频| 欧美疯狂做受xxxx富婆| 麻豆精品在线视频| 国产农村妇女精品| 91小视频免费观看| 午夜视频一区二区三区| 国产精品女主播在线观看| 91在线一区二区三区| 一区二区三区久久| 欧美一级二级三级乱码| 国产一区91精品张津瑜| 亚洲欧洲另类国产综合| 欧美午夜精品免费| 久久成人羞羞网站| 中文字幕在线观看不卡| 欧美色电影在线| 韩日欧美一区二区三区| 自拍偷拍欧美精品| 日韩一区二区在线观看视频| 国产成人自拍网| 亚洲国产成人91porn| 久久先锋资源网| 欧美在线播放高清精品| 国产做a爰片久久毛片| 亚洲色大成网站www久久九九| 欧美乱妇15p| 成人福利在线看| 日本人妖一区二区| 亚洲激情在线播放| 久久久久久久久久久久久夜| 欧美日韩免费电影| 成人中文字幕在线| 日本91福利区| 一区二区不卡在线播放| 久久久亚洲午夜电影| 欧美视频完全免费看| 福利一区二区在线| 久久www免费人成看片高清| 亚洲天天做日日做天天谢日日欢| 日韩精品一区二区三区蜜臀| 色94色欧美sute亚洲13| 国产成人欧美日韩在线电影| 日韩精品亚洲一区| 一区二区三区精品在线| 国产精品久线在线观看| 久久久久一区二区三区四区| 欧美人与性动xxxx| 91老司机福利 在线| 国产91在线|亚洲| 狠狠色狠狠色合久久伊人| 日韩精品成人一区二区在线| 亚洲精品欧美激情| **欧美大码日韩| 中文字幕av一区二区三区免费看| 日韩免费看网站| 91精品国产入口| 欧美日韩在线播| 欧洲一区在线电影| 91麻豆免费视频| 91视频在线观看免费| 成人午夜激情片| 成人影视亚洲图片在线| 国产成人免费视频网站高清观看视频| 麻豆一区二区三| 麻豆精品蜜桃视频网站| 美日韩黄色大片| 美女看a上一区| 黄色精品一二区| 国产一区二区日韩精品| 麻豆国产欧美一区二区三区| jlzzjlzz亚洲女人18| 国产乱一区二区| 国产一区二区不卡老阿姨| 国产一区二区精品久久99| 国产麻豆精品在线观看| 国产乱子伦视频一区二区三区| 国产综合色产在线精品| 国产盗摄一区二区| 成人黄色一级视频| 色婷婷av久久久久久久| 欧美在线视频不卡| 精品视频一区二区三区免费| 欧美日韩在线播放一区| 欧美高清视频在线高清观看mv色露露十八 | 国产精品77777竹菊影视小说| 精品一区二区久久久| 国产在线不卡一区| 成人看片黄a免费看在线| 91亚洲国产成人精品一区二区三| 91福利在线免费观看| 欧美区在线观看| 欧美不卡视频一区| 国产精品网站导航| 亚洲一线二线三线视频| 日韩精品一级二级| 国产成人精品免费视频网站| 色悠悠亚洲一区二区| 欧美日韩精品高清| 欧美精品一区二区在线播放| 国产精品久久久久影院老司| 伊人色综合久久天天人手人婷| 午夜精品福利一区二区蜜股av| 色欧美片视频在线观看| 91.com在线观看| 国产日韩欧美麻豆| 亚洲国产欧美日韩另类综合| 久久成人免费电影| 91尤物视频在线观看| 91精品国产乱码| 国产精品久久久久一区二区三区 | 久久综合网色—综合色88| 国产精品久久影院| 日韩精品三区四区| 不卡影院免费观看| 91精品国产综合久久精品麻豆| 国产午夜精品一区二区三区嫩草| 一区二区三区欧美日韩| 国产精品乡下勾搭老头1| 欧美午夜精品电影| 欧美国产一区在线| 免费在线观看日韩欧美| 91色.com| 国产午夜精品福利| 亚洲v日本v欧美v久久精品| 丁香激情综合国产| 日韩欧美激情一区| 亚洲国产你懂的| 波多野结衣亚洲一区| 精品国产一区二区三区忘忧草 | 久久久美女艺术照精彩视频福利播放| 一区二区三区中文字幕在线观看| 极品少妇一区二区| 欧美亚洲动漫另类| 国产精品久久久久久亚洲伦 | 国产精品一区二区久久精品爱涩 | 日韩视频免费观看高清完整版在线观看 | av电影在线观看完整版一区二区| 欧美一区二区三区免费视频| 夜夜嗨av一区二区三区中文字幕| 国产精品一二三四五| 日韩女优毛片在线| 奇米777欧美一区二区| 在线一区二区三区| 综合自拍亚洲综合图不卡区| 国产成人免费视频网站| 久久综合999| 美女视频一区在线观看| 欧美精品xxxxbbbb| 亚洲国产综合在线| 欧美亚洲国产bt| 亚洲已满18点击进入久久| 色综合天天性综合| 国产精品对白交换视频 | 日本在线不卡视频| 欧美理论片在线| 亚洲成人资源在线| 欧美自拍偷拍午夜视频| 亚洲欧美成人一区二区三区| a美女胸又www黄视频久久| 欧美国产一区在线| 成人激情黄色小说| 国产精品传媒在线| 91精品国产综合久久香蕉麻豆| 亚洲国产日韩a在线播放| 欧美色图第一页| 午夜视频一区在线观看| 69堂精品视频| 毛片av一区二区三区| www久久精品| 国产高清久久久| 国产精品国产三级国产a| 99久久久无码国产精品| 中文字幕欧美一| 欧洲日韩一区二区三区| 性做久久久久久| 欧美一级生活片| 国产精一品亚洲二区在线视频| 亚洲国产精品传媒在线观看| 成人黄色电影在线| 国产视频一区二区在线观看| 视频精品一区二区| 欧美三级日本三级少妇99| 亚洲成人在线观看视频| 欧美精三区欧美精三区| 麻豆成人久久精品二区三区红| 日韩精品一区在线观看| 日韩欧美国产麻豆| 国产a精品视频| 久久嫩草精品久久久久| 91视频com| 国产凹凸在线观看一区二区| 日韩综合小视频|