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

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

?? os_sem.c

?? 基于ucos的arm7 lpc2138的lcd程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2007, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.85
*
* LICENSING TERMS:
* ---------------
*   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.  
* If you plan on using  uC/OS-II  in a commercial product you need to contact Micri祄 to properly license 
* its use in your product. We provide ALL the source code for your convenience and to help you experience 
* uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  paying a 
* licensing fee.
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include <ucos_ii.h>
#endif

#if OS_SEM_EN > 0
/*$PAGE*/
/*
*********************************************************************************************************
*                                           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 block (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.
*
*              perr          is a pointer to an error code that can contain one of the following values:
*                            OS_ERR_NONE             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 *perr)
{
    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 (perr == (INT8U *)0) {                              /* Validate 'perr'                          */
        return (pevent);
    }
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *perr = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *perr = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *perr = 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();
                 *perr                  = OS_ERR_NONE;
                 pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *perr                  = 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, OS_STAT_PEND_OK);
             }
#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  */
             }
             *perr                  = OS_ERR_NONE;
             pevent_return          = (OS_EVENT *)0;       /* Semaphore has been deleted               */
             break;

        default:
             OS_EXIT_CRITICAL();
             *perr                  = 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
*                            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).
*
*              perr          is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*
*                            OS_ERR_NONE         The call was successful and your task owns the resource
*                                                or, the event you are waiting for occurred.
*                            OS_ERR_TIMEOUT      The semaphore was not received within the specified
*                                                'timeout'.
*                            OS_ERR_PEND_ABORT   The wait on the semaphore was aborted.
*                            OS_ERR_EVENT_TYPE   If you didn't pass a pointer to a semaphore.
*                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
*                                                would lead to a suspension.
*                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer.
*                            OS_ERR_PEND_LOCKED  If you called this function when the scheduler is locked
*
* Returns    : none
*********************************************************************************************************
*/

