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

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

?? os_sem.c

?? ucosii在9200上的移植ADS版本.rar
?? 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一区二区三区免费野_久草精品视频
日韩电影在线观看网站| 99国产麻豆精品| 国产91精品露脸国语对白| 色婷婷激情综合| 久久人人爽爽爽人久久久| 一区二区三区国产精华| 国产一区二区三区视频在线播放| 91麻豆国产自产在线观看| 欧美精品一区二区三区四区 | 国产福利一区在线观看| 在线观看91视频| 欧美激情在线一区二区三区| 日韩电影在线一区二区| 99精品国产91久久久久久| 日韩女优视频免费观看| 一区二区三区在线看| 丰满亚洲少妇av| 久久这里只有精品视频网| 亚洲观看高清完整版在线观看| 成人高清视频在线| 久久精品亚洲麻豆av一区二区| 日本欧美一区二区三区乱码 | 国产福利一区在线观看| 欧美一区二区三区视频免费播放| 亚洲综合成人在线视频| 91蜜桃视频在线| 亚洲婷婷在线视频| av一区二区久久| 亚洲国产精品t66y| 国产成人在线视频免费播放| 精品乱码亚洲一区二区不卡| 日韩专区欧美专区| 欧美猛男男办公室激情| 亚洲综合色婷婷| 欧美色成人综合| 婷婷久久综合九色综合伊人色| 日本韩国精品在线| 亚洲激情网站免费观看| 91久久免费观看| 亚洲成人手机在线| 4hu四虎永久在线影院成人| 亚洲成av人影院在线观看网| 欧美日韩综合不卡| 丝袜亚洲精品中文字幕一区| 制服丝袜在线91| 国产一区二区中文字幕| 国产婷婷色一区二区三区| 国产不卡免费视频| 国产精品国产三级国产aⅴ原创 | 黑人巨大精品欧美一区| 337p粉嫩大胆噜噜噜噜噜91av| 国产在线精品国自产拍免费| 久久久精品国产免大香伊| 成人av免费观看| 一级日本不卡的影视| 久久久九九九九| 国产99久久精品| 亚洲人妖av一区二区| 在线亚洲免费视频| 蜜臀av亚洲一区中文字幕| 欧美成人免费网站| 福利一区二区在线| 亚洲精选一二三| 欧美久久久久久久久久| 韩国午夜理伦三级不卡影院| 亚洲国产成人在线| 欧美专区亚洲专区| 精品一区二区影视| 亚洲欧美偷拍另类a∨色屁股| 欧美日韩一二区| 国产一区二区三区电影在线观看| 中文字幕制服丝袜一区二区三区 | 欧美精品一卡两卡| 国产精品夜夜爽| 一个色综合av| 2024国产精品| 欧美在线不卡视频| 国产成人午夜精品影院观看视频 | 色94色欧美sute亚洲13| 免费在线观看精品| 国产精品久久久99| 欧美一区二区三区性视频| 懂色av一区二区三区蜜臀| 亚洲一区二区欧美激情| 久久久综合视频| 欧美日本一道本在线视频| 国产剧情一区在线| 午夜精品久久久久久久| 国产精品久久久久久久久果冻传媒| 欧美伊人久久久久久久久影院| 国产精品资源在线| 日韩精品欧美精品| 亚洲精品美腿丝袜| 国产欧美日韩卡一| 日韩欧美一区二区三区在线| 色综合天天综合网国产成人综合天 | 精东粉嫩av免费一区二区三区| 亚洲少妇屁股交4| 久久综合色综合88| 欧美电影一区二区三区| 91免费在线视频观看| 国v精品久久久网| 精品一区二区三区免费观看| 午夜欧美电影在线观看| 国产精品一区二区91| 亚洲mv大片欧洲mv大片精品| 国产精品福利一区二区三区| 久久久99免费| www日韩大片| 精品理论电影在线| 欧美一二三区精品| 欧美日韩国产乱码电影| 色婷婷久久久久swag精品| 国产高清不卡一区二区| 国产精品伊人色| 精品制服美女久久| 九九九精品视频| 热久久国产精品| 蜜臀va亚洲va欧美va天堂| 三级一区在线视频先锋| 午夜一区二区三区在线观看| 一区二区成人在线观看| 一区二区在线观看av| 自拍偷拍国产亚洲| 亚洲精品国产精华液| 亚洲一区二区三区四区五区中文| 亚洲欧美韩国综合色| 一区二区日韩av| 午夜视频一区二区| 美日韩一级片在线观看| 久久国产三级精品| 国产高清精品在线| 91色在线porny| 在线亚洲高清视频| 欧美一区在线视频| 久久久久久久久久电影| 国产精品国产三级国产三级人妇 | 一区二区三区自拍| 婷婷国产v国产偷v亚洲高清| 日本美女一区二区| 国产精品一区二区不卡| bt欧美亚洲午夜电影天堂| 色94色欧美sute亚洲13| 亚洲柠檬福利资源导航| 亚洲综合久久久| 日韩国产高清影视| 国产成人丝袜美腿| 色嗨嗨av一区二区三区| 欧美一区二区在线播放| 久久久影院官网| 一区二区三区欧美视频| 日本aⅴ亚洲精品中文乱码| 国产精品自拍一区| 色狠狠av一区二区三区| 日韩视频免费观看高清完整版| 国产亚洲制服色| 亚洲激情av在线| 蜜臀av性久久久久蜜臀aⅴ四虎| 精品一区二区国语对白| 99视频超级精品| 91精品国产综合久久久久久| 国产香蕉久久精品综合网| 亚洲精品一二三| 国产一区二三区| 91成人在线免费观看| 2023国产精品视频| 一区二区三区四区不卡在线| 捆绑调教一区二区三区| 91在线视频观看| 精品三级在线看| 洋洋av久久久久久久一区| 国产盗摄精品一区二区三区在线| 欧美性大战久久| 中文字幕一区二区三区av| 天堂va蜜桃一区二区三区漫画版| 大美女一区二区三区| 日韩一级大片在线观看| 一区二区三区丝袜| 成人免费的视频| 精品国内二区三区| 亚洲国产欧美日韩另类综合| 成人美女视频在线观看| 欧美mv日韩mv国产网站app| 亚洲国产一区视频| 99久久夜色精品国产网站| 精品欧美一区二区久久| 天天影视涩香欲综合网| 91女神在线视频| 中文av一区二区| 精品一区二区免费看| 欧美日韩的一区二区| 亚洲男人天堂av网| av电影一区二区| 欧美经典一区二区| 国产在线国偷精品产拍免费yy| 欧美在线视频日韩| 亚洲免费av网站| 欧美精品一区二区三| 蜜桃视频在线观看一区二区| 欧美日韩中字一区|