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

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

?? os_sem.c

?? ucCos移植到廣州友善nano2410
?? 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:
*

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本中文字幕不卡| 欧美高清一级片在线观看| 色偷偷88欧美精品久久久| 国产成人免费网站| 成人精品鲁一区一区二区| 国产成人精品1024| 91在线你懂得| 91精品欧美久久久久久动漫| 在线观看91精品国产麻豆| 欧美大片国产精品| 国产精品天天摸av网| 亚洲精品国产精品乱码不99| 亚洲一线二线三线久久久| 美女网站视频久久| 97久久精品人人爽人人爽蜜臀| 在线亚洲精品福利网址导航| 欧美日韩国产一级二级| 国产亚洲1区2区3区| 一区二区成人在线视频| 国产激情一区二区三区| 欧美日韩免费观看一区三区| 中文字幕乱码久久午夜不卡 | 国内精品伊人久久久久影院对白| 国产久卡久卡久卡久卡视频精品| 欧美亚洲综合色| 国产精品国产三级国产有无不卡 | 亚洲不卡在线观看| 99视频精品免费视频| 日韩精品资源二区在线| 日本不卡一二三| 欧美天堂亚洲电影院在线播放| 欧美不卡在线视频| 免费人成精品欧美精品| 91精品国产欧美一区二区18 | 成人看片黄a免费看在线| 精品久久久久久久久久久院品网 | 7777精品伊人久久久大香线蕉 | 国产成人综合亚洲91猫咪| 日韩欧美一级在线播放| 91小视频免费看| 99综合电影在线视频| 在线观看日韩高清av| 亚洲综合一区在线| 欧美三级日韩三级| 国产一区二区三区蝌蚪| 久久久99久久| 91麻豆精东视频| 日韩高清一区在线| 亚洲国产精品国自产拍av| 91麻豆国产精品久久| 日欧美一区二区| 欧美精品一区二区三区蜜臀| 成人国产精品免费观看动漫| 亚洲美腿欧美偷拍| 精品国精品自拍自在线| 99久久综合狠狠综合久久| 日本不卡一二三区黄网| 国产精品色呦呦| 亚洲精品一区二区三区蜜桃下载 | 99这里都是精品| 看电影不卡的网站| 亚洲一区二区三区免费视频| 日本一区二区三区久久久久久久久不| 色综合视频一区二区三区高清| 精品一区二区三区在线播放视频 | 日韩在线观看一区二区| 蜜桃精品视频在线| 亚洲精品欧美专区| 国产人久久人人人人爽| 日韩美女视频19| 久久爱www久久做| 一区二区三区四区中文字幕| 精品99久久久久久| 日韩欧美在线影院| 9191成人精品久久| 日韩片之四级片| 欧美一区二区三区色| 欧美一级在线免费| www久久精品| 国产精品国产三级国产| 日韩美女啊v在线免费观看| 国产精品高潮呻吟久久| 久久久久久久久久久99999| 欧美午夜片在线观看| 欧美一级精品在线| 欧美激情一区二区三区全黄| 欧美激情一区二区三区不卡 | 成人丝袜18视频在线观看| 成人免费视频一区二区| 亚洲国产精品成人综合| 一区二区免费在线| 一区二区三区四区不卡视频| 欧洲另类一二三四区| 色哟哟国产精品| 色成年激情久久综合| 色94色欧美sute亚洲线路一久| 久久日韩精品一区二区五区| 色噜噜狠狠色综合欧洲selulu| 欧美日韩一区不卡| 国产精品另类一区| 亚洲成av人片一区二区| 国产中文一区二区三区| 欧美三级日韩在线| 国产精品色眯眯| 国产精品亚洲一区二区三区在线 | 亚洲日本丝袜连裤袜办公室| 日韩欧美一区在线观看| 国产精品亲子伦对白| 日本在线不卡视频| 日本高清不卡一区| 最新不卡av在线| 色综合久久久久| 一区二区三区四区亚洲| 色婷婷久久99综合精品jk白丝| 国产精品久久久久aaaa樱花| 国产91精品露脸国语对白| 久久久久久久av麻豆果冻| 国产成人精品免费看| 亚洲免费观看视频| 91福利区一区二区三区| 亚洲一区二区三区爽爽爽爽爽| 色婷婷综合久久久中文一区二区| 一区二区三区免费网站| 欧美三区在线观看| 免费黄网站欧美| 国产欧美一区二区精品仙草咪| 成人av午夜影院| 丝袜美腿亚洲色图| 精品久久久久久亚洲综合网 | 一区二区三区**美女毛片| 欧美日本在线播放| 成人av第一页| 国产乱码精品一区二区三区五月婷| 久久婷婷国产综合国色天香| 99久久婷婷国产综合精品| 首页欧美精品中文字幕| 国产精品嫩草影院com| 欧美一区二区在线免费观看| 成人午夜免费视频| 精品一区二区三区久久| 亚洲一区二区综合| 国产精品久久久久久妇女6080| 色呦呦国产精品| 成人福利视频在线| 国产一区 二区| 精品一区二区三区免费视频| 一片黄亚洲嫩模| 亚洲色图欧美在线| 亚洲国产一区二区视频| 国产精品短视频| 国产精品欧美一区喷水| 国产精品国产自产拍高清av王其| 久久亚洲二区三区| 国产精品国产三级国产有无不卡| 国产精品午夜免费| 一区二区三区四区五区视频在线观看| 国产精品嫩草99a| 亚洲欧洲av在线| 午夜私人影院久久久久| 免费看日韩a级影片| 成人高清视频在线| 在线免费观看日本欧美| 91精品综合久久久久久| 久久精品欧美日韩| 亚洲综合免费观看高清完整版 | 国产69精品久久777的优势| 国产v日产∨综合v精品视频| 国产91露脸合集magnet| 一本久久综合亚洲鲁鲁五月天| 欧美高清激情brazzers| 国产丝袜美腿一区二区三区| 亚洲午夜成aⅴ人片| 国产成人在线看| 日韩一级成人av| 亚洲免费观看高清完整版在线观看| 亚洲一区二区偷拍精品| 国产一区中文字幕| 91国偷自产一区二区开放时间| 日韩欧美激情四射| 日韩精品免费视频人成| 欧洲精品视频在线观看| 国产精品私人影院| 国产一区二区三区在线观看免费| 日本电影亚洲天堂一区| 国产精品乱人伦一区二区| 久久99精品久久久久久国产越南| 色呦呦日韩精品| 亚洲成a人v欧美综合天堂| 91色porny在线视频| 国产精品动漫网站| 色综合天天狠狠| 天天影视色香欲综合网老头| 91丨九色porny丨蝌蚪| 亚洲一二三区视频在线观看| 色哟哟国产精品免费观看| 亚洲伊人色欲综合网| 在线不卡一区二区| 美女视频黄 久久| 国产亚洲美州欧州综合国| 顶级嫩模精品视频在线看|