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

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

?? os_sem.c

?? 本源碼是用ARM9 2410開發的OLED液晶驅動開發代碼
?? 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一区二区三区免费野_久草精品视频
国产传媒久久文化传媒| 成人免费不卡视频| 亚洲mv大片欧洲mv大片精品| 国产精品福利影院| 国产精品精品国产色婷婷| 久久久一区二区三区| 国产亚洲欧洲997久久综合| 久久精品人人做人人综合| 国产亚洲欧美激情| 国产精品每日更新| 亚洲天堂网中文字| 亚洲狠狠爱一区二区三区| 亚洲一区二区黄色| 麻豆一区二区三区| 国产一区二区精品在线观看| 成人精品视频一区| 在线精品亚洲一区二区不卡| 91精品国产乱码| 精品国产免费人成在线观看| 国产肉丝袜一区二区| 怡红院av一区二区三区| 午夜婷婷国产麻豆精品| 精品在线亚洲视频| 不卡av免费在线观看| 欧美在线你懂得| 欧美精品一区二区久久久| 日本一区二区三区dvd视频在线| 亚洲私人黄色宅男| 日本成人在线不卡视频| 成人av午夜影院| 欧美剧在线免费观看网站| 精品国产乱码久久久久久浪潮 | 欧美日韩www| 久久新电视剧免费观看| 中文字幕日韩一区| 免费久久99精品国产| 成人av在线播放网址| 欧美精品精品一区| 中文字幕第一区二区| 亚洲v日本v欧美v久久精品| 国产精品一二三四区| 欧美三级日韩在线| 国产日韩影视精品| 免费看黄色91| 欧美午夜电影网| 国产精品福利一区二区三区| 美国一区二区三区在线播放| 色综合色狠狠综合色| 久久影院电视剧免费观看| 亚洲午夜av在线| 成人综合婷婷国产精品久久免费| 欧美日本国产一区| 亚洲精品国产精品乱码不99| 国产一区二区三区久久久| 欧美日韩精品一区二区天天拍小说| 国产欧美日韩不卡| 久久99精品一区二区三区三区| 色噜噜狠狠成人网p站| 国产欧美日韩精品在线| 久久精品国产**网站演员| 欧美影视一区在线| 亚洲图片你懂的| 99久久99久久精品免费看蜜桃| 久久夜色精品一区| 六月丁香综合在线视频| 欧美片在线播放| 亚洲欧美日韩在线| av在线播放一区二区三区| 国产日韩精品一区二区三区在线| 久久av资源网| 欧美变态口味重另类| 久久精品噜噜噜成人av农村| 日韩一区二区在线免费观看| 午夜激情久久久| 欧美日韩一区中文字幕| 午夜av电影一区| 欧美日精品一区视频| 亚洲高清视频在线| 欧美日韩精品系列| 午夜精品一区二区三区三上悠亚| 欧美综合色免费| 亚洲午夜一二三区视频| 欧美三级电影在线看| 亚洲不卡一区二区三区| 91麻豆精品国产91久久久久久久久| 亚洲第一电影网| 日韩美女主播在线视频一区二区三区 | 欧美精品乱码久久久久久| 亚洲v日本v欧美v久久精品| 91精品在线一区二区| 蜜桃视频在线观看一区二区| 精品免费国产一区二区三区四区| 国产一区二区在线看| 欧美激情一区二区三区全黄| 色悠悠亚洲一区二区| 三级一区在线视频先锋| 精品国产91洋老外米糕| 成人av先锋影音| 午夜私人影院久久久久| 久久亚洲综合色一区二区三区| 国产69精品久久久久777| 一区二区三区在线视频免费| 欧美精选在线播放| 国产精品主播直播| 亚洲国产一二三| 久久精品视频一区二区| 欧美日韩中文国产| 国产一区二区三区四区五区入口| 亚洲日本电影在线| 日韩欧美二区三区| 一本色道久久综合狠狠躁的推荐| 性久久久久久久久| 国产精品美女久久久久久久网站| 色噜噜狠狠成人网p站| 国产一区二区三区在线看麻豆| 亚洲视频在线一区| 精品精品国产高清a毛片牛牛 | 欧美国产精品一区二区| 欧美日韩一区三区四区| 成人听书哪个软件好| 午夜国产精品一区| **性色生活片久久毛片| 久久先锋影音av鲁色资源网| 欧美三区在线视频| 成人av影院在线| 韩国精品久久久| 日韩精品欧美成人高清一区二区| 中文字幕在线免费不卡| 精品久久一二三区| 5858s免费视频成人| 色素色在线综合| 成人激情午夜影院| 国产麻豆视频一区二区| 七七婷婷婷婷精品国产| 亚洲国产人成综合网站| 亚洲少妇30p| 国产精品久久久久婷婷 | jlzzjlzz亚洲日本少妇| 加勒比av一区二区| 麻豆一区二区99久久久久| 性欧美大战久久久久久久久| 亚洲制服丝袜一区| 亚洲影院在线观看| 亚洲一二三四在线| 综合精品久久久| 亚洲欧美日韩电影| 亚洲视频网在线直播| 亚洲国产成人一区二区三区| 精品国产免费一区二区三区四区| 日韩欧美色电影| 26uuu久久天堂性欧美| 精品日韩99亚洲| 久久综合色综合88| 欧美精品一区二区三区高清aⅴ| 日韩精品专区在线影院观看 | 成人污视频在线观看| 国产成人在线电影| 国产91精品一区二区麻豆网站| 韩国精品在线观看| 国产精品99久久久久久久vr | 一二三四区精品视频| 尤物av一区二区| 天天色天天操综合| 久久精品国产亚洲5555| 韩国精品主播一区二区在线观看 | 亚洲免费av观看| 亚洲午夜电影在线| 秋霞影院一区二区| 国产一区二区三区精品欧美日韩一区二区三区 | 国产精品一区二区91| 丁香天五香天堂综合| 91在线观看视频| 欧美日韩一区久久| 久久综合久久99| 亚洲欧美自拍偷拍色图| 亚洲第一在线综合网站| 久久99国产精品麻豆| av影院午夜一区| 精品视频在线视频| 337p粉嫩大胆噜噜噜噜噜91av| 欧美国产国产综合| 亚洲乱码精品一二三四区日韩在线 | 国产精品久久毛片| 亚洲一区二区三区国产| 久久黄色级2电影| 成人涩涩免费视频| 欧洲视频一区二区| 精品国产乱码久久久久久久| 亚洲特级片在线| 日本成人中文字幕在线视频| 高清不卡一二三区| 欧美亚洲一区二区在线观看| 日韩欧美一区二区不卡| 一色屋精品亚洲香蕉网站| 亚洲成人激情综合网| 国产成人亚洲综合a∨猫咪| 欧美在线免费观看亚洲| 国产欧美日韩卡一| 免费高清视频精品| 91福利在线观看|