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

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

?? os_sem.c

?? ep7312- ad轉換的源碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2001, 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                      */
        OS_EventWaitListInit(pevent);
    }
    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一区二区三区免费野_久草精品视频
91一区二区三区在线播放| 精品毛片乱码1区2区3区| 91精品国产免费| 国产精品国产三级国产普通话蜜臀 | 亚洲午夜电影在线| 久久av资源站| 色噜噜狠狠成人网p站| 精品国产免费久久| 午夜亚洲国产au精品一区二区 | 丝袜亚洲另类丝袜在线| 成人爱爱电影网址| 久久婷婷色综合| 免费观看在线色综合| 日本高清不卡视频| ...xxx性欧美| 成人影视亚洲图片在线| 91精品久久久久久久91蜜桃| 日韩毛片视频在线看| 国产精一区二区三区| 日韩一区二区在线看片| 亚洲午夜久久久久| 91麻豆swag| 亚洲欧洲在线观看av| 国产一区视频网站| 日韩一区二区免费视频| 亚洲不卡在线观看| 在线观看视频一区| 樱花草国产18久久久久| 波多野结衣中文字幕一区二区三区| 日韩精品一区国产麻豆| 免费成人你懂的| 欧美精品久久天天躁| 亚洲图片欧美一区| 91精彩视频在线| 一区二区三区国产精华| 色婷婷精品大在线视频| 综合久久久久综合| 91丨九色porny丨蝌蚪| 最好看的中文字幕久久| 91最新地址在线播放| 亚洲欧洲性图库| 91美女福利视频| 亚洲国产视频a| 欧美日韩视频第一区| 亚洲成人1区2区| 欧美一区二区三区系列电影| 日日欢夜夜爽一区| 精品盗摄一区二区三区| 国产麻豆9l精品三级站| 中文字幕不卡三区| 97国产一区二区| 亚洲国产精品久久久男人的天堂 | 婷婷中文字幕一区三区| 91精品国产一区二区| 久久精品免费看| 久久久久国产精品免费免费搜索| 国产成人亚洲精品狼色在线| 国产精品福利一区二区三区| 一本色道a无线码一区v| 天天影视涩香欲综合网| 亚洲精品一区二区三区四区高清| 成人精品一区二区三区四区| 亚洲美女视频在线观看| 欧美日韩国产经典色站一区二区三区 | 麻豆精品国产传媒mv男同| 久久一夜天堂av一区二区三区| 国产激情91久久精品导航| 亚洲欧洲精品成人久久奇米网| 欧美午夜精品免费| 国产一区二区三区四| 亚洲男同1069视频| 欧美一区二区三区免费大片| 国产精品中文字幕日韩精品| 亚洲欧美色一区| 欧美一区二区三区色| 国产1区2区3区精品美女| 亚洲国产成人av| 欧美—级在线免费片| 91麻豆精品久久久久蜜臀| 99久久久精品| 狠狠色丁香久久婷婷综合丁香| 亚洲免费在线视频| 久久久久88色偷偷免费| 欧美精品丝袜久久久中文字幕| av亚洲精华国产精华| 激情图片小说一区| 天天色天天爱天天射综合| 国产精品国产三级国产普通话99| 精品免费视频.| 7777女厕盗摄久久久| 色综合亚洲欧洲| 国产电影一区二区三区| 日本视频免费一区| 亚洲一区二区三区中文字幕 | 2023国产精品自拍| 91麻豆视频网站| 波多野结衣中文字幕一区| 日本午夜精品视频在线观看 | 欧美视频在线一区| 国产成人免费视频一区| 久久99精品久久久| 亚洲成人第一页| 国产精品视频免费看| 日韩一区二区在线观看视频播放| www.亚洲国产| 国产一区二区免费在线| 一区二区三区在线免费播放| 国产精品传媒入口麻豆| 26uuu另类欧美亚洲曰本| 欧美日韩电影在线播放| youjizz久久| 国产精品亚洲一区二区三区妖精| 亚洲一区二区三区视频在线播放| 亚洲乱码日产精品bd| 欧美激情中文字幕| 久久综合av免费| 日韩一区二区在线观看| 欧美体内she精高潮| 成人黄页毛片网站| 91免费观看国产| 成人国产电影网| 国产精品一区二区无线| 久久福利资源站| 裸体在线国模精品偷拍| 五月激情综合网| 寂寞少妇一区二区三区| 蜜桃一区二区三区在线| 天天做天天摸天天爽国产一区| 亚洲在线视频免费观看| 一区二区三区资源| 中文字幕一区二区视频| 欧美国产1区2区| 国产欧美精品在线观看| 国产婷婷色一区二区三区四区| 国产亚洲综合在线| 欧美韩国日本不卡| 一区二区三区久久久| 亚洲尤物视频在线| 午夜欧美视频在线观看| 亚洲成人精品影院| 日本午夜一区二区| 成人在线综合网| 91色在线porny| 欧美在线视频日韩| 欧美日韩成人一区| 日韩欧美电影一二三| 69堂成人精品免费视频| 久久久久免费观看| 国产精品每日更新| 一区二区激情视频| 日日夜夜精品视频天天综合网| 青青草成人在线观看| 九色|91porny| 波多野结衣中文一区| 91丨porny丨国产| 欧美区一区二区三区| 日韩三级中文字幕| 久久毛片高清国产| 亚洲国产精品嫩草影院| 免费的成人av| 国产成人精品影视| 91国偷自产一区二区开放时间| 69堂成人精品免费视频| 18成人在线观看| 日韩黄色免费网站| 成人v精品蜜桃久久一区| 在线精品视频免费播放| 欧美tickling挠脚心丨vk| 亚洲人精品午夜| 久久97超碰色| 色综合久久99| 精品国产91乱码一区二区三区| 综合在线观看色| 国产高清成人在线| 欧美日韩国产综合久久| www成人在线观看| 亚洲永久精品国产| 国产在线视频一区二区| 99麻豆久久久国产精品免费 | 91浏览器在线视频| 欧美岛国在线观看| 亚洲一区在线看| 国产传媒欧美日韩成人| 日韩欧美不卡一区| 悠悠色在线精品| 国产xxx精品视频大全| 欧美群妇大交群的观看方式| 日本一区二区高清| 看电影不卡的网站| 欧美日本在线播放| 亚洲天堂精品在线观看| 国产一区二区三区视频在线播放| 欧美性猛交xxxx黑人交| 亚洲黄一区二区三区| 成人性色生活片| 久久综合给合久久狠狠狠97色69| 日韩avvvv在线播放| 在线精品视频免费观看| 久久久久久久性| 捆绑调教美女网站视频一区|