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

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

?? os_sem.c

?? uCos-ii 2.86 在C8051F410單片機上移植成功!!! 其中包括:UART驅動
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                              (c) Copyright 1992-2007, Micrium, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.86
*
* LICENSING TERMS:
* ---------------
*   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.  
* If you plan on using  uC/OS-II  in a commercial product you need to contact Micri祄 to properly license 
* its use in your product. We provide ALL the source code for your convenience and to help you experience 
* uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  paying a 
* licensing fee.
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "..\header files\includes.h"
#endif

#if OS_SEM_EN > 0
/*$PAGE*/
/*
*********************************************************************************************************
*                                           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) reentrant
{
    INT16U     cnt;
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0;
#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 block (OS_EVENT) associated with the
*                            created semaphore
*              == (void *)0  if no event control blocks were available
*********************************************************************************************************
*/

OS_EVENT  *OSSemCreate (INT16U cnt)	reentrant
{
    OS_EVENT  *pevent;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0;
#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.
*
*              perr          is a pointer to an error code that can contain one of the following values:
*                            OS_ERR_NONE             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 *perr) reentrant
{
    BOOLEAN    tasks_waiting;
    OS_EVENT  *pevent_return;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {                              /* Validate 'perr'                          */
        return (pevent);
    }
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *perr = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *perr = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *perr = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0) {                         /* See if any tasks waiting on semaphore    */
        tasks_waiting = OS_TRUE;                           /* Yes                                      */
    } else {
        tasks_waiting = OS_FALSE;                          /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
             if (tasks_waiting == OS_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();
                 *perr                  = OS_ERR_NONE;
                 pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *perr                  = OS_ERR_TASK_WAITING;
                 pevent_return          = pevent;
             }
             break;

        case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
             while (pevent->OSEventGrp != 0) {             /* Ready ALL tasks waiting for semaphore    */
                 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
             }
#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 == OS_TRUE) {               /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *perr                  = OS_ERR_NONE;
             pevent_return          = (OS_EVENT *)0;       /* Semaphore has been deleted               */
             break;

        default:
             OS_EXIT_CRITICAL();
             *perr                  = OS_ERR_INVALID_OPT;
             pevent_return          = pevent;
             break;
    }
    return (pevent_return);
}
#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).
*
*              perr          is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*
*                            OS_ERR_NONE         The call was successful and your task owns the resource
*                                                or, the event you are waiting for occurred.
*                            OS_ERR_TIMEOUT      The semaphore was not received within the specified
*                                                'timeout'.
*                            OS_ERR_PEND_ABORT   The wait on the semaphore was aborted.
*                            OS_ERR_EVENT_TYPE   If you didn't pass a pointer to a semaphore.
*                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
*                                                would lead to a suspension.
*                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer.
*                            OS_ERR_PEND_LOCKED  If you called this function when the scheduler is locked
*
* Returns    : none
*********************************************************************************************************
*/
/*$PAGE*/
void  OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *perr)	reentrant
{
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {                         /* Validate 'perr'                               */
        return;
    }
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        *perr = OS_ERR_PEVENT_NULL;
        return;
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        *perr = OS_ERR_EVENT_TYPE;
        return;
    }
    if (OSIntNesting > 0) {                           /* See if called from ISR ...                    */
        *perr = OS_ERR_PEND_ISR;                      /* ... can't PEND from an ISR                    */
        return;
    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩国产a| 国模少妇一区二区三区| 色婷婷av一区二区三区gif| 亚洲四区在线观看| 色综合中文字幕| 亚洲午夜av在线| 777亚洲妇女| 国产一区二区三区免费在线观看| 久久久三级国产网站| 成人h动漫精品| 亚洲女同一区二区| 欧美日本在线观看| 黄色成人免费在线| ...中文天堂在线一区| 亚洲免费资源在线播放| 欧美麻豆精品久久久久久| 免费看精品久久片| 国产日韩欧美一区二区三区乱码| 99视频一区二区| 天天av天天翘天天综合网色鬼国产 | 午夜久久电影网| 日韩欧美国产精品| 成人美女在线观看| 亚洲大片一区二区三区| 久久久电影一区二区三区| 一本久久精品一区二区| 美国十次综合导航| 亚洲天堂成人网| 欧美sm极限捆绑bd| 91精品办公室少妇高潮对白| 国产在线不卡一区| 亚洲国产精品一区二区久久恐怖片 | 日韩欧美一级片| 99r国产精品| 韩国欧美国产1区| 亚洲图片自拍偷拍| 国产日韩欧美精品一区| 欧美一区日本一区韩国一区| 91在线小视频| 国产九色精品成人porny | 国产一区二区网址| 亚洲乱码日产精品bd| 精品日韩99亚洲| 欧美性生活久久| 成人avav影音| 国产在线视频一区二区| 午夜视频久久久久久| 国产精品久久久一本精品| 日韩欧美国产综合一区| 欧美调教femdomvk| 色94色欧美sute亚洲13| 国产91综合一区在线观看| 美女视频黄 久久| 亚洲va韩国va欧美va| 亚洲日本免费电影| 中文字幕高清一区| 国产婷婷色一区二区三区在线| 欧美一区二区在线观看| 欧美伊人精品成人久久综合97| 99re成人在线| 99久久免费视频.com| 国产一区二区成人久久免费影院| 毛片不卡一区二区| 久久精品久久久精品美女| 日韩不卡一区二区| 日韩精品电影在线| 天天综合色天天综合色h| 亚洲综合另类小说| 一区二区三区中文字幕| 亚洲欧美另类小说| 一区二区三区不卡视频| 一区二区三区在线高清| 亚洲免费观看高清完整版在线观看 | 欧美成人在线直播| 日韩三级免费观看| 日韩精品一区二区三区四区视频| 538在线一区二区精品国产| 欧美二区三区91| 91精品国产一区二区三区蜜臀 | 亚洲一卡二卡三卡四卡五卡| 一区二区三区日韩欧美| 亚洲最色的网站| 一本大道久久a久久综合| 一本一道综合狠狠老| 色综合天天性综合| 欧美在线观看18| 欧美日韩精品免费观看视频| 欧美日韩亚洲综合一区二区三区| 色噜噜偷拍精品综合在线| 99视频超级精品| 在线观看视频一区| 欧美老女人第四色| 日韩三级视频在线看| 久久亚洲私人国产精品va媚药| 久久婷婷综合激情| 无码av免费一区二区三区试看| 亚洲精品久久7777| 亚洲国产裸拍裸体视频在线观看乱了| 亚洲人成精品久久久久久| 国产精品短视频| 一区二区三区欧美久久| 蜜桃91丨九色丨蝌蚪91桃色| 国产精选一区二区三区| 91一区二区三区在线播放| 在线观看成人免费视频| 欧美群妇大交群的观看方式| 日韩欧美精品在线视频| 国产精品久99| 午夜精品福利在线| 国产一二三精品| 欧美怡红院视频| 国产日韩欧美一区二区三区乱码| 亚洲免费在线视频一区 二区| 日本不卡视频在线观看| 成人精品国产福利| 欧美精选一区二区| 欧美激情一区二区三区四区| 亚洲在线成人精品| 国产伦精品一区二区三区视频青涩 | 日韩午夜激情电影| 亚洲图片激情小说| 麻豆国产精品一区二区三区 | 欧美一区二区黄| 久久精品夜夜夜夜久久| 一区二区三区在线播| 国内精品嫩模私拍在线| 91精品福利视频| 久久久.com| 免费在线看一区| 色偷偷成人一区二区三区91| 日韩欧美一区中文| 一区二区三区视频在线观看| 国产福利电影一区二区三区| 欧美群妇大交群中文字幕| 国产精品免费观看视频| 男人的天堂久久精品| 在线一区二区三区做爰视频网站| 337p粉嫩大胆色噜噜噜噜亚洲| 一区二区三区在线观看国产| av电影一区二区| 久久综合久色欧美综合狠狠| 亚洲午夜精品在线| 99国产精品久久久久久久久久 | 国产综合久久久久久鬼色| 色狠狠av一区二区三区| 欧美激情综合网| 韩国av一区二区| 欧美一区二区观看视频| 亚洲成av人片在线| 在线观看视频一区二区| 亚洲视频在线观看一区| 国产高清久久久久| 久久精品国产99久久6| 欧美军同video69gay| 亚洲一区二区在线观看视频| 91亚洲国产成人精品一区二三| 国产精品网站在线观看| 国产成人免费在线视频| www国产精品av| 精品亚洲国产成人av制服丝袜| 91精品福利在线一区二区三区 | 一本色道久久综合亚洲91| 国产精品国产精品国产专区不蜜 | 国产亚洲人成网站| 国内精品在线播放| 精品美女在线播放| 狠狠色伊人亚洲综合成人| 欧美大片日本大片免费观看| 美女性感视频久久| 久久综合中文字幕| 国产成人精品亚洲日本在线桃色| 久久精品一区二区三区不卡| 国产高清不卡一区二区| 欧美国产一区二区| 成人午夜精品一区二区三区| 国产精品丝袜久久久久久app| 成人精品免费看| 亚洲欧美欧美一区二区三区| 在线国产亚洲欧美| 日本人妖一区二区| 久久综合狠狠综合久久综合88| 国产精品18久久久久久久久久久久 | 午夜激情久久久| 欧美成人高清电影在线| 国产一区二区三区不卡在线观看| 日本一区二区动态图| 99精品热视频| 亚洲国产综合在线| 欧美电影免费观看完整版| 国产精品一级在线| 樱花草国产18久久久久| 91精品欧美一区二区三区综合在 | 欧美视频完全免费看| 免费高清在线视频一区·| 精品福利在线导航| 99精品视频中文字幕| 丝袜国产日韩另类美女| 国产婷婷一区二区| 欧美午夜电影一区| 国产一区二区精品久久91|