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

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

?? os_sem.c

?? 在別處找到的一些uc/os-ii的一些資料
?? 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)
{
   
    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)
{
   
    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)
{
   
    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一区二区三区免费野_久草精品视频
国产欧美日韩精品a在线观看| 国产精品三级av在线播放| 精品少妇一区二区三区日产乱码| 久久日韩精品一区二区五区| 中文字幕一区二区三区不卡| 秋霞午夜av一区二区三区| 成人毛片在线观看| 91精品麻豆日日躁夜夜躁| 国产精品青草久久| 日本欧美久久久久免费播放网| 国产成人啪免费观看软件| 欧美日韩一区二区在线视频| 国产偷国产偷精品高清尤物| 日韩在线一区二区三区| 成人午夜碰碰视频| 国产视频一区不卡| 狠狠色综合日日| 欧美一区二区三区免费| 亚洲国产精品自拍| 99国产精品国产精品久久| 日韩欧美不卡在线观看视频| 久久丝袜美腿综合| 亚洲黄色片在线观看| 99精品久久免费看蜜臀剧情介绍| 国产日韩欧美高清| 亚洲综合丝袜美腿| 大尺度一区二区| 日韩欧美的一区| 国产综合久久久久影院| 日韩精品一区二区三区在线播放| 亚洲成在线观看| 欧美日本韩国一区二区三区视频| 一区二区欧美国产| 欧美亚洲国产一区在线观看网站| 亚洲欧美国产77777| 在线欧美小视频| 亚洲一二三四久久| 欧美三级韩国三级日本三斤| 亚洲欧美日韩精品久久久久| 91猫先生在线| 午夜精品久久久久久久久久| 欧美肥大bbwbbw高潮| 久久成人免费电影| 国产日韩欧美激情| 成人福利视频网站| 亚洲午夜精品17c| 欧美成人国产一区二区| 国产69精品久久99不卡| 亚洲精品国产精品乱码不99| 91国模大尺度私拍在线视频| 五月天中文字幕一区二区| 日韩精品一区二区三区视频在线观看| 国产一区二区不卡老阿姨| 亚洲国产精品99久久久久久久久| 91在线精品一区二区| 青青青伊人色综合久久| 亚洲女同一区二区| 一本久道久久综合中文字幕| 日本中文字幕一区二区有限公司| 欧美一卡二卡在线| a级精品国产片在线观看| 婷婷国产在线综合| 日本一区二区动态图| 欧美午夜免费电影| 福利91精品一区二区三区| 日韩精品一级中文字幕精品视频免费观看 | 成人精品视频网站| 中文字幕一区日韩精品欧美| 欧美精品久久一区| 色悠悠久久综合| 粉嫩aⅴ一区二区三区四区 | 日韩欧美成人午夜| 在线观看区一区二| 99国产欧美另类久久久精品| 韩国av一区二区| 另类专区欧美蜜桃臀第一页| 一区二区三区av电影| 亚洲免费资源在线播放| 国产欧美一区二区在线观看| 欧美片网站yy| 欧美日韩在线免费视频| 成人av在线影院| www.综合网.com| aaa欧美色吧激情视频| 欧美日韩一区二区三区在线看| 国产一区二区三区免费看| 精品亚洲国产成人av制服丝袜| 五月激情综合婷婷| 日韩精品成人一区二区三区| 五月婷婷色综合| 成人久久18免费网站麻豆| 亚洲大尺度视频在线观看| 丝瓜av网站精品一区二区 | 亚洲欧美视频一区| 一区二区在线观看免费视频播放| 亚洲欧美激情插 | 另类小说色综合网站| 99视频有精品| 在线观看日韩av先锋影音电影院| 欧洲精品在线观看| 欧美一区三区二区| 久久精品欧美日韩精品| 自拍偷在线精品自拍偷无码专区 | 国产精品传媒入口麻豆| 亚洲精品中文字幕乱码三区| 婷婷激情综合网| 久久午夜羞羞影院免费观看| 欧美高清你懂得| 久久网这里都是精品| 亚洲一区二区三区视频在线| 国产一区二区三区四| 欧美日韩国产精选| 欧美—级在线免费片| 日本va欧美va欧美va精品| 欧美成人a视频| 丝袜亚洲另类欧美| 色久优优欧美色久优优| 久久久久久久精| 蓝色福利精品导航| 欧美三级欧美一级| 亚洲麻豆国产自偷在线| 高清免费成人av| 久久久99精品免费观看不卡| 麻豆免费看一区二区三区| 欧美一区二区在线看| 91麻豆国产自产在线观看| 26uuu成人网一区二区三区| 日韩国产在线观看一区| 欧美色大人视频| 日韩美女一区二区三区四区| 亚洲一区二区3| 欧美二区三区的天堂| www.日韩精品| 国产精品丝袜黑色高跟| 成人激情免费视频| 中文字幕中文字幕中文字幕亚洲无线| 国产一区欧美日韩| 亚洲精品一区二区三区在线观看| 麻豆国产一区二区| 久久人人爽爽爽人久久久| 国产美女精品在线| 国产目拍亚洲精品99久久精品| 国产精品99久久久久久久女警| 久久久久久**毛片大全| 成人美女在线视频| 1024成人网| 欧美日韩一本到| 韩国av一区二区| 色成人在线视频| 蜜桃视频在线一区| 中文字幕av一区二区三区免费看| 91免费看视频| 免费久久精品视频| 中文字幕av一区二区三区免费看 | 丁香亚洲综合激情啪啪综合| 日韩欧美在线1卡| 丝袜脚交一区二区| 国产午夜久久久久| 欧美午夜宅男影院| 国产综合色视频| 洋洋av久久久久久久一区| 欧美一区二区福利在线| 99在线精品视频| 日韩电影免费在线看| 国产精品二三区| 日韩三级视频在线观看| 色香蕉成人二区免费| 精品国产91乱码一区二区三区| 99精品视频一区二区| 中文字幕亚洲欧美在线不卡| 日韩免费观看高清完整版| 91免费看视频| 粉嫩蜜臀av国产精品网站| 日本aⅴ亚洲精品中文乱码| 国产精品无码永久免费888| 日本伊人色综合网| 久久综合色之久久综合| 欧美喷水一区二区| 欧美性一级生活| 91美女福利视频| 9久草视频在线视频精品| 国产剧情在线观看一区二区| 日韩激情中文字幕| 亚洲一级不卡视频| 亚洲老妇xxxxxx| 亚洲日本在线a| 亚洲精品中文字幕乱码三区| 国产精品久久国产精麻豆99网站 | 亚洲人成精品久久久久久| 日本一区二区免费在线观看视频| 欧美精品一区二区三区高清aⅴ| 久久99在线观看| 精品亚洲免费视频| 国产精品538一区二区在线| 国产精品系列在线播放| 国产电影精品久久禁18| 国产成人亚洲综合色影视| 国产成人精品一区二| 2023国产精品| 精品美女一区二区|