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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_sem.c

?? ARM7TDMI軟件模擬器
?? 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:
*

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人777| 国产成人精品三级麻豆| 欧美日韩综合色| 亚洲综合色婷婷| 91亚洲精品久久久蜜桃| 国产精品女同一区二区三区| 高清在线不卡av| 国产三级精品视频| 成人一区二区在线观看| 国产人成一区二区三区影院| 国产精品亚洲视频| 国产精品丝袜一区| 97se亚洲国产综合自在线不卡 | 国产三级精品视频| 国产福利精品一区| 国产精品三级电影| 91丨porny丨国产入口| 亚洲免费在线电影| 91国偷自产一区二区三区成为亚洲经典 | 亚洲永久免费av| 欧美日韩在线综合| 亚洲电影一区二区三区| 欧美猛男超大videosgay| 午夜a成v人精品| 日韩女同互慰一区二区| 激情综合色综合久久| 国产午夜精品福利| 成人avav影音| 亚洲一区电影777| 欧美精品丝袜久久久中文字幕| 日本强好片久久久久久aaa| 欧美mv日韩mv| 国产91丝袜在线18| 亚洲三级小视频| 欧美日韩国产成人在线免费| 麻豆中文一区二区| 国产亚洲一本大道中文在线| av动漫一区二区| 亚洲影院理伦片| 欧美成人video| 国产精品白丝av| 亚洲免费成人av| 欧美久久久一区| 国产综合色精品一区二区三区| 中文字幕中文字幕中文字幕亚洲无线| 欧美亚洲动漫精品| 九九久久精品视频| 最新热久久免费视频| 欧美理论片在线| 国产精品综合久久| 亚洲精品成a人| 欧美成人伊人久久综合网| voyeur盗摄精品| 婷婷国产在线综合| 中文字幕成人av| 4438亚洲最大| 成人爽a毛片一区二区免费| 亚洲图片欧美视频| 国产视频一区二区在线| 欧洲精品一区二区| 国产精品91一区二区| 亚洲一区二区在线观看视频| 久久女同精品一区二区| 在线观看区一区二| 国产一区高清在线| 亚洲18女电影在线观看| 日本一区二区三区四区在线视频| 欧美中文字幕亚洲一区二区va在线 | 欧美色偷偷大香| 国产大陆亚洲精品国产| 亚洲国产美国国产综合一区二区| 国产午夜精品一区二区三区嫩草| 欧美日韩一区中文字幕| 粉嫩av一区二区三区在线播放| 天天综合色天天| 最近日韩中文字幕| 精品久久久久久久人人人人传媒| 色狠狠色噜噜噜综合网| 国产一区二区电影| 午夜精品久久久久久| 中文字幕日韩一区二区| 精品国产伦一区二区三区观看体验 | 日韩欧美一级在线播放| 色婷婷av一区二区三区软件| 国产在线精品一区二区三区不卡| 亚洲一区二区不卡免费| 国产精品久久久久四虎| 精品免费日韩av| 欧美在线|欧美| 成人免费福利片| 奇米综合一区二区三区精品视频| 亚洲三级电影全部在线观看高清| ww久久中文字幕| 日韩一区二区在线观看视频| 在线精品观看国产| 成人性生交大片免费看在线播放| 久久成人羞羞网站| 日韩黄色小视频| 91无套直看片红桃| 久久99精品国产.久久久久久| 亚洲影院在线观看| 亚洲欧美偷拍三级| 中文字幕巨乱亚洲| 久久九九影视网| 日韩三级视频在线看| 欧美日韩亚洲不卡| 色94色欧美sute亚洲13| 99久久精品一区| 成人综合日日夜夜| 国产成人精品免费| 国产精品伊人色| 精品伊人久久久久7777人| 日本午夜精品视频在线观看 | 国产精品12区| 国产尤物一区二区在线| 国内精品久久久久影院色| 日韩av成人高清| 日本午夜精品一区二区三区电影| 五月天激情小说综合| 亚洲影视在线播放| 亚洲高清免费观看| 午夜欧美大尺度福利影院在线看| 亚洲午夜久久久久久久久电影院| 亚洲影院理伦片| 亚洲成a人v欧美综合天堂 | 无码av中文一区二区三区桃花岛| 一卡二卡欧美日韩| 亚洲一区二区三区免费视频| 亚洲国产精品视频| 亚洲第一主播视频| 日日摸夜夜添夜夜添国产精品 | 欧美色视频在线观看| 欧美日韩在线一区二区| 欧美日韩mp4| 欧美一区二区在线免费播放| 成人午夜激情片| 丁香桃色午夜亚洲一区二区三区| 国产69精品久久99不卡| 风间由美一区二区av101| 成人激情电影免费在线观看| 99在线热播精品免费| 99久久精品国产精品久久| 一本大道av伊人久久综合| 色哟哟精品一区| 欧美日韩国产美| 日韩小视频在线观看专区| 精品国产一区二区三区久久影院| 久久久久久久一区| 国产精品视频免费看| 亚洲女同女同女同女同女同69| 一区二区三区不卡视频| 日韩中文字幕区一区有砖一区| 久久精品999| 国产91丝袜在线播放九色| 91蜜桃免费观看视频| 欧美性受xxxx黑人xyx| 欧美一区二区在线免费观看| 26uuu另类欧美| 国产精品国产三级国产专播品爱网| 亚洲视频在线一区观看| 亚洲午夜免费视频| 久久99国产精品成人| 国产成人在线视频网站| 91小视频在线| 欧美精品电影在线播放| 精品剧情在线观看| 国产精品久久久久久久午夜片| 亚洲国产精品一区二区www| 久久国产综合精品| av欧美精品.com| 欧美精品第1页| 国产欧美一区二区三区在线老狼| 亚洲婷婷综合色高清在线| 午夜精品久久久久久久99水蜜桃| 国精产品一区一区三区mba视频| 97超碰欧美中文字幕| 欧美一区二区三区系列电影| 国产人成一区二区三区影院| 亚洲最色的网站| 国产一区不卡视频| 91高清视频在线| 久久综合色之久久综合| 一区二区三区.www| 国产做a爰片久久毛片| 在线观看亚洲成人| 久久综合色综合88| 亚洲图片自拍偷拍| 丁香啪啪综合成人亚洲小说| 欧美精品一卡二卡| 中文字幕高清不卡| 欧美aaaaa成人免费观看视频| 成人免费高清在线| 日韩视频一区二区| 一区二区三区四区在线| 国产一区二区在线观看视频| 欧美日韩精品一区二区| 国产精品福利影院| 麻豆91小视频| 欧美系列在线观看| 国产精品免费丝袜|