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

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

?? os_sem.c

?? UCOS-II ATMEGA128 移殖
?? 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一区二区三区免费野_久草精品视频
欧美一区二区三区视频免费| 久久女同精品一区二区| 555夜色666亚洲国产免| 欧美激情一区二区三区全黄| 丝袜美腿成人在线| caoporn国产精品| 欧美一区二区三区啪啪| 综合久久久久久久| 粉嫩蜜臀av国产精品网站| 91麻豆精品国产91久久久久| 亚洲欧美日韩国产综合| 成人看片黄a免费看在线| 欧美一级xxx| 亚洲18女电影在线观看| 99精品视频在线观看| 国产视频一区二区三区在线观看| 亚洲大片精品永久免费| 91免费在线播放| 中文字幕在线播放不卡一区| 国产自产v一区二区三区c| 日韩一级完整毛片| 视频在线在亚洲| 欧美美女一区二区三区| 亚洲一区二区视频| 欧美性猛交xxxx乱大交退制版 | 天堂蜜桃一区二区三区 | 国产欧美1区2区3区| 美国精品在线观看| 欧美一区二区三区视频| 日韩和欧美的一区| 在线播放中文字幕一区| 日日夜夜免费精品| 日韩午夜精品视频| 免费成人在线观看视频| 日韩精品资源二区在线| 久久国产尿小便嘘嘘| 精品久久久久久久久久久久久久久久久| 偷拍日韩校园综合在线| 美女网站在线免费欧美精品| 日韩av二区在线播放| 成人高清在线视频| 日韩精品一区二区三区中文精品| 国产精品美女久久久久久2018| 喷白浆一区二区| 欧美午夜理伦三级在线观看| 久久久天堂av| 蜜桃久久av一区| 色综合视频在线观看| 精品国产乱码久久久久久蜜臀| 亚洲欧洲av色图| 国产二区国产一区在线观看| 国产精品一区二区在线播放| 日韩一区二区在线观看视频 | 国产成人欧美日韩在线电影| 国产精品免费观看视频| 一本色道久久综合狠狠躁的推荐 | 色哟哟欧美精品| 亚洲成av人片一区二区梦乃| 日韩一级欧美一级| 国产福利一区二区三区视频| 中文字幕一区三区| 欧美日韩国产高清一区二区三区| 精品无人码麻豆乱码1区2区 | 日韩精品中文字幕一区二区三区 | 免费看欧美女人艹b| 久久人人爽爽爽人久久久| 91在线观看污| 免费观看在线综合| 中文字幕一区在线观看视频| 4438x亚洲最大成人网| 成人丝袜18视频在线观看| 亚洲成人av一区| 国产农村妇女毛片精品久久麻豆| 欧美亚洲动漫制服丝袜| 国产一区二区三区在线观看精品 | 一本大道综合伊人精品热热| 免费欧美在线视频| 一区二区三区中文字幕精品精品| 欧美xxxxx裸体时装秀| 91黄色激情网站| 国产不卡在线视频| 蜜臀久久99精品久久久久宅男| 国产喷白浆一区二区三区| 欧美电影在哪看比较好| 99精品视频在线播放观看| 久久精品免费观看| 亚洲最大成人综合| 中文字幕免费不卡| 精品久久久影院| 欧美日韩国产经典色站一区二区三区| 粉嫩av一区二区三区粉嫩| 免费成人av在线播放| 亚洲一区二区三区激情| 中文久久乱码一区二区| 精品久久人人做人人爽| 91麻豆精品国产91久久久资源速度 | 中文字幕一区二区三区乱码在线| 日韩一级片在线观看| 在线视频国内一区二区| heyzo一本久久综合| 国产福利一区在线| 国产一区二区在线观看视频| 青青草国产成人av片免费 | 国产欧美一区二区三区鸳鸯浴| 在线播放欧美女士性生活| 91久久精品午夜一区二区| 高清不卡在线观看| 国产精品一区二区久久精品爱涩| 久久精品国产99| 成人性生交大合| 狠狠狠色丁香婷婷综合久久五月| 免费人成精品欧美精品| 日韩影院在线观看| 日本在线不卡视频| 日本成人在线网站| 久久精品国产亚洲5555| 美脚の诱脚舐め脚责91| 精品在线观看免费| 韩国av一区二区三区在线观看| 看片的网站亚洲| 激情五月激情综合网| 黄色成人免费在线| 国产成人免费视频一区| 成人动漫一区二区在线| 成人精品gif动图一区| 99精品欧美一区二区三区综合在线| bt欧美亚洲午夜电影天堂| 91蜜桃视频在线| 91国产成人在线| 3751色影院一区二区三区| 欧美一区二区在线观看| 日韩精品一区二区在线| 欧美激情在线免费观看| 亚洲欧美日韩在线播放| 亚洲一区二区欧美日韩 | 日韩视频中午一区| 久久综合色8888| 国产精品美女久久久久av爽李琼| ㊣最新国产の精品bt伙计久久| 一级中文字幕一区二区| 日一区二区三区| 国产在线不卡一区| 99精品欧美一区二区蜜桃免费| 欧美中文字幕一区| 日韩亚洲欧美成人一区| 国产人成一区二区三区影院| 综合久久给合久久狠狠狠97色| 亚洲va天堂va国产va久| 国内精品不卡在线| 91女人视频在线观看| 欧美一级艳片视频免费观看| 国产亚洲成av人在线观看导航| 亚洲免费观看高清| 日本成人在线一区| 99久久精品国产精品久久| 欧美另类久久久品| 欧美经典一区二区| 午夜激情一区二区三区| 国产成人精品网址| 欧美日韩免费在线视频| 欧美国产日韩一二三区| 丝袜美腿亚洲综合| 99re成人精品视频| 精品人伦一区二区色婷婷| 亚洲精品视频在线观看免费| 精品一区二区在线免费观看| 欧洲色大大久久| 国产视频在线观看一区二区三区| 午夜伊人狠狠久久| jlzzjlzz国产精品久久| 精品国产青草久久久久福利| 一区二区免费在线| 成人午夜在线免费| 中文字幕日韩av资源站| 久久精品国产亚洲aⅴ| 欧美日韩一区精品| 综合自拍亚洲综合图不卡区| 韩日欧美一区二区三区| 欧美日韩国产高清一区二区| 日韩毛片在线免费观看| 国产高清久久久| 欧美tickling网站挠脚心| 天堂资源在线中文精品| 在线视频你懂得一区| 亚洲欧洲色图综合| 丁香六月综合激情| 亚洲精品一区二区三区影院| 日韩高清在线电影| 欧美三级视频在线| 亚洲已满18点击进入久久| 成人avav影音| 国产精品久久久久aaaa樱花| 国产精品456露脸| 久久人人97超碰com| 国产一区二区成人久久免费影院| 欧美一区二区三区视频在线观看| 午夜精品久久久久久久99水蜜桃| 欧美四级电影在线观看| 夜夜精品浪潮av一区二区三区| 色欧美片视频在线观看在线视频|