亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
精品一二三四区| 欧美日韩在线观看一区二区 | 91国产福利在线| 精品国产一二三| 亚洲地区一二三色| 成人国产精品视频| 日韩免费性生活视频播放| 亚洲欧美一区二区久久| 国产一区二区三区四区在线观看| 欧洲视频一区二区| 国产精品国产三级国产aⅴ原创| 日本强好片久久久久久aaa| 色婷婷av久久久久久久| 国产精品久久久久久妇女6080| 久久福利视频一区二区| 欧美伊人精品成人久久综合97| 国产精品视频麻豆| 国产福利一区在线| 久久婷婷久久一区二区三区| 日日骚欧美日韩| 欧美日韩午夜在线| 亚洲免费av观看| 91玉足脚交白嫩脚丫在线播放| 国产三级欧美三级| 国产乱国产乱300精品| 日韩欧美激情四射| 麻豆91小视频| 久久人人爽爽爽人久久久| 蜜桃av一区二区| 2021久久国产精品不只是精品| 久久国产精品无码网站| 欧美哺乳videos| 国产美女娇喘av呻吟久久| 久久在线免费观看| 国产精品中文字幕日韩精品| 久久嫩草精品久久久精品| 黄色小说综合网站| 国产亚洲精品bt天堂精选| 国产成人精品1024| 国产精品久久久久久久久图文区| 成人亚洲精品久久久久软件| 国产欧美精品一区二区三区四区 | 欧美大尺度电影在线| 三级影片在线观看欧美日韩一区二区| 欧美亚洲综合在线| 日韩高清电影一区| 精品久久免费看| 国产一区在线观看视频| 国产亚洲一区二区在线观看| 成人精品免费看| 亚洲色图在线播放| 欧美乱妇23p| 久久99日本精品| 国产欧美日韩另类视频免费观看| av电影一区二区| 亚洲第一av色| 国产香蕉久久精品综合网| 色综合久久综合网欧美综合网| 亚洲福利一区二区| 久久久美女艺术照精彩视频福利播放| 不卡的av在线| 图片区小说区国产精品视频| 26uuu久久天堂性欧美| 99精品视频在线播放观看| 亚洲va欧美va人人爽| 精品理论电影在线观看| 91丨九色porny丨蝌蚪| 五月婷婷综合在线| 欧美国产激情二区三区| 欧美在线一二三| 国产成人鲁色资源国产91色综| 亚洲精品高清在线| 精品sm在线观看| 欧美性感一区二区三区| 国产自产高清不卡| 亚洲高清在线精品| 国产精品卡一卡二卡三| 日韩免费观看2025年上映的电影| 99re在线精品| 国产成人自拍在线| 日韩av电影免费观看高清完整版在线观看| 国产亚洲精品久| 日韩女优电影在线观看| 91福利精品视频| 成人黄色免费短视频| 日本伊人色综合网| 亚洲一卡二卡三卡四卡无卡久久| 亚洲精品在线网站| 欧美日韩国产中文| 91一区二区在线| 国产乱码精品一区二区三| 日韩精品一二三区| 亚洲一区av在线| 亚洲精品免费视频| 亚洲国产精品av| 久久在线观看免费| 欧美一区二区高清| 在线一区二区三区做爰视频网站| 国产精品99久久久久久久vr | 宅男噜噜噜66一区二区66| 99精品久久只有精品| 国产精品123区| 九九国产精品视频| 日本女优在线视频一区二区| 一区二区三区中文字幕在线观看| 国产精品嫩草影院av蜜臀| 国产亚洲精品7777| 久久久久久久综合日本| 日韩欧美一级在线播放| 91精品欧美综合在线观看最新| 欧美在线999| 在线一区二区视频| 欧洲国产伦久久久久久久| 色天天综合久久久久综合片| 色综合咪咪久久| 色婷婷久久99综合精品jk白丝| 成人aa视频在线观看| 成人美女在线视频| 不卡的看片网站| 91美女视频网站| 欧美在线一区二区| 欧美电影影音先锋| 日韩亚洲欧美成人一区| 精品日韩在线观看| 久久久久国产精品人| 久久精品视频网| 中文天堂在线一区| 亚洲精品久久久蜜桃| 亚洲综合精品久久| 三级一区在线视频先锋| 玖玖九九国产精品| 懂色中文一区二区在线播放| www.欧美日韩| 欧美日韩亚洲综合在线 | 欧美国产日本视频| 136国产福利精品导航| 亚洲精品免费视频| 日韩va亚洲va欧美va久久| 精品在线播放免费| 成人激情动漫在线观看| 99久久精品情趣| 精品视频一区二区三区免费| 日韩一区二区三区电影| 国产三级一区二区三区| 成人欧美一区二区三区黑人麻豆| 亚洲乱码国产乱码精品精可以看 | 国产高清在线观看免费不卡| 国产白丝网站精品污在线入口| 色综合天天综合给合国产| 制服丝袜亚洲网站| 中文字幕在线观看一区| 日本成人在线一区| 成人av第一页| 日韩一区二区在线观看| 亚洲色图.com| 精品亚洲国内自在自线福利| 99久久精品久久久久久清纯| 欧美人体做爰大胆视频| 国产精品色眯眯| 麻豆一区二区三| 色哟哟国产精品免费观看| 精品国产成人在线影院 | 中文字幕不卡的av| 五月天丁香久久| 99久久久精品| 国产午夜一区二区三区| 日韩成人午夜电影| 在线观看国产日韩| 中文字幕免费一区| 激情五月婷婷综合| 欧美日韩在线播放一区| 欧美高清在线精品一区| 美女免费视频一区二区| 欧美视频在线一区二区三区| 日本一区二区视频在线观看| 全国精品久久少妇| 欧美日韩久久一区| 亚洲靠逼com| caoporm超碰国产精品| 久久久不卡影院| 国内外精品视频| 欧美一级久久久久久久大片| 夜夜亚洲天天久久| 色综合色狠狠综合色| 中文字幕欧美日韩一区| 国产毛片精品视频| 精品国产一区二区亚洲人成毛片| 亚洲成av人综合在线观看| 一本大道综合伊人精品热热 | caoporn国产一区二区| 久久久噜噜噜久噜久久综合| 美腿丝袜亚洲色图| 777xxx欧美| 婷婷丁香激情综合| 欧美麻豆精品久久久久久| 亚洲国产cao| 欧美一区二区啪啪| 日av在线不卡| 精品久久久久久综合日本欧美| 天使萌一区二区三区免费观看|