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

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

?? os_sem.c

?? ARM9 9200 UCOS 程序
?? 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一区二区三区免费野_久草精品视频
欧美一区二区视频在线观看| 欧美高清视频不卡网| 成人18视频日本| 色综合久久88色综合天天6| 懂色av一区二区在线播放| proumb性欧美在线观看| 精品视频一区三区九区| 精品乱码亚洲一区二区不卡| 中文字幕的久久| 丝袜诱惑制服诱惑色一区在线观看 | 91麻豆精品国产综合久久久久久| 欧美一级搡bbbb搡bbbb| 国产亚洲一区二区三区| 欧美日产在线观看| 国产精品毛片大码女人| yourporn久久国产精品| 国产精品九色蝌蚪自拍| 成人黄色免费短视频| 国产精品久久久久aaaa| 久久99蜜桃精品| 久久免费午夜影院| 国产成人免费高清| 国产精品丝袜在线| 成人福利视频网站| 亚洲视频一区二区在线观看| 色一区在线观看| 午夜国产精品一区| 制服丝袜一区二区三区| 久久爱www久久做| 舔着乳尖日韩一区| 欧美三级三级三级| 日韩二区三区四区| 久久新电视剧免费观看| 国模娜娜一区二区三区| 国产精品久久久久婷婷| www.久久久久久久久| 国产精品免费人成网站| 日本乱人伦aⅴ精品| 日本麻豆一区二区三区视频| 久久亚洲免费视频| 色素色在线综合| 人人超碰91尤物精品国产| 久久亚洲一区二区三区明星换脸| aaa亚洲精品| 一区二区三区精品视频在线| 日韩欧美亚洲国产另类 | 欧美老人xxxx18| 精品亚洲成av人在线观看| 国产精品系列在线| 欧美精品在线视频| 国产一区二区在线影院| 一区二区三区日韩精品视频| 日韩女优毛片在线| 91色porny| 久久99精品久久久久久国产越南 | 国产午夜精品久久久久久久 | 国产在线不卡一区| 一区二区三区中文免费| 日韩欧美亚洲国产另类| 色婷婷久久综合| 91伊人久久大香线蕉| 国产欧美在线观看一区| 久久av中文字幕片| 五月天婷婷综合| 亚洲视频小说图片| 国产欧美精品国产国产专区| 欧美电影免费观看高清完整版在线| 91免费视频观看| 成人av电影免费在线播放| 黑人巨大精品欧美黑白配亚洲| 亚洲sss视频在线视频| 一区二区三区在线视频免费观看 | 欧美变态口味重另类| 91极品视觉盛宴| 99久精品国产| 92国产精品观看| 91在线国产福利| av电影在线观看不卡| 成人黄色网址在线观看| 日韩女优电影在线观看| 日韩一区二区三区视频在线| 91精品国产一区二区三区| 欧美巨大另类极品videosbest| 欧美专区日韩专区| 精品视频全国免费看| 欧美日韩日本视频| 91精品国产色综合久久ai换脸 | 处破女av一区二区| 国产精品123| 风间由美中文字幕在线看视频国产欧美 | 国产在线一区观看| 国产一区不卡视频| 成人性色生活片免费看爆迷你毛片| 国产成人av福利| 成人免费视频视频在线观看免费| 成人av资源站| 亚洲免费av高清| 91精品视频网| 欧美性猛片xxxx免费看久爱| 成人国产免费视频| 国产麻豆9l精品三级站| 免费观看在线综合| 日韩极品在线观看| 亚洲不卡一区二区三区| 一区二区三区精品视频在线| 国产精品国产三级国产三级人妇| 26uuu欧美日本| 日韩欧美亚洲国产精品字幕久久久 | 日韩激情中文字幕| 亚洲福利视频一区二区| 亚洲免费观看在线观看| 亚洲视频免费在线| 成人免费一区二区三区视频| 国产精品久久久久久久久搜平片 | 精品国产一区二区三区久久久蜜月| 91成人免费在线视频| 97精品电影院| 日本道精品一区二区三区| www.日韩大片| 91免费国产视频网站| 五月激情综合色| 丁香激情综合五月| 欧美日韩成人在线一区| 国产亚洲成aⅴ人片在线观看| 亚洲激情图片小说视频| 激情小说欧美图片| 在线欧美日韩国产| 久久精品人人做人人爽人人| 成人午夜免费电影| 717成人午夜免费福利电影| 国产精品国产三级国产有无不卡| 五月天中文字幕一区二区| 成人免费观看视频| 777奇米成人网| 亚洲毛片av在线| 国产剧情一区在线| 3d成人h动漫网站入口| 日韩伦理av电影| 国产一区二区三区在线观看免费| 日本久久电影网| 久久久久久久久97黄色工厂| 丝袜美腿亚洲综合| 色综合中文字幕国产| 日韩亚洲欧美高清| 一区二区三区视频在线看| 成人免费视频一区| 久久亚洲精品小早川怜子| 日韩激情一二三区| 欧美视频一区二区在线观看| 国产精品电影一区二区三区| 国产美女精品在线| 欧美一区二区免费| 五月综合激情网| 在线精品观看国产| 亚洲天天做日日做天天谢日日欢| 国产一区91精品张津瑜| 日韩一区二区三区四区五区六区| 亚洲一区二区免费视频| 色天天综合色天天久久| 国产精品乱码人人做人人爱| 国产米奇在线777精品观看| 日韩欧美的一区二区| 蜜臀久久久99精品久久久久久| 欧美性大战久久久久久久蜜臀| 久久99精品久久只有精品| 欧美日韩在线播放| 亚洲成人av免费| 欧美亚洲国产bt| 亚洲已满18点击进入久久| 9色porny自拍视频一区二区| 亚洲国产精品av| 国产91精品一区二区麻豆网站| 精品国产一区二区在线观看| 免费观看91视频大全| 69堂成人精品免费视频| 婷婷一区二区三区| 91精品视频网| 老司机免费视频一区二区| 欧美成人a∨高清免费观看| 久久成人久久鬼色| 国产午夜久久久久| 9久草视频在线视频精品| 亚洲精品国产一区二区精华液 | 91免费视频网址| 久久久亚洲国产美女国产盗摄| 午夜视频在线观看一区| 99久久久无码国产精品| 色狠狠综合天天综合综合| 国产精品911| 不卡在线视频中文字幕| 国产日产欧美一区二区三区| 粉嫩久久99精品久久久久久夜| 久久精品免费在线观看| 成人激情校园春色| 亚洲精品成人悠悠色影视| 欧美日韩一级二级| 美女久久久精品| 国产一区二区三区在线观看免费视频 | 欧美性生活大片视频| 亚洲欧美另类图片小说|