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

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

?? os_sem.c

?? LPC2104/5/6嵌入式系統程序實例,帶有PROTUES7.1仿真文件,適合做入門指導
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                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);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
不卡视频在线看| 欧美日韩国产系列| 视频在线观看一区| 国产精品视频线看| 日韩视频在线永久播放| 99re热视频这里只精品| 看片的网站亚洲| 亚洲高清一区二区三区| 日韩毛片视频在线看| 久久综合九色欧美综合狠狠 | 豆国产96在线|亚洲| 婷婷六月综合网| 亚洲激情图片一区| 国产精品伦一区二区三级视频| 日韩欧美国产wwwww| 欧美在线你懂的| 成人av在线资源| 国产成人av一区二区| 麻豆91精品视频| 污片在线观看一区二区| 亚洲黄色免费电影| 最新国产精品久久精品| 久久久天堂av| 欧美精品一区二区三区很污很色的 | 884aa四虎影成人精品一区| 91丝袜呻吟高潮美腿白嫩在线观看| 国产乱码一区二区三区| 麻豆一区二区99久久久久| 日韩精品国产精品| 天使萌一区二区三区免费观看| 一区二区三区欧美在线观看| 国产精品第四页| 国产精品国产三级国产普通话三级 | 亚洲欧美激情在线| 国产精品久久久久久久久晋中 | 91福利国产成人精品照片| www.66久久| 9色porny自拍视频一区二区| 成人免费毛片嘿嘿连载视频| 成人污视频在线观看| 处破女av一区二区| 成人永久aaa| 9i在线看片成人免费| 不卡一区中文字幕| 91天堂素人约啪| 91国偷自产一区二区使用方法| 99精品视频一区二区| 91在线一区二区三区| 日本二三区不卡| 欧美日韩视频在线观看一区二区三区 | 午夜视频久久久久久| 视频一区视频二区中文| 久久精品国产一区二区| 国产一区二区免费看| 成人午夜在线播放| 一本色道久久综合狠狠躁的推荐| 欧美体内she精视频| 欧美一区二区三区免费在线看| 日韩一区二区免费在线观看| 久久久久99精品一区| 日韩美女啊v在线免费观看| 亚洲午夜视频在线观看| 日韩影院精彩在线| 国内精品免费**视频| 成人av在线一区二区| 在线看不卡av| 91精品国产免费久久综合| 久久综合色8888| 亚洲另类一区二区| 蜜臀av在线播放一区二区三区| 国产福利不卡视频| 91国产视频在线观看| 3d成人动漫网站| 亚洲国产精品二十页| 亚洲国产另类av| 国内成人精品2018免费看| av成人老司机| 欧美一级黄色片| 国产欧美一区二区精品性色 | 欧美一区二区三区白人| 欧美韩国日本综合| 亚洲123区在线观看| 国产成人av影院| 精品视频在线免费观看| 日本一区二区三区四区| 五月综合激情日本mⅴ| 不卡的电视剧免费网站有什么| 欧美高清视频www夜色资源网| 久久精品夜色噜噜亚洲a∨| 亚洲在线一区二区三区| 国产精品主播直播| 欧美酷刑日本凌虐凌虐| 国产精品短视频| 国产在线精品免费| 欧美亚一区二区| 欧美国产乱子伦| 蜜臀久久99精品久久久久宅男 | 免费看欧美美女黄的网站| 波多野结衣中文字幕一区 | 国产欧美日韩一区二区三区在线观看| 亚洲午夜三级在线| 不卡一区二区在线| 久久久综合精品| 免费视频一区二区| 在线一区二区三区做爰视频网站| 久久久久久久久久久久久久久99| 日本欧美一区二区三区乱码| 色综合天天在线| 中文在线一区二区| 黑人巨大精品欧美黑白配亚洲 | 国产精品网站在线播放| 精品在线免费观看| 欧美狂野另类xxxxoooo| 一区二区三区免费网站| 不卡视频免费播放| 久久久精品国产免大香伊 | 波波电影院一区二区三区| 日韩精品最新网址| 日韩影院在线观看| 777午夜精品免费视频| 一区二区三区波多野结衣在线观看| 粉嫩欧美一区二区三区高清影视| www一区二区| 美女诱惑一区二区| 日韩欧美色综合| 蜜桃视频一区二区| 日韩一级免费一区| 日本视频在线一区| 欧美一二区视频| 蜜臀av性久久久久蜜臀av麻豆| 88在线观看91蜜桃国自产| 日韩主播视频在线| 制服丝袜av成人在线看| 日韩国产精品久久久久久亚洲| 欧美三级电影一区| 午夜精品久久久久久不卡8050| 在线观看91视频| 亚洲成av人影院在线观看网| 欧美欧美欧美欧美首页| 免费在线看成人av| 久久午夜电影网| 国产精品一级片| 最新日韩在线视频| 91成人国产精品| 亚洲成人手机在线| 91精品国产色综合久久不卡电影| 人人精品人人爱| 精品精品国产高清一毛片一天堂| 久国产精品韩国三级视频| 久久久国产一区二区三区四区小说| 成人中文字幕在线| 一区二区三区中文字幕精品精品 | 国产欧美精品一区二区三区四区 | 亚洲精品写真福利| 欧美日韩视频在线观看一区二区三区 | 日本欧美一区二区| 欧美精品一区二区在线播放| 粉嫩绯色av一区二区在线观看| 自拍偷拍欧美精品| 欧美视频一区二区三区在线观看| 日本网站在线观看一区二区三区| 久久色在线视频| 91在线国产观看| 婷婷成人激情在线网| 久久久午夜精品| 色94色欧美sute亚洲线路二| 日本成人在线不卡视频| 国产亚洲一本大道中文在线| 色婷婷狠狠综合| 蜜臂av日日欢夜夜爽一区| 中文欧美字幕免费| 欧美日韩不卡在线| 国产91丝袜在线观看| 亚洲一区二区三区中文字幕在线 | 亚洲美女淫视频| 日韩欧美国产精品| 91欧美一区二区| 久久电影国产免费久久电影| 中文字幕中文字幕一区二区| 欧美日韩不卡在线| av午夜一区麻豆| 蜜芽一区二区三区| 亚洲色图在线播放| 2020国产精品| 欧美日韩日日摸| 成人免费看黄yyy456| 日韩av网站在线观看| 日韩一区中文字幕| 久久免费美女视频| 在线91免费看| 色综合天天综合在线视频| 韩国三级中文字幕hd久久精品| 亚洲激情校园春色| 国产欧美一区二区精品秋霞影院| 欧美日韩亚洲国产综合| 91丨九色porny丨蝌蚪| 国产精品中文字幕日韩精品 | 91国产丝袜在线播放| 国产一区二区女| 免费的成人av|