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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_sem.c

?? 本源碼是用ARM9 2410開發(fā)的OLED液晶驅(qū)動開發(fā)代碼
?? 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:
*

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩精品三区| 欧美日韩一区二区三区免费看| 欧美不卡视频一区| 美国毛片一区二区| 久久日韩精品一区二区五区| 国内外成人在线| 亚洲国产成人一区二区三区| 波多野洁衣一区| 一区二区免费看| 日韩一卡二卡三卡四卡| 久久99久久99精品免视看婷婷 | 色一情一伦一子一伦一区| 亚洲女同ⅹxx女同tv| 精品1区2区3区| 久久福利资源站| 国产精品免费视频一区| 欧美在线啊v一区| 青草av.久久免费一区| 久久九九影视网| 91福利精品第一导航| 蜜臀久久久99精品久久久久久| 久久久亚洲高清| 欧美综合色免费| 另类专区欧美蜜桃臀第一页| 中文字幕欧美一| 欧美成人一区二区| 91性感美女视频| 麻豆精品在线看| 亚洲美女屁股眼交| 精品国产一区二区亚洲人成毛片| 成av人片一区二区| 日本sm残虐另类| 亚洲欧美日韩在线不卡| 日韩一区二区三| 91在线云播放| 国产永久精品大片wwwapp| 一区二区三区免费网站| ww久久中文字幕| 91久久精品网| 国产成人亚洲综合a∨婷婷图片| 亚洲福利视频三区| 国产精品福利一区二区三区| 91精品国产免费| 91国偷自产一区二区开放时间| 九九国产精品视频| 亚洲成人三级小说| 国产精品久久久久久久久晋中| 91精品国产麻豆国产自产在线| 91色.com| 成人蜜臀av电影| 狠狠色伊人亚洲综合成人| 天天综合日日夜夜精品| 亚洲欧美日韩一区二区 | 国产成人夜色高潮福利影视| 亚洲va在线va天堂| 亚洲精品欧美在线| 国产精品久久777777| 国产欧美日韩在线| 日韩欧美视频一区| 91精品视频网| 制服丝袜亚洲网站| 欧美亚男人的天堂| 色婷婷av一区二区三区大白胸| 高清不卡在线观看| 国产91对白在线观看九色| 国产一区在线视频| 激情综合色丁香一区二区| 日韩高清一区二区| 午夜精品福利在线| 天天色综合天天| 天堂午夜影视日韩欧美一区二区| 亚洲人一二三区| 亚洲天堂中文字幕| 亚洲另类在线一区| 亚洲已满18点击进入久久| 一区二区免费看| 亚洲午夜三级在线| 亚洲电影一级黄| 天堂午夜影视日韩欧美一区二区| 亚洲成人在线免费| 日本一道高清亚洲日美韩| 日韩精品乱码av一区二区| 日韩高清一区二区| 韩国精品一区二区| 粉嫩av亚洲一区二区图片| www.亚洲精品| 欧美亚洲日本国产| 欧美一区二区在线看| 欧美一级理论片| 精品国产精品网麻豆系列| 久久精品人人做人人爽97| 欧美国产日本视频| 亚洲免费三区一区二区| 亚洲bt欧美bt精品777| 日本视频中文字幕一区二区三区| 久久精品72免费观看| 国产成人免费视频精品含羞草妖精 | www.av精品| 欧美午夜一区二区三区| 在线成人免费观看| 久久嫩草精品久久久精品一| 国产欧美视频一区二区| 一区二区成人在线| 理论电影国产精品| 成人av在线影院| 欧美乱妇15p| 久久―日本道色综合久久| 亚洲天堂2016| 麻豆精品精品国产自在97香蕉| 国产成人精品免费| 欧美亚洲国产一区二区三区| 日韩视频免费观看高清完整版在线观看| 欧美tickling网站挠脚心| 国产精品久久看| 舔着乳尖日韩一区| 成人高清av在线| 欧美日本韩国一区| 亚洲国产成人自拍| 日本不卡一二三区黄网| av网站免费线看精品| 91麻豆精品国产91久久久久久久久 | 99国产精品视频免费观看| 欧美酷刑日本凌虐凌虐| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | www.在线成人| 欧美一区二区视频在线观看| 日本一区二区三区视频视频| 亚洲成人av福利| 不卡高清视频专区| 欧美一级精品大片| 亚洲欧美韩国综合色| 国产精品综合二区| 欧美一区二区三区人| 亚洲少妇屁股交4| 国产麻豆成人传媒免费观看| 欧美日韩精品专区| 亚洲免费观看高清完整版在线观看| 蜜臀av一区二区在线免费观看| 色婷婷国产精品| 国产精品免费aⅴ片在线观看| 免费看日韩a级影片| 91精品1区2区| 国产精品麻豆欧美日韩ww| 精品午夜一区二区三区在线观看| 欧美午夜精品一区二区三区| 亚洲欧美综合色| 粉嫩aⅴ一区二区三区四区五区| 日韩欧美亚洲一区二区| 性感美女久久精品| 欧洲一区二区三区在线| 自拍av一区二区三区| 粉嫩蜜臀av国产精品网站| 26uuu另类欧美亚洲曰本| 无吗不卡中文字幕| 欧美日韩精品免费| 午夜精品免费在线| 欧美无人高清视频在线观看| 一区二区三区91| 日本高清不卡视频| 亚洲综合小说图片| 在线观看视频91| 亚洲第一成人在线| 欧美日韩在线三区| 亚洲精品第1页| 91国偷自产一区二区三区成为亚洲经典 | 日本美女一区二区三区视频| 欧美日韩一级视频| 亚洲国产欧美另类丝袜| 在线欧美小视频| 亚洲成人一区二区在线观看| 欧美日韩一区二区三区高清| 亚洲国产综合色| 精品污污网站免费看| 亚洲成人一区二区| 欧美一区二区三区小说| 青青草视频一区| 精品蜜桃在线看| 国产a视频精品免费观看| 欧美极品xxx| www.66久久| 一区二区三区精品视频| 欧美图区在线视频| 日韩精品一二三| 久久午夜免费电影| 成人丝袜视频网| 亚洲精品日韩一| 制服丝袜国产精品| 国产资源在线一区| 国产精品久久久久影院亚瑟| 色拍拍在线精品视频8848| 亚洲一区二区三区爽爽爽爽爽| 欧美日韩国产精选| 久久99国产精品久久99果冻传媒| 精品国产91乱码一区二区三区 | 国产资源精品在线观看| 中文字幕一区视频| 欧美三级在线看| 韩国理伦片一区二区三区在线播放| 国产精品免费网站在线观看| 欧亚洲嫩模精品一区三区|