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

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

?? 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:
*

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产不卡高清在线观看视频| 91在线国产福利| 欧美男同性恋视频网站| 亚洲综合在线视频| 欧美视频精品在线| 日韩av一级电影| 精品乱码亚洲一区二区不卡| 狠狠色综合日日| 国产欧美日韩另类一区| 91丨porny丨最新| 亚洲免费看黄网站| 日本一区二区三区免费乱视频| 亚洲精品午夜久久久| 国产精品免费av| 午夜精品福利在线| 美国欧美日韩国产在线播放| 久久精品国产色蜜蜜麻豆| 国产精品亚洲第一区在线暖暖韩国| 精品一区二区免费在线观看| 色综合久久中文综合久久97 | 一区二区三区在线观看欧美| 欧美色区777第一页| 老汉av免费一区二区三区| 中文字幕精品一区二区三区精品| 91在线精品一区二区三区| 天天影视色香欲综合网老头| 精品国产乱码久久久久久久| 成年人国产精品| 肉肉av福利一精品导航| 久久精品水蜜桃av综合天堂| 色琪琪一区二区三区亚洲区| 日本成人在线网站| 国产精品二三区| 欧美一区二区三区在线看| 岛国精品在线播放| 日本午夜精品一区二区三区电影| 久久久精品免费免费| 欧美日韩精品系列| 丁香啪啪综合成人亚洲小说| 天堂一区二区在线| 国产精品福利电影一区二区三区四区 | 盗摄精品av一区二区三区| 图片区小说区国产精品视频| 国产亚洲欧美在线| 91精品国产综合久久香蕉麻豆 | 亚洲三级在线播放| 精品卡一卡二卡三卡四在线| 在线中文字幕不卡| 高清在线观看日韩| 久久精品国产亚洲5555| 亚洲精品国产一区二区三区四区在线 | 97久久精品人人澡人人爽| 一区二区三区小说| 日韩美一区二区三区| 日韩av中文字幕一区二区| 欧美日韩午夜精品| 日韩精品每日更新| 欧美一级片免费看| 国产成人综合在线播放| 精品国产免费久久| 色综合天天综合狠狠| 91久久人澡人人添人人爽欧美| 国产欧美久久久精品影院| 日韩欧美视频一区| 欧美区视频在线观看| 色国产精品一区在线观看| 丁香婷婷综合色啪| 国产一区二区免费视频| 奇米777欧美一区二区| 一区二区三区91| 国产精品成人一区二区三区夜夜夜| 欧美成人在线直播| 欧美一区午夜视频在线观看| 欧美色图免费看| 欧美三区免费完整视频在线观看| 一本色道a无线码一区v| 99在线精品视频| 99re视频精品| 97精品超碰一区二区三区| 成人午夜激情片| 成人sese在线| 成人免费观看视频| 99vv1com这只有精品| 一本色道久久综合亚洲91| 色呦呦网站一区| 在线精品视频免费播放| 欧美伊人久久久久久久久影院 | 久久91精品国产91久久小草| 视频精品一区二区| 免费欧美日韩国产三级电影| 久久99热99| 国产成人日日夜夜| 不卡一二三区首页| 色综合久久99| 欧美一区二区精品久久911| 91精品国产手机| 2021久久国产精品不只是精品| 91在线视频免费91| 色综合激情五月| 日本一区二区三级电影在线观看 | 91天堂素人约啪| 国产永久精品大片wwwapp| 日本中文字幕一区二区视频| 亚洲高清视频的网址| 中文字幕一区二区不卡 | 国产精品三级av| 欧美性猛交xxxxxxxx| 欧美一区二区在线免费播放| 精品少妇一区二区三区在线视频| 久久久久高清精品| 亚洲欧美视频在线观看视频| 亚洲国产综合色| 极品少妇一区二区三区精品视频 | 亚洲妇女屁股眼交7| 精品制服美女丁香| 97久久精品人人做人人爽50路| 欧美日韩在线三级| 国产三级一区二区三区| 亚洲国产日韩精品| 国产毛片精品视频| 在线亚洲一区观看| 亚洲精品在线三区| 一区二区三区久久| 国产麻豆成人精品| 欧美午夜宅男影院| 国产色一区二区| 日本系列欧美系列| 色综合久久综合中文综合网| 精品国产乱码久久久久久闺蜜 | 日本一区二区三区国色天香| 午夜精品免费在线| av电影在线观看完整版一区二区| 91精品国产高清一区二区三区蜜臀| 欧美极品另类videosde| 日韩高清不卡在线| 色悠悠久久综合| 国产视频亚洲色图| 麻豆成人av在线| 欧美午夜精品理论片a级按摩| 国产无一区二区| 麻豆精品一区二区综合av| 欧美在线三级电影| 国产精品嫩草99a| 国内精品免费**视频| 欧美综合天天夜夜久久| 中文字幕中文字幕在线一区| 91精品国产高清一区二区三区蜜臀| 亚洲女人小视频在线观看| 欧美日韩精品高清| 国内精品嫩模私拍在线| 3atv一区二区三区| 久久精品国产秦先生| 欧美一区二区三区四区视频| 一个色在线综合| 91免费视频观看| 亚洲在线观看免费| 欧美日韩国产小视频| 艳妇臀荡乳欲伦亚洲一区| 欧美一区二区三区在| 色综合久久九月婷婷色综合| 欧美四级电影网| 亚洲精品乱码久久久久久久久 | 欧美一区二区成人6969| 亚洲午夜免费福利视频| 亚洲国产精品成人久久综合一区| jvid福利写真一区二区三区| 一区二区久久久久久| 久久影院视频免费| 成人高清免费观看| 又紧又大又爽精品一区二区| 亚洲色图欧美激情| av亚洲产国偷v产偷v自拍| 欧美精品一区二区在线播放| 日韩高清在线一区| 丁香激情综合国产| 国产资源精品在线观看| 蜜桃视频一区二区| 久久久av毛片精品| 欧美久久一区二区| 色综合视频在线观看| 久久精品在这里| 亚洲chinese男男1069| 免费成人深夜小野草| 亚洲最大的成人av| 亚洲一区二区影院| 亚洲欧美日韩在线不卡| 国产亚洲欧美一级| 2023国产精品视频| 成人av在线网站| 国产成人亚洲精品青草天美| 国产成人综合网| 久久精品免费观看| 蜜臀av一区二区三区| 成人免费黄色在线| 欧美在线|欧美| 国产精品白丝jk白祙喷水网站| 欧美性感一类影片在线播放| 欧美久久一二三四区| 欧美大片日本大片免费观看| 亚洲码国产岛国毛片在线|