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

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

?? os_sem.c

?? Turbo C 3.0 + UCOS2 + UCGUI PC學(xué)習(xí)版本
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
/*
*********************************************************************************************************
*                                                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
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产高清成人在线| 亚洲少妇屁股交4| 日韩成人av影视| 欧美一区二区在线播放| 奇米影视一区二区三区小说| 日韩精品中文字幕一区 | 亚洲视频一二三| 91麻豆成人久久精品二区三区| 中文字幕欧美一| 色狠狠综合天天综合综合| 亚洲v中文字幕| 日韩亚洲欧美中文三级| 激情综合色综合久久| 日本一区二区三级电影在线观看 | 91麻豆免费观看| 夜夜爽夜夜爽精品视频| 欧美另类高清zo欧美| 精品一区二区综合| 中文字幕第一区二区| 91国在线观看| 久久99国产精品久久99果冻传媒| 久久精品视频在线免费观看| av在线不卡网| 日本午夜精品视频在线观看 | 91精品国产色综合久久不卡蜜臀| 久久精品国产精品亚洲综合| 日本一区二区三区视频视频| 在线观看日韩精品| 精品一区二区日韩| 一区二区中文字幕在线| 91精品久久久久久蜜臀| 丁香亚洲综合激情啪啪综合| 亚洲国产视频直播| 久久一日本道色综合| 欧美亚洲日本一区| 国产精品1区2区3区在线观看| 一区二区三区精品在线观看| 亚洲精品一区二区三区影院| eeuss鲁片一区二区三区| 日本特黄久久久高潮| 1000部国产精品成人观看| 日韩久久久精品| 在线观看av一区二区| 国产高清无密码一区二区三区| 亚洲欧洲制服丝袜| 久久综合丝袜日本网| 欧美酷刑日本凌虐凌虐| 91亚洲精品久久久蜜桃网站 | 激情综合色丁香一区二区| 国产精品久久久久影院色老大 | 欧美高清在线精品一区| 在线成人免费视频| 在线观看日产精品| 成人动漫一区二区| 麻豆一区二区三| 偷拍一区二区三区四区| 亚洲欧美日本在线| 国产精品久久久久四虎| 久久蜜桃av一区二区天堂| 日韩一区国产二区欧美三区| 欧美日韩一区二区三区在线看 | 欧美日韩精品专区| 色综合色综合色综合色综合色综合 | 成人开心网精品视频| 麻豆国产精品官网| 午夜一区二区三区视频| 一区二区不卡在线播放| 亚洲欧美日韩一区| 最新中文字幕一区二区三区| 国产精品色婷婷| 国产精品乱人伦中文| 中文字幕av在线一区二区三区| 久久精品这里都是精品| 日韩精品一区二区三区视频播放| 制服丝袜一区二区三区| 91精品黄色片免费大全| 欧美一区二区视频在线观看2022 | 国产激情偷乱视频一区二区三区 | 奇米一区二区三区| 日本系列欧美系列| 日本欧美韩国一区三区| 久久国内精品视频| 美女视频黄频大全不卡视频在线播放| 日韩黄色免费电影| 久久国产人妖系列| 国产九九视频一区二区三区| 国产99精品视频| 91色视频在线| 欧美色窝79yyyycom| 欧美丰满高潮xxxx喷水动漫| 91精品国产欧美一区二区18| 精品美女在线观看| 久久午夜老司机| 国产精品家庭影院| 亚洲国产综合人成综合网站| 日韩1区2区日韩1区2区| 九九**精品视频免费播放| 国产精品一区二区你懂的| 成人天堂资源www在线| 色综合久久久久综合| 欧美精品视频www在线观看| 欧美成人伊人久久综合网| 久久精品视频免费观看| 18成人在线视频| 视频精品一区二区| 国产精品538一区二区在线| 91啪亚洲精品| 日韩欧美精品三级| 国产精品护士白丝一区av| 午夜久久福利影院| 国产高清不卡一区| 在线观看免费亚洲| 久久天天做天天爱综合色| 亚洲视频在线观看三级| 蜜桃久久久久久| 91同城在线观看| 精品美女一区二区| 18欧美乱大交hd1984| 久久精品国产一区二区| 成人开心网精品视频| 91精品婷婷国产综合久久| 中文字幕日韩一区二区| 六月丁香婷婷久久| 97精品国产97久久久久久久久久久久| 91精品国产一区二区三区蜜臀| 中文字幕制服丝袜成人av | 欧美亚洲国产一区二区三区va| 精品久久国产97色综合| 一区二区三区日本| 国产一区二区日韩精品| 欧美日韩一区二区电影| 国产精品福利一区| 精品写真视频在线观看| 欧美在线你懂的| 久久久久久久久免费| 香蕉久久夜色精品国产使用方法 | 亚洲综合免费观看高清完整版| 韩国理伦片一区二区三区在线播放| 91福利视频久久久久| 中文在线一区二区| 极品尤物av久久免费看| 69久久夜色精品国产69蝌蚪网| 亚洲欧美区自拍先锋| 成人中文字幕合集| 久久久国产综合精品女国产盗摄| 五月婷婷激情综合网| 99视频国产精品| 日本一区二区成人| 国产精品1区二区.| 欧美精品一区二区三区视频| 婷婷综合另类小说色区| 欧美影视一区在线| 亚洲综合在线视频| 97aⅴ精品视频一二三区| 欧美国产日韩亚洲一区| 国产成人自拍网| 国产午夜精品一区二区| 国产一区二区三区综合| 2019国产精品| 国产一区二区在线视频| 久久综合国产精品| 精品一区精品二区高清| 日韩视频一区二区在线观看| 水蜜桃久久夜色精品一区的特点| 在线视频国内一区二区| 亚洲国产一区视频| 欧美老女人在线| 日本va欧美va瓶| 欧美不卡一二三| 狠狠色丁香九九婷婷综合五月| 日韩午夜电影av| 老司机精品视频一区二区三区| 精品日韩一区二区| 国产福利电影一区二区三区| 中文字幕av资源一区| 91视频在线观看| 亚洲v精品v日韩v欧美v专区| 精品视频在线视频| 日本不卡一二三区黄网| 精品国产污污免费网站入口| 国产美女在线观看一区| 国产农村妇女精品| 91丝袜高跟美女视频| 亚洲国产日韩一区二区| 在线成人av网站| 国产精品中文有码| 亚洲欧洲性图库| 欧美人与z0zoxxxx视频| 日本在线观看不卡视频| 久久免费视频一区| 91视频www| 日韩中文字幕区一区有砖一区 | 亚洲日韩欧美一区二区在线| 欧美日韩国产乱码电影| 蜜臀精品久久久久久蜜臀 | 久久久久青草大香线综合精品| 成人性生交大合| 亚洲一区二区三区小说| 欧美电视剧免费观看| 99久久精品国产一区|