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

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

?? os_sem.c

?? 基于GE00 實驗系統開發板的實驗指導用途
?? 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);
    }
#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)
{
#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                */
#if OS_EVENT_NAME_SIZE > 0
        (void)strcpy(pevent->OSEventName, "?");
#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)
{
#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);
    }
#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 > 0
                 (void)strcpy(pevent->OSEventName, "?");   /* Unknown name                             */
#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    */
                 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
#if OS_EVENT_NAME_SIZE > 0
             (void)strcpy(pevent->OSEventName, "?");       /* Unknown name                             */
#endif
             OS_EventWaitListInit(pevent);                 /* Clear out the wait list                  */
             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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜在线成人av| 91色乱码一区二区三区| 粉嫩高潮美女一区二区三区 | 国产午夜精品一区二区| 亚洲免费av网站| 狠狠狠色丁香婷婷综合激情| 色婷婷激情综合| 国产精品视频在线看| 日韩1区2区日韩1区2区| 91社区在线播放| 国产欧美精品国产国产专区| 免费在线观看精品| 欧美亚洲禁片免费| 亚洲欧美日韩中文播放| 国产白丝网站精品污在线入口| 8x8x8国产精品| 一区二区三区四区精品在线视频| 国产a级毛片一区| 亚洲精品一线二线三线无人区| 亚洲成av人**亚洲成av**| 色综合久久综合网欧美综合网| 国产日韩欧美一区二区三区乱码| 久久精品国产99国产精品| 91精品午夜视频| 日韩福利电影在线观看| 欧美日韩一卡二卡| 亚洲国产精品久久人人爱蜜臀| 成人avav影音| 国产精品久久久久精k8| 国产在线视视频有精品| 久久亚洲综合色| 国产二区国产一区在线观看| 337p日本欧洲亚洲大胆精品 | 欧美色图第一页| 一个色综合av| 欧美大胆一级视频| 美国十次综合导航| 日韩中文字幕麻豆| 91精品国产黑色紧身裤美女| 天堂资源在线中文精品| 7777精品伊人久久久大香线蕉超级流畅| 亚洲精品国产一区二区精华液| 色悠久久久久综合欧美99| 亚洲美女偷拍久久| 欧美另类变人与禽xxxxx| 日韩中文欧美在线| 精品国精品国产| 成人av综合在线| 亚洲激情男女视频| 欧美一区二区三区白人| 久草在线在线精品观看| 久久久电影一区二区三区| 不卡的看片网站| 一区二区理论电影在线观看| 欧美久久一二区| 国产黄人亚洲片| 一区二区三区四区在线播放| 欧美肥大bbwbbw高潮| 韩国女主播一区二区三区| 国产精品麻豆视频| 欧美人与禽zozo性伦| 国产剧情在线观看一区二区 | 精品久久人人做人人爰| 国产jizzjizz一区二区| 亚洲精品日日夜夜| 欧美videossexotv100| www.亚洲色图| 久久国产免费看| 亚洲免费在线视频| 精品国产乱码久久久久久浪潮| 97久久精品人人爽人人爽蜜臀| 午夜精品福利一区二区三区蜜桃| 久久久激情视频| 制服.丝袜.亚洲.中文.综合| 大尺度一区二区| 日韩精品一级中文字幕精品视频免费观看 | 欧美久久一区二区| 成人福利在线看| 日韩精品一级中文字幕精品视频免费观看 | 丝袜国产日韩另类美女| 国产色婷婷亚洲99精品小说| 欧美午夜电影一区| 成人手机电影网| 免费不卡在线观看| 一区二区三区欧美日| 国产香蕉久久精品综合网| 欧美系列亚洲系列| 99久久99精品久久久久久 | 亚洲国产成人av| 中文字幕日韩一区| 26uuuu精品一区二区| 538prom精品视频线放| 99re成人精品视频| 懂色一区二区三区免费观看| 老司机免费视频一区二区三区| 亚洲精品ww久久久久久p站| 久久精品日韩一区二区三区| 日韩一级二级三级| 欧美喷水一区二区| 欧美体内she精高潮| 99re在线精品| 91社区在线播放| 99精品久久久久久| av日韩在线网站| 99精品在线免费| www.欧美亚洲| 99久久精品国产导航| 不卡视频免费播放| 粉嫩久久99精品久久久久久夜| 国产成人在线视频网站| 激情综合色丁香一区二区| 蜜臀av性久久久久蜜臀av麻豆| 亚洲国产综合色| 亚瑟在线精品视频| 日韩高清在线电影| 免费人成在线不卡| 久久se精品一区精品二区| 麻豆成人久久精品二区三区红| 日本欧美一区二区三区乱码| 日韩国产精品久久久久久亚洲| 亚洲高清在线视频| 美日韩一级片在线观看| 激情另类小说区图片区视频区| 久久电影国产免费久久电影| 国产一区在线视频| 丰满亚洲少妇av| 91蝌蚪porny九色| 精品视频在线看| 日韩一级精品视频在线观看| 精品成人a区在线观看| 国产欧美精品一区二区色综合朱莉| 久久久99精品久久| 中文字幕视频一区二区三区久| 亚洲日本一区二区| 亚洲国产成人va在线观看天堂| 日韩国产在线观看| 国产精品白丝av| 色综合天天综合网天天看片| 欧美性色黄大片手机版| 这里只有精品电影| 久久久高清一区二区三区| 中文字幕在线免费不卡| 亚洲大片免费看| 国内精品免费在线观看| 色综合天天综合网天天看片| 欧美日韩精品一区二区三区蜜桃 | 韩国av一区二区三区在线观看| 成人性生交大片免费看在线播放| av成人免费在线观看| 欧美日韩一区二区三区免费看| 精品美女一区二区| 亚洲欧美另类小说| 久久se这里有精品| 色丁香久综合在线久综合在线观看| 777午夜精品视频在线播放| 久久九九影视网| 午夜av一区二区三区| 国产高清精品在线| 欧美日韩精品久久久| 日本一区二区综合亚洲| 亚洲va国产va欧美va观看| 国产精品1024久久| 91精品国产aⅴ一区二区| 国产精品无人区| 麻豆免费看一区二区三区| 91视频免费看| 337p粉嫩大胆噜噜噜噜噜91av| 亚洲在线视频网站| 成人免费va视频| 日韩一区二区三区视频| 亚洲精品日日夜夜| 成人黄色软件下载| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 国产精品灌醉下药二区| 久久国产欧美日韩精品| 欧美日韩免费观看一区三区| 国产精品女人毛片| 黄色小说综合网站| 欧美一级欧美一级在线播放| 一区二区三区在线视频观看| 福利一区福利二区| 久久婷婷一区二区三区| 欧美aaaaa成人免费观看视频| 在线观看91精品国产入口| 国产亚洲va综合人人澡精品| 久久福利资源站| 日韩免费视频线观看| 丝袜美腿高跟呻吟高潮一区| 91国偷自产一区二区三区观看| 国产精品免费网站在线观看| 国产精品1区二区.| 精品久久久久香蕉网| 午夜电影久久久| 欧美日韩一区二区电影| 一二三区精品福利视频| 色94色欧美sute亚洲线路二| 亚洲色图视频网站| 99久久久久免费精品国产| 国产精品久久看| 99精品视频在线播放观看|