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

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

?? os_sem.c

?? AT91RM9200的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网站| 欧美色视频在线观看| 日韩激情视频网站| wwwwww.欧美系列| 97se亚洲国产综合自在线| 亚洲人成7777| 欧美一区二区三区在线看| 久久国产综合精品| 中文字幕一区二区三区色视频| 99免费精品视频| 日韩精品久久理论片| 久久久综合视频| 91美女精品福利| 蜜桃视频一区二区三区 | 国产一区二区中文字幕| 国产日韩欧美制服另类| 日本高清不卡aⅴ免费网站| 蜜臀久久久久久久| 男女男精品视频网| 国产情人综合久久777777| 99久久精品国产一区| 午夜久久久久久久久| 久久久99精品免费观看| 91麻豆视频网站| 精品亚洲国产成人av制服丝袜 | 国产午夜精品久久| 欧美在线高清视频| 国产一本一道久久香蕉| 一区二区日韩av| 国产拍揄自揄精品视频麻豆| 欧美三级一区二区| 成人一级片在线观看| 亚洲电影你懂得| 欧美激情在线一区二区三区| 欧美日产在线观看| 成人av网站在线观看| 奇米在线7777在线精品| 自拍偷拍国产精品| 久久久久久久网| 欧美男生操女生| 91老师片黄在线观看| 韩国成人在线视频| 亚洲国产日日夜夜| 国产精品电影院| 2019国产精品| 亚洲成人777| 国产精品久久久一区麻豆最新章节| 欧美精品免费视频| 色婷婷狠狠综合| 丁香激情综合国产| 精品中文字幕一区二区| 无吗不卡中文字幕| 一区二区三区国产精华| 国产精品国产精品国产专区不蜜| 2023国产精品自拍| 日韩亚洲欧美成人一区| 88在线观看91蜜桃国自产| 欧洲一区在线观看| 日本高清免费不卡视频| 99精品国产热久久91蜜凸| 国产九九视频一区二区三区| 美腿丝袜亚洲色图| 日本免费在线视频不卡一不卡二| 亚洲制服丝袜av| 一区二区三区免费观看| 亚洲欧美另类图片小说| 国产精品毛片a∨一区二区三区| 国产亚洲污的网站| 国产女主播在线一区二区| 国产亚洲精品超碰| 欧美国产综合一区二区| 国产拍欧美日韩视频二区| 久久免费精品国产久精品久久久久| 91精品国产免费| 4438x成人网最大色成网站| 在线成人高清不卡| 日韩一级片网址| 精品久久久久av影院| wwwwxxxxx欧美| 国产日韩一级二级三级| 日本一区二区免费在线观看视频| 久久精品一区二区三区不卡| 日韩精品一区二区三区三区免费| 欧美r级电影在线观看| 久久夜色精品一区| 国产精品美日韩| 亚洲欧美aⅴ...| 亚洲国产aⅴ成人精品无吗| 亚洲成人一区二区| 久久精品国产亚洲5555| 国产盗摄精品一区二区三区在线| 成人影视亚洲图片在线| 91丨porny丨首页| 欧美久久久久久久久| 欧美mv日韩mv| 亚洲欧美综合色| 午夜精品久久久久久久蜜桃app| 美女一区二区三区在线观看| 日韩午夜小视频| 久久综合成人精品亚洲另类欧美| 欧美国产日韩a欧美在线观看 | 一区二区成人在线| 日韩av午夜在线观看| 国产精品一区在线| 91国在线观看| 精品国产91亚洲一区二区三区婷婷| 久久久久久一二三区| 亚洲乱码一区二区三区在线观看| 调教+趴+乳夹+国产+精品| 国产精品一二三四五| 91国产精品成人| 日韩亚洲欧美一区| 国产精品短视频| 奇米影视一区二区三区小说| 懂色av一区二区三区免费观看| 91久久精品一区二区| 久久亚洲春色中文字幕久久久| 综合电影一区二区三区 | 国产精品18久久久久| 色婷婷亚洲精品| 久久精品亚洲麻豆av一区二区| 亚洲欧美成人一区二区三区| 精品亚洲欧美一区| 欧美三级日韩在线| 国产日本欧洲亚洲| 蜜桃一区二区三区四区| 在线观看日韩电影| 成人欧美一区二区三区黑人麻豆 | 亚洲乱码一区二区三区在线观看| 麻豆精品久久精品色综合| 色94色欧美sute亚洲线路一ni | 自拍偷拍欧美精品| 国产在线看一区| 欧美伦理视频网站| 亚洲精品videosex极品| 国产成人免费高清| 欧美大度的电影原声| 五月婷婷综合在线| 色婷婷国产精品久久包臀| 国产亚洲精品bt天堂精选| 免费成人美女在线观看.| 91国产福利在线| 亚洲色图清纯唯美| 成人网页在线观看| 久久精品免视看| 久久99久久99| 欧美一区二区人人喊爽| 亚洲一级二级三级在线免费观看| 不卡一区在线观看| 国产农村妇女毛片精品久久麻豆 | 精品成人在线观看| 天堂一区二区在线| 在线观看国产一区二区| 日韩理论片一区二区| 99久久久久久| 中文字幕一区二区5566日韩| 国产精品自拍毛片| 久久久美女毛片| 国产在线播放一区二区三区| 久久午夜老司机| 国产一区二区在线看| 久久久综合网站| 成人性色生活片免费看爆迷你毛片| 亚洲精品一区二区三区精华液| 奇米精品一区二区三区在线观看| 7777精品伊人久久久大香线蕉经典版下载 | 国产成人精品午夜视频免费| www一区二区| 国产69精品久久久久毛片| 国产精品午夜在线| 91浏览器在线视频| 亚洲精选免费视频| 精品视频全国免费看| 日韩在线一区二区| 亚洲精品一区二区三区福利| 国产福利一区在线| 亚洲欧洲av一区二区三区久久| 91在线观看污| 亚洲高清免费在线| 日韩精品一区二区三区视频在线观看 | 日韩avvvv在线播放| 欧美不卡123| 国产69精品久久777的优势| 亚洲欧美另类小说| 欧美高清视频一二三区| 国产最新精品免费| 国产精品久久久久久妇女6080| 在线亚洲一区二区| 日本aⅴ免费视频一区二区三区 | 99久久99久久综合| 亚洲va韩国va欧美va精品 | 欧美日韩在线一区二区| 久久99久久久欧美国产| 中文字幕 久热精品 视频在线| 色香蕉久久蜜桃| 免费看日韩精品|