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

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

?? os_sem.c

?? uCOS-II 2.83 帶監控任務OS-VIEW
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2006, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.83
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "..\arm\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)
{
    INT16U     cnt;
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0;
#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 = 0;
#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;
    OS_EVENT  *pevent_return;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (err == (INT8U *)0) {                               /* Validate 'err'                           */
        return (pevent);
    }
    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);
    }
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0) {                         /* See if any tasks waiting on semaphore    */
        tasks_waiting = OS_TRUE;                           /* Yes                                      */
    } else {
        tasks_waiting = OS_FALSE;                          /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
             if (tasks_waiting == OS_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;
                 pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *err                   = OS_ERR_TASK_WAITING;
                 pevent_return          = pevent;
             }
             break;

        case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
             while (pevent->OSEventGrp != 0) {             /* 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 == OS_TRUE) {               /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *err                   = OS_NO_ERR;
             pevent_return          = (OS_EVENT *)0;       /* Semaphore has been deleted               */
             break;

        default:
             OS_EXIT_CRITICAL();
             *err                   = OS_ERR_INVALID_OPT;
             pevent_return          = pevent;
             break;
    }
    return (pevent_return);
}
#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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品粉嫩aⅴ一区二区三区四区| 国产毛片精品国产一区二区三区| 国产精品久久久久久一区二区三区| 欧美精品vⅰdeose4hd| 欧美精品在欧美一区二区少妇 | 日韩一级片在线播放| 欧美一区二区三区日韩视频| 69p69国产精品| 日韩欧美国产一区二区在线播放| 欧美v国产在线一区二区三区| 日韩三级av在线播放| 亚洲精品一区二区三区蜜桃下载| 久久丝袜美腿综合| 一区二区中文视频| 亚洲国产视频网站| 丝袜美腿亚洲综合| 久久精品国产久精国产爱| 国产精品亚洲成人| 色菇凉天天综合网| 在线播放91灌醉迷j高跟美女 | 亚洲精品一区二区三区蜜桃下载| 欧美极品aⅴ影院| 欧美韩日一区二区三区四区| 国产精品久久久久久久久久久免费看 | 精品一区二区三区的国产在线播放| 欧美久久久久久久久久| 51精品视频一区二区三区| 2021久久国产精品不只是精品| 国产亚洲欧美日韩俺去了| 亚洲美女偷拍久久| 九色|91porny| 久久成人18免费观看| 亚洲色图欧美在线| 国产精品色一区二区三区| 国产丝袜美腿一区二区三区| 亚洲蜜臀av乱码久久精品蜜桃| 一区二区三区资源| 精品一区二区三区香蕉蜜桃| 91一区二区在线| 日韩精品影音先锋| 亚洲综合色自拍一区| 久久99久国产精品黄毛片色诱| 成人激情电影免费在线观看| 欧美日韩国产精品成人| 国产精品欧美一区二区三区| 美女脱光内衣内裤视频久久影院| 99精品国产视频| 精品久久国产字幕高潮| 亚洲综合小说图片| 国产电影一区二区三区| 欧美人妇做爰xxxⅹ性高电影| 亚洲国产成人在线| 麻豆成人免费电影| 欧美三级中文字幕| 亚洲视频一二三区| 成人性视频免费网站| 精品免费国产一区二区三区四区| 亚洲一区成人在线| 一本色道久久综合亚洲精品按摩| 欧美国产日韩一二三区| 日本中文在线一区| 在线看不卡av| 亚洲视频你懂的| 99久久久精品免费观看国产蜜| 久久久一区二区三区捆绑**| 麻豆91在线观看| 91精品国产高清一区二区三区蜜臀| 一区二区三区日韩| 色综合久久久网| 亚洲女子a中天字幕| 99视频精品在线| 亚洲欧洲日产国产综合网| 成人一道本在线| 国产精品麻豆久久久| 国产一区二区三区黄视频 | 国产剧情一区二区| 久久午夜国产精品| 国产在线日韩欧美| 精品国产成人在线影院| 激情综合色播激情啊| 久久精品视频在线看| 成人午夜免费电影| 亚洲色欲色欲www| 日本高清不卡在线观看| 亚洲h在线观看| 日韩一区二区麻豆国产| 国产一区二区三区观看| 中文字幕亚洲欧美在线不卡| av中文字幕在线不卡| 亚洲裸体xxx| 欧美人妇做爰xxxⅹ性高电影| 蜜桃精品视频在线| 久久精品视频一区| 日本道色综合久久| 另类小说欧美激情| 国产精品久久久久久久久免费相片 | 欧美高清精品3d| 蜜桃在线一区二区三区| 2021久久国产精品不只是精品| 国产乱码精品一区二区三区忘忧草| 久久久久久久久久看片| www.亚洲色图.com| 日韩黄色免费网站| 国产欧美视频一区二区三区| a级高清视频欧美日韩| 日韩激情av在线| 中文字幕不卡在线观看| 欧美午夜精品一区二区三区| 久久99日本精品| 亚洲蜜臀av乱码久久精品蜜桃| 欧美高清dvd| 99久久精品国产麻豆演员表| 日韩不卡免费视频| 国产精品久久久久久亚洲伦| 91精品国产综合久久精品性色 | 亚洲在线免费播放| 精品伦理精品一区| 在线观看日韩毛片| 国产综合一区二区| 亚洲成av人片www| 国产精品国产三级国产aⅴ中文| 欧美日韩精品一二三区| 成人午夜免费视频| 狠狠色综合色综合网络| 亚洲精品国产高清久久伦理二区| 久久亚洲精品国产精品紫薇| 欧美系列日韩一区| 91视频在线观看| 国产成人激情av| 精品一区二区在线观看| 亚洲福利电影网| 亚洲人成亚洲人成在线观看图片| 精品成人在线观看| 91精品啪在线观看国产60岁| 在线免费不卡视频| 99国产精品国产精品久久| 国产一区二区在线视频| 免费观看成人鲁鲁鲁鲁鲁视频| 亚洲国产一区二区在线播放| 国产精品国产三级国产aⅴ中文| 2021久久国产精品不只是精品| 日韩三级精品电影久久久 | 欧美日本在线看| 一道本成人在线| 99久久99久久久精品齐齐| 国内外成人在线视频| 免费成人你懂的| 美女视频黄免费的久久| 人禽交欧美网站| 青青草国产精品97视觉盛宴| 视频在线在亚洲| 青青草伊人久久| 久久精品国产第一区二区三区| 青青草成人在线观看| 蜜臀精品一区二区三区在线观看| 日韩精品一卡二卡三卡四卡无卡| 日韩精品欧美精品| 麻豆freexxxx性91精品| 国产毛片精品视频| 成人深夜在线观看| 91色|porny| 欧美性xxxxx极品少妇| 欧美精品 国产精品| 日韩视频永久免费| 国产日韩一级二级三级| 欧美激情资源网| 亚洲欧美日韩一区| 日韩精品亚洲一区二区三区免费| 日韩av不卡在线观看| 精品一区精品二区高清| 成人高清免费观看| 在线免费观看一区| 日韩三级视频中文字幕| 欧美精品一区在线观看| 国产精品无圣光一区二区| 亚洲精品成a人| 麻豆精品在线播放| 成人在线视频一区二区| 欧美视频完全免费看| 精品裸体舞一区二区三区| 国产精品视频一二三| 中文字幕欧美一| 欧美aaa在线| 不卡的电视剧免费网站有什么| 在线视频一区二区免费| 2024国产精品| 一区二区三区在线免费观看 | 国产日产欧美精品一区二区三区| 日韩一区欧美一区| 日韩av一级片| 99re这里只有精品6| 精品久久久久av影院| 亚洲精品乱码久久久久| 国产一区二区精品久久91| 色婷婷综合五月| 国产日韩成人精品| 免费观看30秒视频久久| 欧美亚洲尤物久久| 国产精品乱码人人做人人爱| 裸体一区二区三区|