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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_sem.c

?? UCOS移植到LPC2148上使用:有6個簡單任務(wù): 功能: 任務(wù)0 (P1.8 燈循環(huán) 亮 滅 ) 任務(wù)1 (P1.9 燈循環(huán) 亮 滅 ) 任務(wù)2 (P1.20 燈循環(huán) 亮 滅 ) 任務(wù)3
?? 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);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
最新国产成人在线观看| 欧美mv日韩mv国产网站| 亚洲视频免费在线| 99国产精品久久久久| 亚洲视频在线一区| 日本高清不卡视频| 亚洲国产欧美在线| 555www色欧美视频| 久久99深爱久久99精品| 久久精品亚洲一区二区三区浴池| 精品一区二区三区视频在线观看 | 国产精品无遮挡| 99在线精品一区二区三区| 亚洲精品老司机| 3d动漫精品啪啪一区二区竹菊 | 亚洲欧美国产三级| 欧美人xxxx| 国产精品一区二区视频| 亚洲男女毛片无遮挡| 欧美群妇大交群中文字幕| 精品中文字幕一区二区| 国产精品免费视频网站| 欧美色区777第一页| 麻豆精品视频在线观看视频| 欧美国产一区二区在线观看| 日本精品视频一区二区三区| 琪琪一区二区三区| 国产精品久久久久久亚洲伦| 欧美猛男超大videosgay| 国内精品不卡在线| 亚洲伦理在线免费看| 欧美成人三级电影在线| 99re在线精品| 国内精品国产三级国产a久久| 樱花影视一区二区| 精品福利一区二区三区| 91黄色免费观看| 国产乱码一区二区三区| 亚洲成人免费观看| 国产精品视频免费| 日韩视频免费观看高清完整版 | 欧美午夜电影一区| 国产成人综合网| 视频一区二区不卡| 中文字幕在线不卡视频| 精品国一区二区三区| 欧美在线短视频| 成人精品一区二区三区中文字幕| 青青草一区二区三区| 亚洲精品视频在线观看免费 | 亚洲第一会所有码转帖| 2019国产精品| 制服丝袜激情欧洲亚洲| 91视频你懂的| 丁香啪啪综合成人亚洲小说 | 爽好多水快深点欧美视频| 国产精品美女久久久久久久久久久| 欧美一区二区三区在线观看视频| 色婷婷香蕉在线一区二区| 国产91在线|亚洲| 国内欧美视频一区二区| 美女爽到高潮91| 丝袜a∨在线一区二区三区不卡| 亚洲激情一二三区| 综合色中文字幕| 中文字幕一区二区三区在线播放 | 一二三四社区欧美黄| 国产精品久久久久久久久图文区| 久久综合狠狠综合久久综合88| 91精品在线免费观看| 欧美精品色综合| 欧美色图在线观看| 欧美性生活影院| 欧美视频在线一区| 色婷婷亚洲一区二区三区| 一本大道av一区二区在线播放| aaa亚洲精品一二三区| 成人免费视频国产在线观看| 国产成人免费视频网站| 国产精品伊人色| 国产精品白丝jk白祙喷水网站| 国产一区二区三区| 国产成人鲁色资源国产91色综| 麻豆精品精品国产自在97香蕉| 日本一不卡视频| 久久精品国产成人一区二区三区| 久久电影网电视剧免费观看| 激情六月婷婷综合| 国产成人精品免费网站| 成人免费三级在线| 91蜜桃传媒精品久久久一区二区| 色美美综合视频| 欧美日韩三级一区二区| 日韩欧美在线综合网| 日韩精品一区二区三区在线播放| 精品1区2区在线观看| 国产午夜精品一区二区三区视频| 国产精品美女一区二区三区 | 日韩精品一区二区三区视频| 精品av综合导航| 国产精品蜜臀av| 一区二区三区日韩| 日韩二区三区在线观看| 国产美女精品人人做人人爽| 成人精品国产一区二区4080| 日本久久一区二区三区| 欧美一级视频精品观看| 久久精品综合网| 亚洲自拍与偷拍| 久久国产日韩欧美精品| 99久久综合精品| 欧美一区二区三区四区在线观看| 久久嫩草精品久久久精品| 樱桃视频在线观看一区| 老司机午夜精品| 91亚洲国产成人精品一区二三 | 欧美日韩国产影片| 精品av久久707| 亚洲精品国产无套在线观| 老司机精品视频一区二区三区| 国产成人精品亚洲午夜麻豆| 在线观看免费亚洲| 久久久久久久精| 亚洲.国产.中文慕字在线| 国产91丝袜在线播放九色| 精品视频一区 二区 三区| 国产欧美日韩麻豆91| 亚洲高清免费视频| 成人av影院在线| 日韩精品一区二区三区中文精品| 国产精品电影院| 美腿丝袜亚洲综合| 91成人免费网站| 国产午夜精品福利| 日本v片在线高清不卡在线观看| 91在线porny国产在线看| 精品国产一区二区三区忘忧草| 夜夜精品浪潮av一区二区三区| 国产精品一二三| 日韩免费一区二区三区在线播放| 亚洲精品国产a| caoporn国产精品| 久久新电视剧免费观看| 免费成人你懂的| 91久久国产最好的精华液| 国产精品免费视频网站| 国精产品一区一区三区mba桃花 | 欧美精彩视频一区二区三区| 免费成人在线视频观看| 欧美日韩久久一区二区| 1024国产精品| 成人动漫av在线| 国产女人aaa级久久久级| 国产综合久久久久久久久久久久| 欧美日韩高清一区二区不卡| 亚洲精品视频在线看| 91一区二区在线| 亚洲欧美综合在线精品| 成人黄色777网| 中文字幕av在线一区二区三区| 国产精品一区久久久久| 2020日本不卡一区二区视频| 美脚の诱脚舐め脚责91| 欧美一级电影网站| 男人的j进女人的j一区| 日韩一区二区在线观看| 日韩精品成人一区二区在线| 69精品人人人人| 日韩中文字幕麻豆| 在线综合+亚洲+欧美中文字幕| 肉肉av福利一精品导航| 69成人精品免费视频| 麻豆精品国产91久久久久久| 日韩欧美在线影院| 精品亚洲成av人在线观看| 欧美精品一区二区三| 国产高清不卡一区二区| 日本一区二区视频在线观看| a级高清视频欧美日韩| 亚洲欧美国产毛片在线| 欧美午夜不卡在线观看免费| 亚洲高清在线精品| 337p亚洲精品色噜噜| 久久不见久久见免费视频7| 久久精品男人天堂av| 成人午夜电影网站| 亚洲欧洲无码一区二区三区| 日本精品视频一区二区| 日韩va亚洲va欧美va久久| 精品剧情在线观看| 国产不卡视频一区| 亚洲精品成人天堂一二三| 欧美日本在线一区| 激情亚洲综合在线| 中文字幕一区三区| 欧美群妇大交群中文字幕| 国产一区二区三区| 一区二区三区中文字幕在线观看| 在线电影欧美成精品| 国产在线国偷精品产拍免费yy|