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

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

?? os_sem.c

?? 實用 ucosii for 三星公的的ARM9 S3C2440 完整代碼
?? 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免费网站麻豆 | 久久久久久麻豆| 欧美日韩亚洲不卡| 在线视频国产一区| 日本乱人伦一区| 9l国产精品久久久久麻豆| 风间由美性色一区二区三区| 国产一区二区三区不卡在线观看| 久久国产夜色精品鲁鲁99| 美女网站色91| 国产一本一道久久香蕉| 成人丝袜高跟foot| 色综合网站在线| 色狠狠色狠狠综合| 91精品国产综合久久久久久久久久 | 91论坛在线播放| 91蝌蚪国产九色| 欧美日韩中文一区| 欧美精品一区二区三区在线| 国产日产精品1区| 欧美国产精品专区| 一区二区三区成人在线视频 | 欧美人狂配大交3d怪物一区| 欧美肥胖老妇做爰| 久久婷婷成人综合色| 中文字幕一区二区日韩精品绯色| 亚洲精品国产成人久久av盗摄| 性欧美大战久久久久久久久| 久久精品国产99久久6| 成人av资源在线观看| 色哟哟一区二区在线观看| 91精品国产综合久久婷婷香蕉| 久久综合色一综合色88| 亚洲免费看黄网站| 麻豆精品蜜桃视频网站| 成人综合婷婷国产精品久久| 欧美艳星brazzers| 久久久久久久久99精品| 亚洲精品欧美激情| 极品销魂美女一区二区三区| 一本久道久久综合中文字幕| 日韩欧美国产精品一区| 亚洲欧美日本韩国| 国产乱码精品1区2区3区| 欧美日韩视频专区在线播放| 欧美国产视频在线| 麻豆久久一区二区| 欧美视频一区二区三区在线观看| 久久久久高清精品| 美日韩一级片在线观看| 在线免费观看视频一区| 中文字幕不卡在线观看| 蜜臀久久99精品久久久久宅男| 91浏览器入口在线观看| 国产亚洲va综合人人澡精品| 美女www一区二区| 欧美视频自拍偷拍| 亚洲日本电影在线| 波多野结衣精品在线| ww久久中文字幕| 日本中文字幕一区二区有限公司| 在线免费观看日本欧美| 国产精品久久福利| 成人黄色综合网站| 久久精品一区二区| 紧缚捆绑精品一区二区| 日韩欧美国产精品一区| 奇米色777欧美一区二区| 欧美日韩久久久一区| 亚洲卡通欧美制服中文| 91在线看国产| 国产精品成人在线观看| 99re视频精品| 亚洲欧洲国产日韩| 99国产精品久久| 亚洲色图视频网| 色狠狠色噜噜噜综合网| 一区二区三区日韩精品| 欧美午夜精品一区二区蜜桃 | 欧美主播一区二区三区| 中文字幕制服丝袜成人av| 成人丝袜18视频在线观看| 国产精品麻豆网站| av电影在线观看不卡| 成人免费小视频| 在线看国产一区| 午夜精品福利在线| 欧美高清视频不卡网| 蜜臀av一区二区在线免费观看 | 国产成人午夜精品影院观看视频 | 欧美日韩mp4| 日韩中文欧美在线| 久久一区二区三区四区| 国产白丝精品91爽爽久久| 国产精品久线在线观看| 在线观看国产91| 日韩成人伦理电影在线观看| 久久影院视频免费| 91网站黄www| 首页综合国产亚洲丝袜| 久久夜色精品国产噜噜av| www.亚洲人| 午夜精彩视频在线观看不卡| 精品美女被调教视频大全网站| 国产一区二区三区电影在线观看| 一区二区中文视频| 6080国产精品一区二区| 高清久久久久久| 一区二区三区蜜桃| 日韩女优av电影在线观看| 成人精品免费网站| 日韩精品乱码免费| 国产精品久久看| 国产亚洲制服色| 亚洲综合男人的天堂| 国产精品亚洲专一区二区三区| 欧美一区永久视频免费观看| 国产精品1区二区.| 亚洲永久精品大片| 久久久久久久久岛国免费| 欧美视频一区在线| 丁香婷婷深情五月亚洲| 日韩高清不卡一区二区三区| 国产精品久久免费看| 精品国产一区二区三区久久影院| 91亚洲国产成人精品一区二三| 蜜臀av性久久久久蜜臀aⅴ流畅 | 日韩成人精品在线| 亚洲色欲色欲www| 久久嫩草精品久久久精品一| 欧美三级中文字幕在线观看| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 在线亚洲一区观看| 国产成人免费在线| 久久99久久久久| 天天色图综合网| 一区二区三区在线不卡| 国产精品美女久久久久久久久| 精品剧情在线观看| 91精品国产一区二区三区| 日本道免费精品一区二区三区| 国产成人免费视| 国产乱人伦偷精品视频免下载 | 中文字幕在线不卡视频| 久久久久久夜精品精品免费| 日韩亚洲欧美中文三级| 欧美高清精品3d| 91.com视频| 3751色影院一区二区三区| 7777精品伊人久久久大香线蕉经典版下载| 91麻豆免费观看| 91视视频在线观看入口直接观看www| 国产丶欧美丶日本不卡视频| 国产在线视频不卡二| 韩国欧美国产1区| 国产一区二区三区高清播放| 国产福利一区二区三区视频| 国产黄色成人av| 岛国av在线一区| 91在线云播放| 精品视频在线免费看| 欧美一区永久视频免费观看| 91精品中文字幕一区二区三区| 欧美精品久久一区二区三区| 日韩一级大片在线| 久久久久久久久久电影| 国产精品免费av| 亚洲免费资源在线播放| 亚洲成人免费av| 九九久久精品视频| 成人午夜免费电影| av电影天堂一区二区在线| 91黄视频在线| 91精品国产91久久久久久一区二区| 欧美videos中文字幕| 国产亲近乱来精品视频| 亚洲精选一二三| 天天操天天色综合| 国产精品原创巨作av| 91在线免费播放| 欧美精品高清视频| 久久精品人人做人人综合| 亚洲欧洲日韩一区二区三区| 一区二区三区精品在线观看| 美国毛片一区二区三区| 成人午夜精品在线| 欧美色图免费看| 久久久久久久综合日本| 亚洲最新在线观看| 久久国内精品自在自线400部| 成人一级视频在线观看| 欧美美女直播网站| 国产精品污www在线观看| 亚洲国产精品久久一线不卡| 精品一区二区三区香蕉蜜桃| 91香蕉视频在线| 精品剧情在线观看| 天天综合色天天| 91浏览器在线视频| 久久久蜜桃精品|