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

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

?? os_sem.c

?? uCOS-II 移植到ARM7上
?? 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一区二区三区免费野_久草精品视频
欧美一区二区三级| 欧美人妇做爰xxxⅹ性高电影| 一区二区高清视频在线观看| 精品伦理精品一区| 欧美伊人久久久久久久久影院 | 亚洲综合丁香婷婷六月香| 久久久亚洲精华液精华液精华液| 欧美亚洲图片小说| a在线欧美一区| 国产成人免费av在线| 美女高潮久久久| 午夜精品aaa| 亚洲一区二区三区精品在线| 国产精品夫妻自拍| 国产亚洲欧美一级| 精品久久久久久久久久久久久久久 | 99精品黄色片免费大全| 毛片不卡一区二区| 午夜不卡av免费| 亚洲一区二区黄色| 亚洲品质自拍视频网站| 国产精品色呦呦| 久久久蜜臀国产一区二区| 制服丝袜中文字幕一区| 欧美三级韩国三级日本三斤| 在线观看亚洲一区| 一本大道久久a久久综合婷婷| 成人高清在线视频| 成人avav影音| 成人av在线播放网址| 成+人+亚洲+综合天堂| 成人午夜免费av| 不卡电影一区二区三区| 99国产麻豆精品| 色综合天天综合网国产成人综合天 | 在线播放一区二区三区| 欧美性做爰猛烈叫床潮| 欧美天堂一区二区三区| 欧美性色aⅴ视频一区日韩精品| 99精品视频在线播放观看| a级高清视频欧美日韩| 成年人午夜久久久| 91搞黄在线观看| 国产精品一区一区三区| 国产精品一区二区久久精品爱涩| 精品一区二区日韩| 国产一区二区三区av电影| 国产毛片精品一区| 成人永久aaa| 99riav久久精品riav| 在线观看亚洲精品| 久久五月婷婷丁香社区| 久久先锋资源网| 国产精品久久久久精k8 | 亚洲成人中文在线| 免费精品视频最新在线| 国产精品一区在线观看乱码| av中文字幕一区| 欧美日韩国产片| 精品国产麻豆免费人成网站| 亚洲国产激情av| 亚洲午夜av在线| 裸体一区二区三区| www.久久久久久久久| 欧美日韩国产一二三| 久久精品亚洲麻豆av一区二区| 国产精品对白交换视频| 午夜电影网一区| 国产成人99久久亚洲综合精品| 在线免费观看不卡av| 精品黑人一区二区三区久久 | 亚洲一区二区成人在线观看| 日本va欧美va欧美va精品| 国产成人亚洲综合a∨婷婷图片| 91搞黄在线观看| www欧美成人18+| 一区二区三区中文字幕电影 | 亚洲免费观看高清完整版在线 | 欧美精品久久久久久久多人混战 | 欧美三级韩国三级日本三斤| 26uuu国产在线精品一区二区| 中文字幕在线不卡| 久久精品国产一区二区三区免费看| 不卡免费追剧大全电视剧网站| 欧美视频一区二区三区四区| 国产欧美日本一区二区三区| 首页国产欧美日韩丝袜| www.亚洲色图.com| 精品国产伦一区二区三区免费| 一区二区三区欧美日| 福利电影一区二区三区| 91精品国产综合久久福利| 亚洲欧美一区二区三区国产精品| 美脚の诱脚舐め脚责91 | 精品日产卡一卡二卡麻豆| 专区另类欧美日韩| 久久99国产精品久久| 欧美日韩亚洲综合一区二区三区| 国产欧美久久久精品影院| 麻豆一区二区三| 欧美日韩久久久一区| 亚洲欧美成人一区二区三区| 国产精品一二三| 欧美一级xxx| 日韩精品1区2区3区| 欧美在线|欧美| 国产精品免费网站在线观看| 精久久久久久久久久久| 欧美一区二区视频在线观看2022| 亚洲乱码一区二区三区在线观看| 国产成人av自拍| 精品久久久影院| 麻豆精品国产91久久久久久| 欧美军同video69gay| 亚洲6080在线| 在线观看亚洲成人| 亚洲精品高清在线观看| 成人激情免费网站| 中文字幕精品一区| 成人小视频免费观看| 亚洲国产精品黑人久久久| 国产福利精品一区| 国产视频一区二区三区在线观看| 激情综合网av| 26uuuu精品一区二区| 国产在线视频一区二区三区| 精品国产一区二区三区忘忧草| 美女网站在线免费欧美精品| 91精品国产色综合久久久蜜香臀| 日韩精品欧美成人高清一区二区| 欧美日韩一区二区在线视频| 亚洲高清视频的网址| 欧美日韩黄色影视| 欧美a一区二区| 精品久久久久久久久久久久包黑料| 久久国内精品视频| 久久婷婷色综合| 国产精品小仙女| 国产精品久久看| 91啪亚洲精品| 亚洲国产精品一区二区尤物区| 精品视频在线免费看| 亚洲成国产人片在线观看| 4438x亚洲最大成人网| 麻豆精品一区二区综合av| 2020国产精品| av一区二区久久| 亚洲成年人网站在线观看| 91精品国产91综合久久蜜臀| 久久电影网站中文字幕| 国产欧美精品一区二区色综合朱莉| 白白色 亚洲乱淫| 亚洲国产一区二区a毛片| 欧美一级淫片007| 国产二区国产一区在线观看| 亚洲图片激情小说| 久久精品欧美一区二区三区麻豆| 成人黄色国产精品网站大全在线免费观看| 国产精品国产三级国产有无不卡 | 国产91高潮流白浆在线麻豆| **性色生活片久久毛片| 在线观看91精品国产麻豆| 狠狠色2019综合网| 最近中文字幕一区二区三区| 欧美日韩卡一卡二| 国产一区二区三区不卡在线观看 | 久久久国产精品不卡| 91在线精品一区二区| 午夜久久久久久久久| 久久婷婷久久一区二区三区| 一本大道久久a久久综合婷婷| 男女男精品视频网| 中文字幕亚洲在| 欧美一区二区三区免费观看视频| 成人禁用看黄a在线| 日本美女一区二区| 亚洲图片另类小说| 日韩欧美国产电影| 91九色最新地址| 国产精品一二二区| 午夜精品影院在线观看| 国产精品美女视频| 欧美一级片免费看| 91免费版在线看| 九一九一国产精品| 亚洲自拍偷拍网站| 国产精品日韩精品欧美在线| 91精品在线一区二区| 95精品视频在线| 国产一区二区三区精品视频| 亚洲电影你懂得| 一区在线观看视频| 久久久三级国产网站| 欧美丰满高潮xxxx喷水动漫| eeuss鲁片一区二区三区在线看| 麻豆视频观看网址久久| 亚洲成人免费视| 亚洲精品乱码久久久久久黑人 | 国产午夜精品美女毛片视频| 91麻豆精品国产自产在线观看一区 |