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

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

?? os_sem.c

?? Embedded Osystem uCoS s implanting
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
/*
*********************************************************************************************************
*                                                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
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美刺激午夜性久久久久久久| 国产精品视频一二| 欧美日韩亚洲高清一区二区| 成人黄色一级视频| eeuss影院一区二区三区| 成人爽a毛片一区二区免费| 国产91精品一区二区麻豆亚洲| 国产主播一区二区| 国产酒店精品激情| 国产ts人妖一区二区| 国产69精品久久久久毛片 | 国产精品123| 国产最新精品精品你懂的| 国产在线精品一区二区三区不卡| 裸体健美xxxx欧美裸体表演| 国内精品国产三级国产a久久| 国产在线一区二区综合免费视频| 国产一区二区在线电影| 国产69精品久久777的优势| 成人网在线播放| av在线不卡观看免费观看| 日本一区二区三区dvd视频在线| 欧美精品一区二区久久婷婷| 精品1区2区在线观看| 久久久久久久一区| 国产精品入口麻豆九色| 亚洲精品第一国产综合野| 亚洲国产欧美日韩另类综合| 三级影片在线观看欧美日韩一区二区| 久久精品国产网站| 国产成人精品亚洲日本在线桃色| 91视频一区二区| 欧美伦理影视网| 精品久久久久久综合日本欧美| 欧美精彩视频一区二区三区| 亚洲免费观看高清完整| 日韩中文字幕区一区有砖一区| 国产精品资源站在线| 99re这里只有精品视频首页| 欧美羞羞免费网站| 欧美精品一区二| ...中文天堂在线一区| 日韩中文字幕麻豆| 成人国产视频在线观看| 欧美日韩视频第一区| 久久久精品2019中文字幕之3| 亚洲精品国产一区二区精华液| 日本不卡视频在线观看| 床上的激情91.| 欧美日韩一级片在线观看| www激情久久| 亚洲已满18点击进入久久| 韩国av一区二区三区| 欧美中文字幕亚洲一区二区va在线 | 日本一区二区视频在线观看| 亚洲在线视频一区| 国产一二三精品| 欧美日韩国产中文| 国产日韩欧美一区二区三区乱码 | 欧美国产日韩在线观看| 日韩精品每日更新| 成人av网在线| 精品国产自在久精品国产| 亚洲免费观看高清完整版在线观看 | 一区二区三区鲁丝不卡| 麻豆精品国产91久久久久久| 色综合久久久久久久| 欧美精品一区二| 舔着乳尖日韩一区| 色悠久久久久综合欧美99| 久久久久久久综合日本| 秋霞午夜av一区二区三区| 欧美中文一区二区三区| 国产精品久久久久天堂| 精油按摩中文字幕久久| 欧美日韩午夜在线视频| 亚洲欧美aⅴ...| 成人久久18免费网站麻豆 | 亚洲精品成a人| 成人在线视频一区| 精品久久五月天| 人人爽香蕉精品| 欧美巨大另类极品videosbest | 国产亚洲欧洲997久久综合| 三级在线观看一区二区| 精品视频一区二区不卡| 亚洲人成亚洲人成在线观看图片| 国产成人综合在线观看| 久久综合国产精品| 久久丁香综合五月国产三级网站| 粉嫩av亚洲一区二区图片| 精品国产乱码久久久久久久| 欧美aaaaa成人免费观看视频| 精品1区2区3区| 亚洲午夜久久久久久久久久久| 91麻豆精品视频| 亚洲欧洲综合另类| 色菇凉天天综合网| 亚洲精品中文字幕在线观看| 97久久久精品综合88久久| 国产精品美女久久久久aⅴ| 国产高清视频一区| 久久精品欧美日韩| 国产精品亚洲人在线观看| 久久日韩粉嫩一区二区三区| 国产一区999| 欧美激情综合五月色丁香| 成人午夜私人影院| 日韩久久一区二区| 91日韩在线专区| 亚洲欧美另类小说| 欧美婷婷六月丁香综合色| 亚洲一二三四久久| 欧美日韩在线一区二区| 视频一区二区欧美| 欧美电影免费提供在线观看| 国内成+人亚洲+欧美+综合在线| 久久精品欧美一区二区三区麻豆| 国产99久久久精品| 亚洲区小说区图片区qvod| 欧美三级日韩在线| 日韩黄色在线观看| 欧美精品一区二区三区视频| 国产高清精品在线| 日韩美女视频一区| 欧美综合视频在线观看| 日韩高清电影一区| 久久亚洲捆绑美女| 91在线观看一区二区| 亚洲成a人片在线观看中文| 日韩一区二区精品| 国产超碰在线一区| 亚洲激情在线播放| 日韩免费高清视频| 成人黄色综合网站| 亚洲成人免费在线| 久久综合九色综合97婷婷| 91亚洲资源网| 六月婷婷色综合| 亚洲欧美中日韩| 欧美乱妇15p| 国产91丝袜在线播放九色| 亚洲一区二区免费视频| 日韩精品专区在线影院观看| 成人一级视频在线观看| 亚洲一区二区三区四区在线观看| 欧美电视剧免费全集观看| 国产成a人亚洲| 偷拍与自拍一区| 久久精品夜夜夜夜久久| 在线免费观看日本欧美| 激情五月婷婷综合网| 一区二区三区四区av| 欧美一区欧美二区| 成人理论电影网| 日韩福利视频网| 亚洲视频一区二区在线观看| 欧美一区二区三区影视| 99久久精品免费看国产 | 91一区一区三区| 麻豆免费看一区二区三区| 成人免费在线观看入口| 精品1区2区在线观看| 欧美视频在线观看一区| 成人av在线一区二区| 日本午夜一本久久久综合| 1024精品合集| 国产午夜亚洲精品理论片色戒 | 亚洲尤物视频在线| 国产日韩精品视频一区| 3751色影院一区二区三区| 91丝袜高跟美女视频| 国产美女在线观看一区| 午夜精品一区二区三区免费视频 | 久久久美女毛片| 欧美另类z0zxhd电影| 91在线高清观看| 国产成人免费在线观看不卡| 另类综合日韩欧美亚洲| 午夜精品一区二区三区免费视频| 国产精品国产三级国产aⅴ原创| 精品国产一区久久| 欧美精品久久一区| 欧美亚洲综合色| 99国产麻豆精品| 成人av电影在线| 国产高清不卡一区| 国产一区视频网站| 久久国产视频网| 日韩精品一区第一页| 亚洲一区二区三区中文字幕| 亚洲免费成人av| 成人免费小视频| 中文字幕欧美激情| 国产人伦精品一区二区| 久久久精品国产99久久精品芒果 | 午夜激情一区二区| 亚洲最大成人综合| 亚洲综合在线五月| 一区二区三区在线观看国产|