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

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

?? os_sem.c

?? ARM7的一些試驗程序
?? 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不卡免费电影| 亚洲精品你懂的| 欧美一二三区在线| 99久久综合色| 99这里都是精品| 日本黄色一区二区| 国产成人精品三级麻豆| 亚洲成人av一区| 国产精品久久久久久妇女6080| 欧美日韩一级二级三级| av一二三不卡影片| 色综合久久综合中文综合网| 老司机精品视频导航| 亚洲综合图片区| 日本一区二区成人| 1区2区3区精品视频| 久久色.com| 欧美一区二区三区喷汁尤物| 欧美不卡一区二区三区四区| 久久精品人人爽人人爽| 欧美第一区第二区| 欧美精品18+| 欧美色偷偷大香| 精品国产乱码久久久久久影片| 91国模大尺度私拍在线视频| 91精品久久久久久蜜臀| 欧美三区在线观看| 欧美成人一级视频| 亚洲美女免费在线| 亚洲精品一二三四区| 日本欧美肥老太交大片| 奇米影视一区二区三区小说| 午夜精品福利一区二区三区av| 亚洲精品免费一二三区| 久草在线在线精品观看| 麻豆精品一区二区三区| 久久99久久精品| 91无套直看片红桃| 色视频一区二区| 精品国产乱码久久久久久夜甘婷婷 | 欧美性色欧美a在线播放| 91免费视频大全| 欧洲精品一区二区| 色噜噜久久综合| 久久久午夜精品| 国产精品久久久久国产精品日日| 亚洲国产成人av| 老司机午夜精品99久久| 在线一区二区三区四区五区 | 在线一区二区观看| www亚洲一区| 日精品一区二区三区| 久久99精品久久久久久国产越南| 91蝌蚪porny| 国产欧美1区2区3区| 国产精品午夜在线观看| 亚洲午夜在线观看视频在线| 福利电影一区二区| 99免费精品视频| 国产女同性恋一区二区| 美国十次了思思久久精品导航| 欧美在线播放高清精品| 亚洲免费在线电影| 一本久久精品一区二区| 国产精品久久看| 不卡电影一区二区三区| 欧美日韩国产一级二级| 精品国产一区二区三区四区四| 日精品一区二区| 91精品国产高清一区二区三区| 亚洲在线观看免费| 欧美三日本三级三级在线播放| 一区二区三区美女| 国产乱码精品1区2区3区| 91国产福利在线| 亚洲一区二区高清| 91.麻豆视频| 另类调教123区| 日韩美女视频在线| 久久97超碰色| 久久精品网站免费观看| 国产69精品久久99不卡| 国产精品欧美久久久久无广告 | 日韩欧美在线123| 奇米色777欧美一区二区| 日韩丝袜美女视频| 麻豆国产精品一区二区三区 | 亚洲影视资源网| 欧美日韩在线电影| 日av在线不卡| 国产欧美一区二区精品婷婷| 国产xxx精品视频大全| 中文字幕永久在线不卡| 欧美三级乱人伦电影| 蜜桃一区二区三区在线| 久久久99精品久久| 99视频一区二区三区| 亚洲国产精品久久一线不卡| 日韩欧美www| 成人一区二区三区中文字幕| 精品区一区二区| 成人久久视频在线观看| 亚洲国产一区二区三区| 久久久久久一二三区| 一本到不卡免费一区二区| 亚洲超丰满肉感bbw| 久久精品欧美日韩| 91福利国产精品| 韩国女主播一区| 日韩视频中午一区| 99视频在线精品| 免费成人美女在线观看.| 中文字幕精品一区| 7777女厕盗摄久久久| 不卡大黄网站免费看| 蜜桃视频在线一区| 亚洲精品成人a在线观看| 日韩欧美国产综合一区| 一本色道综合亚洲| 激情伊人五月天久久综合| 一区二区三区精品| 久久久夜色精品亚洲| 制服丝袜亚洲播放| 一道本成人在线| 国产成人亚洲综合a∨婷婷图片| 亚洲bdsm女犯bdsm网站| 18欧美亚洲精品| 久久久久97国产精华液好用吗| 欧美日韩国产免费一区二区 | 精品裸体舞一区二区三区| 色域天天综合网| 成人性视频网站| 久久精品久久综合| 午夜精品久久久久久久久久久| 最新国产成人在线观看| 欧美探花视频资源| 91在线免费播放| 日韩精品高清不卡| 亚洲欧洲韩国日本视频| 久久精品一区四区| 亚洲精品在线免费观看视频| 日韩情涩欧美日韩视频| 欧美日本免费一区二区三区| 日本丰满少妇一区二区三区| 99久久精品费精品国产一区二区| 亚洲乱码国产乱码精品精的特点| 国产精品九色蝌蚪自拍| 中文字幕一区二区三区在线不卡| 国产视频亚洲色图| 国产欧美一区二区精品性| 久久色成人在线| 国产欧美日韩视频一区二区| 久久精品一区蜜桃臀影院| 国产亚洲成年网址在线观看| 久久久激情视频| 国产精品三级电影| 成人免费小视频| 一区二区三区在线观看国产| 亚洲成在线观看| 日韩中文字幕一区二区三区| 天堂蜜桃一区二区三区| 蜜桃视频在线观看一区二区| 免费观看在线综合色| 美女国产一区二区| 国产黄色精品网站| 91视频免费观看| 欧美精品一卡二卡| 久久久久国产精品人| 国产精品国产自产拍高清av王其| 国产精品每日更新在线播放网址 | 日产国产高清一区二区三区| 久久狠狠亚洲综合| 99精品国产99久久久久久白柏| 一本色道久久加勒比精品 | 欧美激情一区二区在线| 亚洲免费观看高清完整版在线观看熊| 亚洲午夜国产一区99re久久| 久久99精品国产.久久久久久 | 色婷婷激情一区二区三区| 欧美男生操女生| 中文字幕精品一区二区精品绿巨人 | 国产欧美一区二区精品久导航 | 国产色91在线| 亚洲免费在线观看| 麻豆国产一区二区| proumb性欧美在线观看| 欧美狂野另类xxxxoooo| 中文一区在线播放| 日韩成人一区二区| 91亚洲精品久久久蜜桃| 91精品久久久久久久91蜜桃| 国产午夜精品一区二区三区视频 | 国产日本欧洲亚洲| 亚洲成人av电影| 成人动漫一区二区在线| 91精品国产综合久久久久| 日本一区二区三区dvd视频在线 |