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

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

?? os_sem.c

?? ucosii小實(shí)驗(yàn)任務(wù)五 時(shí)鐘中斷
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : OS_SEM.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "includes.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)
{
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr;
#endif    
    INT16U     cnt;


#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        return (0);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
#endif
    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)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    OS_EVENT  *pevent;


    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                */
        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)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    BOOLEAN    tasks_waiting;


    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);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
#endif
    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) {
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
                 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    */
                 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
             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);

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区三区自拍| 国产91色综合久久免费分享| 一区二区三区免费网站| 中文字幕av在线一区二区三区| 久久亚洲欧美国产精品乐播| 精品福利av导航| 国产亚洲成年网址在线观看| 国产亚洲欧洲一区高清在线观看| 久久综合色婷婷| 国产欧美日韩在线看| 国产精品家庭影院| 亚洲欧美日韩一区二区三区在线观看| 中文字幕在线免费不卡| 亚洲精品成人天堂一二三| 亚洲第一福利一区| 日本成人在线电影网| 精品夜夜嗨av一区二区三区| 国产精品一区二区黑丝| 成人性生交大片免费看中文网站| eeuss影院一区二区三区| 成人美女视频在线看| 91年精品国产| 欧美精品久久久久久久久老牛影院| 欧美一级搡bbbb搡bbbb| wwwwxxxxx欧美| 一色桃子久久精品亚洲| 亚洲一区二区视频在线观看| 日本不卡视频在线| 国产精品99久| 在线观看日韩电影| 日韩一区二区三区av| 久久久www成人免费无遮挡大片| 国产精品福利一区| 亚洲综合在线视频| 麻豆成人av在线| a美女胸又www黄视频久久| 在线看日本不卡| 欧美va亚洲va在线观看蝴蝶网| 中文字幕精品在线不卡| 亚洲愉拍自拍另类高清精品| 久久国产精品无码网站| 91在线免费看| 日韩精品一区二区三区在线观看 | 日韩视频一区二区三区在线播放 | 国产精品国产a| 无码av中文一区二区三区桃花岛| 黄网站免费久久| 99九九99九九九视频精品| 欧美男男青年gay1069videost| 久久一夜天堂av一区二区三区| 亚洲精品国产视频| 国产一区二区三区高清播放| 精品视频色一区| 国产精品网站导航| 免费高清在线一区| 99久久99久久久精品齐齐| 日韩精品一区二区三区视频 | 不卡的电视剧免费网站有什么| 精品视频999| 中文字幕欧美日韩一区| 日韩精品五月天| 91色在线porny| 日韩免费高清av| 亚洲黄色小说网站| 国产高清精品网站| 欧美人xxxx| 亚洲素人一区二区| 国产一区二区美女诱惑| 欧美日韩一区二区欧美激情| 国产精品乱码一区二三区小蝌蚪| 日韩成人一区二区三区在线观看| av欧美精品.com| 欧美精品一区二区三区在线| 亚洲福利一区二区三区| 99久久久久久| 久久精品夜夜夜夜久久| 麻豆91免费看| 91精品国产福利在线观看| 亚洲欧美另类久久久精品2019| 国产精品88av| 久久综合色综合88| 久久成人免费网站| 91精品免费在线观看| 依依成人综合视频| 91亚洲大成网污www| 国产日韩欧美不卡| 国产精品一品二品| 精品久久久久久亚洲综合网 | 久草在线在线精品观看| 欧美午夜电影在线播放| 亚洲男女毛片无遮挡| av午夜一区麻豆| 中文欧美字幕免费| 不卡欧美aaaaa| 中文字幕第一区| 成人开心网精品视频| 国产精品美女一区二区在线观看| 国产乱色国产精品免费视频| 久久亚洲精品国产精品紫薇| 久久激情五月婷婷| 精品国产乱码久久久久久老虎| 日产国产高清一区二区三区 | 丝袜美腿亚洲色图| 欧美久久久久中文字幕| 亚洲成人在线网站| 欧美麻豆精品久久久久久| 午夜精品福利在线| 欧美精品久久天天躁| 日韩电影在线免费看| 欧美一区二区啪啪| 国模一区二区三区白浆| 久久久久久久久久电影| 国产激情视频一区二区在线观看| 久久久久综合网| 成人h动漫精品一区二区| 国产精品久久99| aaa亚洲精品一二三区| 一区二区三区四区精品在线视频| 91久久久免费一区二区| 婷婷国产v国产偷v亚洲高清| 日韩一区二区中文字幕| 狠狠久久亚洲欧美| 国产精品毛片高清在线完整版| 99精品国产一区二区三区不卡| 亚洲人成网站在线| 欧美顶级少妇做爰| 韩国成人精品a∨在线观看| 国产人成一区二区三区影院| 99精品视频一区| 日本伊人午夜精品| 久久久综合视频| 色婷婷综合久色| 免费观看一级欧美片| 久久网这里都是精品| 99久久国产免费看| 日韩精品福利网| 久久精品亚洲麻豆av一区二区| 99久久精品久久久久久清纯| 亚洲电影你懂得| 久久久精品一品道一区| 日本二三区不卡| 九色综合狠狠综合久久| 国产精品电影一区二区| 67194成人在线观看| 福利电影一区二区| 亚洲午夜电影网| 国产视频一区二区在线观看| 91精品福利视频| 激情图片小说一区| 亚洲激情图片小说视频| 欧美v国产在线一区二区三区| 99久久精品情趣| 久久精品国产久精国产| 亚洲人成在线观看一区二区| 欧美大胆一级视频| 91福利在线观看| 国产精品一区二区视频| 亚洲国产裸拍裸体视频在线观看乱了| 精品国产三级a在线观看| 色猫猫国产区一区二在线视频| 日本aⅴ免费视频一区二区三区| 国产午夜亚洲精品不卡| 欧美精品日韩一区| av男人天堂一区| 国产精品影视网| 天堂午夜影视日韩欧美一区二区| 国产精品激情偷乱一区二区∴| 日韩午夜精品视频| 91成人在线免费观看| 国产乱理伦片在线观看夜一区| 婷婷久久综合九色国产成人 | 99视频一区二区| 精品一区二区三区久久久| 亚洲大片在线观看| 亚洲另类一区二区| 中文字幕精品一区二区三区精品| 欧美一区二区三区白人| 欧美性欧美巨大黑白大战| 99精品视频一区| 福利电影一区二区| 国产一区二区视频在线| 日本中文字幕一区二区有限公司| 亚洲欧美日韩一区| 国产精品灌醉下药二区| 久久精品亚洲精品国产欧美| 精品久久久久久久久久久久包黑料 | 色综合av在线| 成人av资源在线| 懂色av一区二区在线播放| 国产在线视频一区二区三区| 手机精品视频在线观看| 一区二区三区国产精华| 亚洲欧洲成人av每日更新| 国产欧美一区二区在线观看| 欧美成人一区二区| 欧美大片在线观看一区二区| 欧美一区二区在线免费观看| 欧美日韩国产精品成人| 在线视频国内自拍亚洲视频| 91久久线看在观草草青青|