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

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

?? os_sem.c

?? BK7S64開發板的uC/OS-II移植源代碼
?? 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一区二区三区免费野_久草精品视频
欧美在线观看你懂的| 欧洲精品中文字幕| 成人av免费在线观看| 93久久精品日日躁夜夜躁欧美| 99免费精品视频| 欧美日韩国产片| 久久蜜桃一区二区| 1024成人网| 日韩在线a电影| 懂色av中文字幕一区二区三区 | 色悠久久久久综合欧美99| 福利91精品一区二区三区| 国产成人午夜99999| 91香蕉国产在线观看软件| 免费成人在线观看| 99久久国产综合精品女不卡| 欧美亚洲一区二区在线| 国产亚洲美州欧州综合国| 久久国内精品自在自线400部| 欧美精品123区| 美日韩一区二区| 国产亚洲1区2区3区| 免费观看日韩电影| www.爱久久.com| 精品欧美乱码久久久久久 | 日韩一级黄色片| 亚洲精品日韩一| 国产aⅴ综合色| 日韩精品最新网址| 丝袜诱惑亚洲看片 | 日韩情涩欧美日韩视频| 精品国产免费久久| 国产一区二区三区| 国产精品免费看片| 99久久精品一区二区| 亚洲天堂精品在线观看| 欧洲国内综合视频| 蜜桃传媒麻豆第一区在线观看| 美腿丝袜在线亚洲一区| 成人av网站在线| 亚洲一区二区在线观看视频| 欧美最猛黑人xxxxx猛交| 91成人免费在线视频| 免费久久99精品国产| 日本一区二区三区在线观看| 韩国精品在线观看| 久久99精品视频| 高清不卡一区二区| 欧美日产国产精品| 亚洲成人免费视| 欧美色区777第一页| 免费精品视频在线| 成人精品国产一区二区4080| av不卡在线播放| 在线视频一区二区三| 亚洲国产视频网站| 欧美精品18+| 亚洲欧美视频一区| thepron国产精品| 亚洲欧美福利一区二区| 91麻豆精品国产91久久久资源速度| 亚洲日本中文字幕区| 国产一区二区三区高清播放| 欧美一级片在线观看| 午夜精品久久久久久| 亚洲人成伊人成综合网小说| 国内精品国产成人国产三级粉色| 欧美v国产在线一区二区三区| 91精品办公室少妇高潮对白| 免费在线成人网| 日本v片在线高清不卡在线观看| 欧美色视频一区| 亚洲色图色小说| 国产自产高清不卡| 亚洲色图在线播放| 色哟哟精品一区| 日韩精品亚洲专区| 国产精品午夜久久| 宅男噜噜噜66一区二区66| 欧美一区二区三区婷婷月色| 337p亚洲精品色噜噜噜| 国产河南妇女毛片精品久久久| 国产精品18久久久久久vr| 三级久久三级久久| 日韩中文字幕av电影| 久久精品久久精品| 五月激情综合网| 国产精品污www在线观看| 26uuu亚洲综合色| 日韩电影在线免费| 国产精品自在欧美一区| 国产精品白丝jk白祙喷水网站| 精品一区二区三区在线视频| eeuss国产一区二区三区| 色婷婷亚洲一区二区三区| 一本在线高清不卡dvd| 亚洲精品一线二线三线无人区| 欧美一区二区在线不卡| 欧美日韩日日摸| 中文字幕成人av| 欧美一级欧美三级| 92国产精品观看| 国产高清在线精品| 亚洲男同1069视频| 久久精品人人爽人人爽| 欧美日精品一区视频| 欧美精品v国产精品v日韩精品| 国产女人水真多18毛片18精品视频 | 国产69精品久久久久777| 一区二区三区免费观看| 综合久久久久综合| 日日摸夜夜添夜夜添国产精品 | 国产一区中文字幕| 中文字幕av免费专区久久| 日本韩国欧美一区| 蜜臀av性久久久久蜜臀aⅴ | 不卡大黄网站免费看| 国产精品欧美一级免费| 在线视频国内一区二区| 久久精品噜噜噜成人av农村| 国产精品电影一区二区三区| 欧美久久一二区| 成人午夜碰碰视频| 午夜精品久久久久久久| 亚洲国产精品激情在线观看 | 亚洲美女精品一区| 91精品国模一区二区三区| 国产一区二区三区免费播放 | 亚洲综合免费观看高清完整版| 欧美一区二区三区性视频| 国产乱码精品一区二区三区av| 亚洲另类色综合网站| 欧美日韩精品一区二区三区四区| 极品尤物av久久免费看| 自拍偷在线精品自拍偷无码专区| 日韩一区二区三区精品视频| 国产91在线|亚洲| 日韩激情视频网站| 国产精品久久影院| 91精品婷婷国产综合久久性色| 久久99久久99| 亚洲一区二区中文在线| 国产欧美日韩卡一| 制服丝袜亚洲播放| 色婷婷亚洲综合| 国产精品一区在线观看你懂的| 性做久久久久久免费观看欧美| 久久视频一区二区| 欧美高清激情brazzers| 国产精品一级片在线观看| 日韩电影在线一区二区三区| 亚洲色图欧洲色图婷婷| 日韩你懂的在线播放| 欧美日韩你懂得| 99久久夜色精品国产网站| 国产麻豆视频精品| 日韩国产欧美视频| 亚洲自拍偷拍av| 精品国产不卡一区二区三区| 欧美日韩一区成人| 亚洲一区二区三区美女| 韩国精品免费视频| 日韩欧美激情在线| 综合在线观看色| 国产99精品视频| 91精品视频网| 亚洲欧洲成人自拍| 精品一区二区三区久久久| 欧美自拍丝袜亚洲| 日韩一级完整毛片| 成人黄色软件下载| 欧美精品一区二区久久婷婷| 久久99精品久久只有精品| 偷拍亚洲欧洲综合| 久久婷婷国产综合国色天香| 91丨porny丨蝌蚪视频| 国产精品小仙女| 国产精品一区二区你懂的| 日韩电影在线观看一区| 日一区二区三区| 亚洲国产视频在线| 天堂成人国产精品一区| 国产亚洲女人久久久久毛片| 久久久久久麻豆| 2023国产精品视频| 成人永久免费视频| 日韩精品在线看片z| 成人亚洲精品久久久久软件| 亚洲人123区| 国产成人欧美日韩在线电影| 国产精品丝袜91| 成人美女视频在线看| 亚洲欧美在线观看| 成人国产在线观看| 国产亚洲综合在线| 成人avav影音| 亚洲男人的天堂在线aⅴ视频| 99re在线视频这里只有精品| 国产精品成人网| 91麻豆精品国产91久久久使用方法|