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

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

?? os_sem.c

?? At91s64_ucos2.76:基于at91sam7s64芯片的uc/os移植代碼
?? 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性久久久久蜜臀aⅴ流畅| 久久99久久99小草精品免视看| 97精品久久久久中文字幕 | 久久你懂得1024| 一区二区三区精品视频在线| 蜜臂av日日欢夜夜爽一区| 成人激情小说网站| 精品国产一区二区三区四区四| 亚洲精品久久嫩草网站秘色| 成人午夜视频福利| 欧美成人精品1314www| 一区二区久久久久| 91在线观看地址| 国产精品国产三级国产普通话99| 日本不卡高清视频| 欧美高清视频www夜色资源网| 亚洲欧美成人一区二区三区| 国产91丝袜在线观看| 精品播放一区二区| 精品一区二区国语对白| 777欧美精品| 亚洲高清免费观看高清完整版在线观看| 99久久伊人精品| 国产精品成人免费| 成人教育av在线| 国产精品久久久久久久久免费樱桃 | 日韩和欧美的一区| 欧美亚洲日本一区| 亚洲午夜成aⅴ人片| 欧美综合色免费| 亚洲人成网站色在线观看| 成+人+亚洲+综合天堂| 国产精品久久久久久久久免费相片 | 青青草精品视频| 3d动漫精品啪啪1区2区免费| 亚洲国产欧美日韩另类综合 | 91免费视频网址| 亚洲品质自拍视频| 欧美性猛交xxxx乱大交退制版| 亚洲欧美色一区| 欧美视频一区二区三区| 天天做天天摸天天爽国产一区| 欧美日韩国产片| 免费看日韩精品| 久久久亚洲欧洲日产国码αv| 国产麻豆精品在线观看| 国产欧美日韩亚州综合| 99久久99久久精品免费观看| 亚洲欧美日韩成人高清在线一区| 日本精品视频一区二区三区| 亚洲成a人在线观看| 日韩精品一区二区在线| 国产资源在线一区| 18成人在线观看| 欧美日韩国产综合一区二区| 久久91精品久久久久久秒播| 中文子幕无线码一区tr| 日本韩国精品一区二区在线观看| 图片区小说区国产精品视频 | 欧美日韩1234| 国产一区二区91| 一色桃子久久精品亚洲| 欧美日韩高清影院| 国产在线观看一区二区| 亚洲欧美另类综合偷拍| 91麻豆精品国产91久久久使用方法 | 国产精品日韩成人| 欧美日韩一二区| 懂色av噜噜一区二区三区av| 亚洲激情图片qvod| 精品国产伦一区二区三区免费| 欧美人牲a欧美精品| 国产一区二区久久| 亚洲一区二区美女| 国产亚洲一区字幕| 欧美精品一二三| 99久久精品免费| 美国十次了思思久久精品导航| 综合激情成人伊人| 久久精品欧美日韩精品 | 免费在线观看一区| 亚洲日本在线天堂| 国产欧美一区二区精品仙草咪| 欧美三级韩国三级日本一级| 韩国毛片一区二区三区| 亚洲尤物在线视频观看| 国产亚洲综合色| 日韩一本二本av| 欧洲亚洲精品在线| 成人va在线观看| 激情综合网最新| 日韩精品欧美精品| 亚洲一级片在线观看| 中文字幕高清不卡| 久久久久久久综合| 欧美一区二区三区电影| 欧美日韩在线综合| 日本道免费精品一区二区三区| 成人国产精品免费观看| 国内精品国产成人国产三级粉色| 亚洲第一久久影院| 亚洲成人av一区二区| 一区二区三区久久久| 国产精品久久久久7777按摩| 精品国产欧美一区二区| 日韩一级精品视频在线观看| 欧美日韩国产综合一区二区| 一本一道久久a久久精品综合蜜臀| 国产成人在线视频免费播放| 久久 天天综合| 极品销魂美女一区二区三区| 蜜臀久久99精品久久久久宅男| 亚洲成人免费在线观看| 午夜视频久久久久久| 亚洲第一搞黄网站| 免费在线观看一区二区三区| 青青草成人在线观看| 免费久久99精品国产| 麻豆精品在线播放| 久久国产尿小便嘘嘘尿| 狠狠狠色丁香婷婷综合激情| 精品一区二区在线播放| 国产一区二区三区美女| 大陆成人av片| 91香蕉视频在线| 欧美亚洲综合一区| 日韩精品中午字幕| 国产亚洲欧美在线| 日韩美女啊v在线免费观看| 亚洲日本电影在线| 高清成人免费视频| 色综合久久综合网| 69堂成人精品免费视频| 精品国产自在久精品国产| 久久综合色之久久综合| 国产精品污www在线观看| 樱桃国产成人精品视频| 日韩和欧美一区二区三区| 狠狠色综合播放一区二区| 99精品欧美一区二区蜜桃免费| 欧美在线三级电影| 精品人在线二区三区| 亚洲欧洲制服丝袜| 捆绑变态av一区二区三区| 粉嫩嫩av羞羞动漫久久久| 欧洲精品一区二区| 精品国产一二三区| 亚洲视频免费在线| 另类成人小视频在线| 成人成人成人在线视频| 欧美性大战久久久久久久| 精品88久久久久88久久久| 亚洲天堂成人网| 韩国在线一区二区| 欧美日韩色综合| 国产三级精品在线| 青青草视频一区| 欧美亚洲国产一区二区三区va| 日韩免费一区二区| 一区二区三区四区国产精品| 极品少妇xxxx偷拍精品少妇| 色久优优欧美色久优优| 日韩欧美国产系列| 亚洲精品欧美激情| 国产成人在线视频免费播放| 91麻豆精品国产91久久久 | 国产成人精品1024| 91福利视频久久久久| 久久久久久久久岛国免费| 亚洲18色成人| 91在线视频播放地址| 精品国产三级a在线观看| 午夜精品久久久久久久蜜桃app| 成人成人成人在线视频| 久久嫩草精品久久久久| 蜜桃视频一区二区| 4438亚洲最大| 石原莉奈一区二区三区在线观看| 99re成人精品视频| 国产精品嫩草99a| 国产自产高清不卡| 精品盗摄一区二区三区| 青青草成人在线观看| 91麻豆精品91久久久久同性| 一片黄亚洲嫩模| 色婷婷久久久亚洲一区二区三区| 国产精品视频在线看| 精品一区二区免费在线观看| 日韩视频免费观看高清完整版 | 国产精品久久综合| 岛国精品一区二区| 国产精品欧美一级免费| 国产乱码一区二区三区| 欧美精品一区在线观看| 美腿丝袜亚洲综合| 欧美成人一区二区三区| 国产一区二区电影|