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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? os_sem.c

?? uC/OS-II V286 最新的源代碼版本
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*
*********************************************************************************************************
*                                                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 <ucos_ii.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)
{
    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)
{
    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)
{
    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)
{
#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;
    }

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人午夜视频在线| 久久精品国产亚洲高清剧情介绍| 欧美精品123区| 粉嫩av一区二区三区在线播放| 亚洲综合色在线| 久久久美女毛片| 欧美日韩一卡二卡| av在线不卡网| 国产九色sp调教91| 日本不卡1234视频| 一区二区三区在线观看国产| 26uuu亚洲| 欧美一区日本一区韩国一区| 日本高清无吗v一区| 国产成人午夜视频| 久久精品久久久精品美女| 亚洲综合精品自拍| 亚洲丝袜制服诱惑| 国产女人18毛片水真多成人如厕| 日韩午夜精品电影| 欧美日韩一区二区三区四区五区| 91碰在线视频| 99久久免费视频.com| 国产河南妇女毛片精品久久久 | 欧美bbbbb| 亚洲综合一区在线| 亚洲人成人一区二区在线观看| 国产午夜精品久久久久久久| 日本一区二区久久| 久久青草欧美一区二区三区| 欧美mv日韩mv| 精品久久久久一区二区国产| 日韩欧美中文字幕精品| 7777精品伊人久久久大香线蕉完整版 | 国产激情一区二区三区桃花岛亚洲 | 一区二区三区中文字幕| 亚洲欧美另类小说| 一区二区三区**美女毛片| 亚洲美女视频在线| 亚洲精品成人少妇| 亚洲一级不卡视频| 亚洲www啪成人一区二区麻豆| 亚洲视频在线一区观看| 国产精品剧情在线亚洲| 中文字幕中文字幕一区二区| 亚洲欧洲韩国日本视频| 国产精品美女久久久久久久久 | 成人性生交大片免费看中文网站| 日韩va亚洲va欧美va久久| 亚洲福利一区二区三区| 老司机精品视频线观看86| 日日夜夜一区二区| 日本sm残虐另类| 韩国v欧美v亚洲v日本v| 国产盗摄精品一区二区三区在线| 国内外精品视频| 成人av一区二区三区| 色狠狠桃花综合| 欧美日韩免费观看一区二区三区| 欧美午夜视频网站| 欧美一级二级三级蜜桃| 精品成人一区二区| 中文字幕精品一区二区精品绿巨人| 国产精品国产自产拍高清av王其| 亚洲美女视频在线| 一区二区三区四区不卡视频 | 国产精品66部| 97se亚洲国产综合自在线不卡| 色噜噜久久综合| 欧美一级日韩免费不卡| 国产清纯美女被跳蛋高潮一区二区久久w | 欧美成人一区二区三区| 亚洲综合男人的天堂| 香蕉影视欧美成人| 国产精品一级在线| 91在线国内视频| 日韩一区二区三| 国产精品大尺度| 午夜av电影一区| 大陆成人av片| 欧美视频一区二区三区在线观看 | 99久免费精品视频在线观看| 91成人免费在线视频| 激情综合网天天干| 日本大胆欧美人术艺术动态| 国产很黄免费观看久久| 国产资源在线一区| 国模套图日韩精品一区二区| 91免费看`日韩一区二区| 日韩午夜激情av| 中文字幕一区日韩精品欧美| 日韩美女久久久| 亚洲成人黄色小说| 北条麻妃一区二区三区| 欧美日韩国产影片| 国产欧美1区2区3区| 亚洲妇熟xx妇色黄| 成人av综合在线| 亚洲乱码中文字幕| 亚洲人成7777| 久久av中文字幕片| 国产91精品欧美| 欧洲激情一区二区| 精品裸体舞一区二区三区| 一区二区免费在线| 成人app软件下载大全免费| 在线中文字幕一区| 中文字幕欧美激情一区| 日日摸夜夜添夜夜添精品视频| 国产在线精品免费| 日韩一区二区视频| 国产一区在线看| 337p亚洲精品色噜噜| 亚洲裸体xxx| 97久久精品人人爽人人爽蜜臀| 精品奇米国产一区二区三区| 日韩黄色在线观看| 成人高清视频免费观看| 日韩欧美国产系列| 日韩精品成人一区二区三区| av不卡在线播放| 久久精品欧美日韩精品 | 亚洲乱码中文字幕综合| 懂色av噜噜一区二区三区av| 精品伦理精品一区| 日本不卡中文字幕| 国产成人免费xxxxxxxx| 欧美一区二区三区人| 亚洲成人自拍网| 欧美日韩你懂得| 亚洲色欲色欲www| 大尺度一区二区| 国产精品美女久久久久aⅴ国产馆| 黄网站免费久久| 精品国产1区二区| 国产乱子伦视频一区二区三区| 日韩一区二区电影| 捆绑调教美女网站视频一区| 欧美日韩国产一二三| 午夜精品久久久久久久99樱桃| 欧美综合久久久| 首页国产欧美久久| 日韩免费观看高清完整版在线观看| 亚洲一二三专区| 欧美一区二区久久| 久久精品噜噜噜成人av农村| 久久久久国产一区二区三区四区| 国内精品免费在线观看| 国产三级精品三级| av在线综合网| 一区二区三区在线免费视频| 91精品午夜视频| 韩国在线一区二区| 2023国产精品自拍| 奇米色一区二区三区四区| 欧美久久久久中文字幕| 九一久久久久久| 国产日本一区二区| 色悠久久久久综合欧美99| 亚洲风情在线资源站| 91精品国产高清一区二区三区| 日韩电影一区二区三区| 久久久国产一区二区三区四区小说 | 4438成人网| 国产精品一区二区久久不卡| 亚洲四区在线观看| 欧美日韩成人综合天天影院| 免费观看日韩电影| 亚洲国产高清在线观看视频| 91麻豆免费看| 美女性感视频久久| 中文字幕不卡在线| 欧美撒尿777hd撒尿| 九九**精品视频免费播放| 国产精品久久久久久久久免费相片 | 欧美www视频| 99精品国产91久久久久久| 亚洲成人动漫在线免费观看| 久久蜜桃av一区精品变态类天堂| 91同城在线观看| 精品一二三四在线| 亚洲欧洲国产日本综合| 日韩女优av电影| 91国偷自产一区二区使用方法| 久久av资源网| 亚洲精品伦理在线| 久久久五月婷婷| 欧美丰满嫩嫩电影| www.久久精品| 国产在线不卡一卡二卡三卡四卡| 亚洲制服丝袜av| 国产精品美女久久久久高潮| 欧美成人国产一区二区| 欧美色视频在线观看| 床上的激情91.| 久久疯狂做爰流白浆xx| 亚洲国产精品影院| 一区在线观看免费| 国产欧美一区在线| 精品国产乱子伦一区|