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

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

?? os_sem.c

?? UCOSII在mcs12dg128上的移植
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                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 "..\Sources\UCOS2\CONFIG_UCOS\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);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
激情成人综合网| 色一情一乱一乱一91av| 欧美精品一区二区在线播放| 亚洲成人你懂的| 欧美绝品在线观看成人午夜影视| 亚洲1区2区3区4区| 一区二区三区精品视频| 91麻豆精品91久久久久同性| 国产揄拍国内精品对白| 中文字幕亚洲精品在线观看| av中文字幕不卡| 亚洲精品视频一区二区| 91精品在线一区二区| 日韩一级黄色大片| 福利电影一区二区三区| 亚洲成人自拍一区| 日韩国产在线一| 3d动漫精品啪啪| 日韩午夜在线观看| 精品盗摄一区二区三区| 中文成人综合网| 日韩一级片在线播放| 精品国产一区二区三区不卡| 国产亚洲欧洲997久久综合 | 亚洲午夜免费电影| 久久中文娱乐网| 欧美裸体一区二区三区| 精品国产乱码91久久久久久网站| 欧美www视频| 制服丝袜av成人在线看| 久久影院电视剧免费观看| 中国av一区二区三区| 亚洲图片欧美一区| 国产成人亚洲综合a∨婷婷| 日本女人一区二区三区| 国产盗摄精品一区二区三区在线 | 亚洲美女偷拍久久| 国产三级久久久| 不卡一卡二卡三乱码免费网站| 免费精品视频在线| 婷婷开心激情综合| 亚洲成人你懂的| 国产成人综合自拍| 欧美日韩在线直播| 色婷婷一区二区三区四区| 日韩午夜激情av| 一区二区在线观看视频在线观看| 日韩国产欧美在线观看| 色综合天天综合狠狠| 欧美午夜精品一区二区蜜桃| 成人性生交大片免费| 国产白丝精品91爽爽久久| 在线国产电影不卡| 精品视频1区2区| 国产精品成人在线观看| 亚洲国产经典视频| 国产精品福利电影一区二区三区四区 | 粉嫩嫩av羞羞动漫久久久| 欧美日韩高清一区二区| 欧美精品777| 激情久久久久久久久久久久久久久久| 99视频一区二区| 久久夜色精品国产噜噜av| 男人的j进女人的j一区| 欧美中文一区二区三区| 亚洲精品伦理在线| 91麻豆精品国产91久久久久| 在线观看日韩av先锋影音电影院| 欧美精品一区二区三区在线播放| 亚洲一区在线观看免费观看电影高清 | 91一区二区三区在线播放| av中文字幕亚洲| 久久精品欧美一区二区三区麻豆| 精品影院一区二区久久久| 国产精品99久久久久久宅男| 国产福利不卡视频| 久久久国产精品不卡| 亚洲欧美另类久久久精品| 国产成人超碰人人澡人人澡| 精品成人一区二区三区四区| 老司机免费视频一区二区三区| 国产麻豆9l精品三级站| 精品国产一区二区三区久久久蜜月| 午夜欧美电影在线观看| 9191成人精品久久| 免费观看30秒视频久久| 日韩欧美二区三区| 夜夜揉揉日日人人青青一国产精品| 成人美女在线观看| 成人免费视频在线观看| 在线欧美日韩精品| 亚洲国产aⅴ天堂久久| 欧美精品亚洲二区| 久久91精品久久久久久秒播| 久久伊99综合婷婷久久伊| 国产老妇另类xxxxx| 中文字幕一区在线观看视频| 色综合天天综合狠狠| 天天色 色综合| 亚洲精品一区在线观看| 不卡的av中国片| 亚洲成人综合视频| 精品对白一区国产伦| www.色精品| 日本亚洲电影天堂| 日本一二三四高清不卡| 欧美亚洲国产一卡| 精品一区二区三区免费观看| 中文字幕一区二区三中文字幕| 欧美三级电影一区| 国产a精品视频| 亚洲电影在线播放| 亚洲第一综合色| 亚洲五月六月丁香激情| 欧美老肥妇做.爰bbww视频| 激情六月婷婷久久| 一个色综合网站| 国产亚洲精品aa午夜观看| 欧美亚洲高清一区| 国产精选一区二区三区| 亚洲成a人在线观看| 国产日韩欧美高清| 欧美日本一道本| 青草av.久久免费一区| 亚洲天堂网中文字| 国产乱一区二区| 亚洲午夜影视影院在线观看| 国产免费观看久久| 欧美一区二区二区| 蜜桃精品在线观看| 精品国产乱子伦一区| 91国模大尺度私拍在线视频| 亚洲欧洲av一区二区三区久久| 欧美精品自拍偷拍| 91色视频在线| 成人激情动漫在线观看| 久久精品国产99国产精品| 亚洲高清久久久| 亚洲激情校园春色| 亚洲婷婷国产精品电影人久久| 久久麻豆一区二区| 欧美福利视频导航| 欧美久久久久久久久| 在线免费观看日本一区| 成人av第一页| 成人av资源在线观看| 成人妖精视频yjsp地址| 国产黄色91视频| 国产在线看一区| 韩国av一区二区| 国产剧情一区二区| 另类综合日韩欧美亚洲| 美腿丝袜亚洲一区| 蜜臀av性久久久久蜜臀aⅴ| 日韩成人伦理电影在线观看| 午夜免费欧美电影| 日韩不卡一区二区| 免费在线观看精品| 久久国产欧美日韩精品| 激情综合亚洲精品| 国产综合一区二区| 国产成人高清在线| 一本色道久久综合狠狠躁的推荐| 91在线视频网址| 国产专区欧美精品| 国产美女精品在线| 白白色亚洲国产精品| 色悠久久久久综合欧美99| 97国产一区二区| 欧美日韩精品欧美日韩精品一综合| 欧美吻胸吃奶大尺度电影 | 色欧美片视频在线观看| 在线视频欧美精品| 欧美一区二区三区在线| 久久欧美中文字幕| 中文字幕在线不卡一区| 亚洲国产综合视频在线观看| 日韩二区三区四区| 成人深夜视频在线观看| 在线欧美日韩精品| 日韩免费高清视频| 亚洲视频免费观看| 日韩黄色一级片| 成人视屏免费看| 88在线观看91蜜桃国自产| 久久―日本道色综合久久| 亚洲精品你懂的| 久久精品理论片| 色综合久久中文综合久久97| 56国语精品自产拍在线观看| 国产日韩亚洲欧美综合| 亚洲一区在线观看免费| 国产精品原创巨作av| 在线观看日韩av先锋影音电影院| 日韩欧美国产成人一区二区| 一区二区在线观看免费| 国产在线视频精品一区| 欧美天堂亚洲电影院在线播放| 久久九九国产精品| 五月综合激情婷婷六月色窝|