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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? os_sem.c

?? 此壓縮包中包含了UCOS-II的詳細(xì)源代碼
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : OS_SEM.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "includes.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)
{
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr;
#endif    
    INT16U     cnt;


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


    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                */
        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)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    BOOLEAN    tasks_waiting;


    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);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
#endif
    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) {
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
                 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    */
                 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
             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);

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人精品一区二区三区四区| 国产一区二区三区免费看| 久久精品水蜜桃av综合天堂| 91精品国产综合久久久久久 | 日韩精品中文字幕一区| 91影院在线免费观看| 国内精品伊人久久久久av一坑| 午夜国产精品一区| 亚洲一二三四区不卡| 国产精品无遮挡| 26uuu亚洲婷婷狠狠天堂| 欧美一区二区成人6969| 5566中文字幕一区二区电影| 欧美日韩一区在线| 欧美性极品少妇| 欧美最新大片在线看| a级高清视频欧美日韩| 极品美女销魂一区二区三区| 久久99精品网久久| 欧美日韩国产a| 日本高清成人免费播放| 91丨九色丨蝌蚪富婆spa| 91亚洲精品久久久蜜桃网站| 国产福利一区二区三区视频在线| 国产在线精品一区二区三区不卡| 国内国产精品久久| 国产精品 日产精品 欧美精品| 国产69精品久久久久777| 白白色亚洲国产精品| 99热国产精品| 不卡视频免费播放| 99亚偷拍自图区亚洲| 欧美性猛交xxxx乱大交退制版 | 首页国产丝袜综合| 美腿丝袜在线亚洲一区| 国产自产高清不卡| 国产夫妻精品视频| 风间由美性色一区二区三区| 91在线一区二区三区| 在线欧美一区二区| 欧美一区二区三区色| 久久精品在线免费观看| 专区另类欧美日韩| 亚洲国产日产av| 美女在线一区二区| 成人黄色在线看| 欧美午夜寂寞影院| 亚洲精品一区二区三区四区高清| 久久久99精品久久| 亚洲欧美一区二区三区孕妇| 亚洲第一电影网| 国产一区二区三区四| 91啪九色porn原创视频在线观看| 欧美日韩在线播| 国产欧美综合色| 亚洲精品日韩综合观看成人91| 亚洲一区二区三区视频在线播放| 美国十次综合导航| aaa亚洲精品| 91精品久久久久久久久99蜜臂| 精品剧情在线观看| 亚洲男人的天堂一区二区| 天天爽夜夜爽夜夜爽精品视频| 国产精品一区二区不卡| 在线观看av不卡| 精品国产sm最大网站| 欧美国产成人在线| 午夜电影网亚洲视频| 不卡的av电影在线观看| 久久综合丝袜日本网| 一区二区日韩av| 国产一区二区精品久久| 日本精品免费观看高清观看| 2017欧美狠狠色| 亚洲成av人片一区二区梦乃| 不卡的av在线播放| 欧美mv和日韩mv的网站| 亚洲一二三四区不卡| 国产一区二区不卡| 777亚洲妇女| 亚洲天堂网中文字| 国模一区二区三区白浆| 欧美无砖专区一中文字| 日韩**一区毛片| 91麻豆精品一区二区三区| 欧美精品黑人性xxxx| 亚洲欧美欧美一区二区三区| 国产一区二区三区在线观看免费视频| 欧美三片在线视频观看| 国产色产综合色产在线视频| 亚洲五月六月丁香激情| 不卡av电影在线播放| 久久―日本道色综合久久| 天堂av在线一区| 色呦呦国产精品| 国产精品久久久久久久第一福利| 亚洲成人中文在线| 色综合久久88色综合天天6 | 久久综合九色综合97_久久久| 一区二区三区国产精华| av电影一区二区| 中文字幕精品综合| 国模大尺度一区二区三区| 欧美日韩一区二区三区四区五区| 国产精品传媒在线| 成人av资源在线| 久久精品在线观看| 国产精品一区二区久激情瑜伽| 欧美一区二区不卡视频| 首页国产欧美久久| 在线一区二区三区四区五区 | 亚洲福利国产精品| 91成人免费电影| 一区二区免费在线| 欧洲亚洲精品在线| 亚洲免费观看高清完整版在线观看 | 国产精品久99| k8久久久一区二区三区 | 亚洲一区国产视频| 欧美性大战久久久久久久| 一区二区三区欧美| 欧美一级一级性生活免费录像| 国内精品伊人久久久久av一坑| 国产日韩欧美制服另类| 91丨porny丨中文| 首页国产欧美日韩丝袜| 精品国产污网站| 成人天堂资源www在线| 亚洲乱码国产乱码精品精的特点| 欧美日韩精品系列| 久久99热狠狠色一区二区| 国产午夜精品理论片a级大结局 | 欧美日韩国产小视频在线观看| 青青草国产成人av片免费| 久久久久久久久久久久久女国产乱| caoporn国产一区二区| 亚洲 欧美综合在线网络| 欧美成人高清电影在线| www.欧美日韩国产在线| 爽爽淫人综合网网站| 久久久久久久一区| 在线视频你懂得一区| 韩国女主播一区二区三区| 亚洲美女免费在线| 日韩欧美国产不卡| 一本色道久久综合狠狠躁的推荐 | 国产精选一区二区三区| 亚洲免费观看在线观看| 精品区一区二区| 色综合欧美在线视频区| 欧美日韩一区三区| 国产成人亚洲精品狼色在线| 亚洲精品国产精品乱码不99| 精品国产乱子伦一区| 91官网在线观看| 国产精品 日产精品 欧美精品| 夜夜精品视频一区二区| 精品va天堂亚洲国产| 色哟哟在线观看一区二区三区| 精油按摩中文字幕久久| 亚洲一区二区在线免费观看视频| 久久久久久久精| 欧美精品日韩精品| a4yy欧美一区二区三区| 精品亚洲aⅴ乱码一区二区三区| 有码一区二区三区| 国产欧美一区二区三区在线看蜜臀| 欧美性猛片xxxx免费看久爱| 成人av资源站| 国产真实乱子伦精品视频| 亚洲一区二区欧美日韩| 中文字幕精品一区| 日韩精品一区二区三区在线观看| 在线欧美一区二区| 成人黄色一级视频| 狠狠久久亚洲欧美| 日韩影院免费视频| 亚洲第一狼人社区| 亚洲日穴在线视频| 国产精品久久久一本精品 | 亚洲一区二区三区四区在线观看| 欧美精彩视频一区二区三区| 日韩限制级电影在线观看| 在线视频你懂得一区| 波多野结衣在线aⅴ中文字幕不卡| 美女www一区二区| 午夜电影一区二区三区| 亚洲一区二区三区精品在线| 国产精品伦理一区二区| 久久精品日韩一区二区三区| 日韩欧美中文字幕公布| 欧美日本在线一区| 色老汉av一区二区三区| 99久久伊人精品| 国产91精品一区二区麻豆网站| 国内精品伊人久久久久av一坑| 日日摸夜夜添夜夜添亚洲女人| 亚洲自拍偷拍九九九| 亚洲永久免费av| 亚洲综合色区另类av|