void  OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *perr)
{
    INT8U      pend_stat;
#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 (perr == (INT8U *)0) {                         /* Validate 'perr'                               */
        return;
    }
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        *perr = OS_ERR_PEVENT_NULL;
        return;
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        *perr = OS_ERR_EVENT_TYPE;
        return;
    }
    if (OSIntNesting > 0) {                           /* See if called from ISR ...                    */
        *perr = OS_ERR_PEND_ISR;                      /* ... can't PEND from an ISR                    */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲卡通欧美制服中文| 一二三区精品视频| 51精品久久久久久久蜜臀| 99精品视频中文字幕| 日韩黄色一级片| 欧洲激情一区二区| 91网站在线播放| 国产欧美精品区一区二区三区| 91影院在线免费观看| 粉嫩蜜臀av国产精品网站| 国产一区二区三区久久悠悠色av | 玉米视频成人免费看| 国产日韩欧美在线一区| 国产成人亚洲综合a∨婷婷| 五月天国产精品| 亚洲高清免费一级二级三级| 亚洲第一福利视频在线| 亚洲影视在线观看| 一区二区三区日本| 午夜私人影院久久久久| 午夜国产精品一区| 日韩国产在线观看一区| 亚洲第四色夜色| 天天操天天综合网| 国产乱子伦视频一区二区三区| 精品一区二区三区免费播放| 午夜私人影院久久久久| 极品美女销魂一区二区三区免费| 蜜臀av性久久久久蜜臀aⅴ四虎| 久久91精品久久久久久秒播| 久久国产剧场电影| 国产精品中文字幕日韩精品| 成人91在线观看| 色综合一区二区| 91.com视频| 精品日韩欧美在线| 国产亚洲精品福利| 亚洲免费观看视频| 亚洲成国产人片在线观看| 另类小说欧美激情| 国产精品一区二区无线| 国产999精品久久| 欧美中文字幕亚洲一区二区va在线| 欧美日韩在线直播| 欧日韩精品视频| 精品国产乱码久久久久久老虎 | 午夜欧美视频在线观看| 日韩**一区毛片| 久久69国产一区二区蜜臀| 国产精一区二区三区| 99久久99久久精品免费看蜜桃| 欧美精品 日韩| 精品久久五月天| 久久久国产一区二区三区四区小说 | 成人国产精品免费观看视频| 色欧美88888久久久久久影院| 欧美日韩精品一区视频| 欧美精彩视频一区二区三区| 夜色激情一区二区| 国产成人免费在线观看不卡| 欧美写真视频网站| 久久―日本道色综合久久| 亚洲精品videosex极品| 蜜臀av性久久久久av蜜臀妖精| 91天堂素人约啪| 日韩午夜电影在线观看| 中文字幕一区二区5566日韩| 日本人妖一区二区| 成人精品鲁一区一区二区| 欧美一区二区二区| 亚洲欧洲性图库| 午夜电影一区二区三区| 成人av在线资源网| 欧美一区二区三区免费大片 | 国产综合久久久久影院| 欧美日韩综合不卡| 国产视频一区在线播放| 奇米亚洲午夜久久精品| 99re热这里只有精品免费视频 | 亚洲五码中文字幕| 国产一区二区三区免费观看| 欧美日韩aaaaa| 一区二区三区丝袜| 懂色av中文字幕一区二区三区| 欧美成人乱码一区二区三区| 亚洲三级小视频| 国产乱子伦视频一区二区三区| 4438成人网| 亚洲一二三级电影| 91久久国产综合久久| 中文字幕的久久| 日本aⅴ精品一区二区三区| 色婷婷亚洲精品| 中文无字幕一区二区三区| 狠狠狠色丁香婷婷综合久久五月| 欧美日韩免费视频| 中文欧美字幕免费| 成人免费av在线| 久久一日本道色综合| 精品制服美女久久| 欧美一区国产二区| 日本三级韩国三级欧美三级| 欧美日韩视频第一区| 亚洲蜜桃精久久久久久久| 成人av片在线观看| 日本一区二区三区电影| 国产成人亚洲精品狼色在线| 欧美成人三级电影在线| 亚洲高清一区二区三区| 6080日韩午夜伦伦午夜伦| 亚洲一区二区三区在线播放| 欧美视频中文字幕| 一区二区三区蜜桃网| 欧美在线免费播放| 亚洲一区二区三区视频在线 | 日韩一区国产二区欧美三区| 日本91福利区| 日韩一级精品视频在线观看| 老司机一区二区| 日韩一级免费一区| 麻豆精品国产传媒mv男同| 精品欧美黑人一区二区三区| 黄页视频在线91| 国产亚洲欧洲一区高清在线观看| 亚洲精品中文在线影院| 日韩av电影免费观看高清完整版 | 国产精品国产三级国产普通话99 | 欧美国产在线观看| 懂色av中文一区二区三区| 国产精品国产精品国产专区不片| 成人黄色软件下载| 亚洲人成小说网站色在线 | 成人国产精品免费观看动漫| 久久久久亚洲蜜桃| 粉嫩av一区二区三区在线播放| 欧美国产激情一区二区三区蜜月| 麻豆精品久久久| 久久久久久久久99精品| 成人在线视频一区| 亚洲成人你懂的| 日韩免费视频一区| 成人黄色av电影| 亚洲夂夂婷婷色拍ww47| 日韩一区二区三区在线| 国产精品一区二区三区乱码| 国产精品久久久久久久岛一牛影视 | 精品国产伦一区二区三区观看体验 | 91婷婷韩国欧美一区二区| 日日夜夜免费精品视频| 日韩午夜激情视频| 韩国精品主播一区二区在线观看 | 国产成人亚洲精品青草天美| 国产精品久久久久婷婷二区次| 欧美无砖专区一中文字| 日韩av一二三| 国产女人aaa级久久久级| 91影视在线播放| 久久精品国产77777蜜臀| 久久奇米777| 欧美亚洲国产一区二区三区va| 蜜臀99久久精品久久久久久软件| 欧美一区永久视频免费观看| 99久久伊人久久99| 日韩av二区在线播放| 日韩理论片在线| 91精品国产免费| 成人综合在线观看| 亚洲mv在线观看| 中文在线一区二区| 日韩欧美电影在线| 91丨九色丨国产丨porny| 黑人巨大精品欧美一区| 亚洲欧美日本韩国| 日韩精品一区二区三区中文不卡| 成人一区二区三区视频在线观看| 亚洲国产一区在线观看| 欧美大白屁股肥臀xxxxxx| 成人av动漫在线| 国产综合成人久久大片91| 亚洲在线视频一区| 精品国产伦一区二区三区免费| 欧美日韩一区精品| 成人黄色免费短视频| 韩国v欧美v日本v亚洲v| 一区二区三区日韩欧美| 国产精品日日摸夜夜摸av| 欧美一级二级三级乱码| hitomi一区二区三区精品| 国产精品99久久久久久似苏梦涵| 亚洲影院在线观看| 一区二区在线观看免费视频播放| 久久―日本道色综合久久| 69精品人人人人| 在线中文字幕不卡| 国产福利一区二区三区视频在线 | 欧美精品久久天天躁| 色欧美片视频在线观看在线视频| 国产成人自拍网| 性做久久久久久免费观看欧美| 一区二区三区欧美在线观看|