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

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

?? os_sem.c

?? 在Freescale16位單片機MC9s12dp256上移植了J1939源碼和操作系統(ucOSII)。
?? 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 "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)
{
    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一区二区| 老司机免费视频一区二区三区| 中国色在线观看另类| 亚洲综合成人在线视频| 国产91色综合久久免费分享| 日韩欧美国产午夜精品| 午夜精品久久久久久久久| 欧美在线你懂的| 亚洲日本乱码在线观看| 99re视频精品| 中文字幕日本乱码精品影院| 高清久久久久久| 国产精品成人免费| 北岛玲一区二区三区四区| 亚洲国产精品成人综合| 粉嫩13p一区二区三区| 自拍偷拍国产精品| 在线一区二区观看| 性做久久久久久免费观看欧美| 欧美在线观看视频一区二区 | 国产精品视频麻豆| 精品视频一区二区不卡| 亚洲色图视频免费播放| 欧美日韩在线直播| 免费高清不卡av| 中文字幕不卡在线| 欧美亚洲国产一区二区三区va| 婷婷综合在线观看| 国产情人综合久久777777| 成人黄色777网| 日韩高清一区在线| 国产精品视频一二三区| 91麻豆精品国产91久久久久| 激情久久久久久久久久久久久久久久| 久久人人爽人人爽| 色婷婷久久久久swag精品 | 中文字幕一区二区三区精华液| 91福利小视频| 国产剧情一区在线| 日本三级韩国三级欧美三级| 成人免费一区二区三区视频| 黄色小说综合网站| 亚洲妇熟xx妇色黄| 99精品偷自拍| 亚洲va欧美va人人爽| 国产欧美一区二区三区沐欲| 日韩一区二区电影在线| 一本一道波多野结衣一区二区| 国产真实乱子伦精品视频| 舔着乳尖日韩一区| 一区二区三区精品视频| 亚洲成人av一区二区三区| 国产偷国产偷亚洲高清人白洁 | 91年精品国产| av在线不卡电影| av影院午夜一区| 成人国产一区二区三区精品| 成人美女视频在线观看| 成人精品gif动图一区| 成人app下载| 色久优优欧美色久优优| 91网站在线播放| 欧洲精品中文字幕| 91麻豆精品国产91久久久久| 日韩欧美www| 国产亚洲综合色| 亚洲欧洲另类国产综合| 艳妇臀荡乳欲伦亚洲一区| 日韩影院免费视频| 韩国视频一区二区| 成人丝袜18视频在线观看| 不卡一区二区三区四区| 欧美最猛性xxxxx直播| 综合久久给合久久狠狠狠97色| 久久久噜噜噜久噜久久综合| 国产精品不卡一区| 丝袜美腿亚洲一区二区图片| 久久精品999| 在线观看日韩电影| 26uuu另类欧美亚洲曰本| 亚洲视频一区二区在线观看| 日韩不卡手机在线v区| bt7086福利一区国产| 日韩免费电影一区| 亚洲国产中文字幕| 成av人片一区二区| 日韩精品一区二区三区老鸭窝| 国产精品美女www爽爽爽| 青青草精品视频| 在线观看免费一区| 中文字幕在线一区二区三区| 日韩精品欧美成人高清一区二区| 成人免费毛片aaaaa**| 精品噜噜噜噜久久久久久久久试看 | 日韩欧美国产电影| 激情国产一区二区| 欧美一区二区三区免费| 成人免费一区二区三区视频| 国产成人免费9x9x人网站视频| 91精品国产黑色紧身裤美女| 亚洲国产成人va在线观看天堂| 本田岬高潮一区二区三区| 中文字幕av一区二区三区| 狠狠色丁香九九婷婷综合五月| 日韩精品一区二区三区中文精品| 亚洲一区二区三区免费视频| 日本道精品一区二区三区| 亚洲欧美精品午睡沙发| 9久草视频在线视频精品| 国产精品人妖ts系列视频| 国产91在线看| 亚洲最新在线观看| 欧美一区二区三区不卡| 极品美女销魂一区二区三区| 久久九九久久九九| 处破女av一区二区| 亚洲一区二区美女| 日韩视频免费直播| 国产激情视频一区二区在线观看| 久久久久久一二三区| av激情亚洲男人天堂| 亚洲国产精品久久人人爱| 日韩欧美激情四射| 成年人网站91| 老司机免费视频一区二区| 国产精品天天看| 欧美日韩免费视频| 国产精品99久久久久久久女警 | 欧美日韩精品欧美日韩精品一| 日本精品视频一区二区三区| 天天操天天综合网| 国产精品黄色在线观看| 欧美裸体一区二区三区| av男人天堂一区| 国产一区二区导航在线播放| 一级特黄大欧美久久久| 久久久久九九视频| 欧美日韩国产天堂| 成人国产在线观看| 国产一区二区在线免费观看| 亚洲va国产va欧美va观看| 亚洲欧洲精品一区二区三区| 欧美精品一区二区久久久| 欧美精品视频www在线观看 | 成人福利视频在线| 国产精品一区在线观看你懂的| 亚洲综合一区在线| 亚洲婷婷在线视频| 国产精品久线在线观看| 国产婷婷精品av在线| 久久久久99精品一区| xfplay精品久久| 2024国产精品| 国产亚洲女人久久久久毛片| 久久久久久亚洲综合影院红桃| 精品久久久久久无| 欧美韩日一区二区三区四区| 午夜视频在线观看一区| 亚洲国产wwwccc36天堂| 午夜精品福利视频网站| 免费人成精品欧美精品 | 欧美精彩视频一区二区三区| 国产亚洲一区二区三区四区| 欧美激情资源网| 亚洲精品国产无天堂网2021| 亚洲一区二区三区激情| 人人狠狠综合久久亚洲| 成人中文字幕在线| 在线视频欧美区| 精品少妇一区二区三区视频免付费| 日韩你懂的在线播放| 中文字幕亚洲在| 蜜臀久久久久久久| 成人免费高清视频| 欧美人牲a欧美精品| 国产女人18水真多18精品一级做| 综合色中文字幕| 精品一区二区成人精品| 99久久777色| 精品剧情v国产在线观看在线| 亚洲天堂精品视频| 国产精品一区二区在线观看不卡| 91在线视频网址| 精品国产sm最大网站免费看| 亚洲另类色综合网站| 国产精品亚洲一区二区三区妖精| 在线中文字幕一区| 蜜桃91丨九色丨蝌蚪91桃色| 一本久道久久综合中文字幕| 欧美成va人片在线观看| 一区二区三区四区在线| 911国产精品| 久久精品视频免费| 亚洲人成人一区二区在线观看| 亚洲永久免费视频| 色婷婷综合久久久中文一区二区| 久久综合成人精品亚洲另类欧美| 午夜国产精品一区| 欧洲av一区二区嗯嗯嗯啊| 亚洲免费在线视频一区 二区|