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

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

?? os_sem.c

?? 一個輕量tcpip協議在移植在ucOS2系統上運行
?? 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一区二区三区免费野_久草精品视频
色综合久久88色综合天天6| 国产精品盗摄一区二区三区| 国产女主播一区| 午夜精品久久久久久久久| 国产成人精品www牛牛影视| 欧美性大战久久久久久久蜜臀 | 久久精品国产亚洲a| 99视频国产精品| 精品国产sm最大网站| 亚洲一区二区欧美激情| 国产mv日韩mv欧美| 久久欧美一区二区| 精品在线一区二区| 欧美日韩国产在线播放网站| ●精品国产综合乱码久久久久| 精品一区二区在线看| 4438x亚洲最大成人网| 亚洲宅男天堂在线观看无病毒| 成人精品一区二区三区中文字幕| 精品日韩一区二区三区 | 国产精品综合网| 日韩视频一区二区三区| 免费人成黄页网站在线一区二区 | 亚洲精品一区二区三区香蕉| 午夜亚洲福利老司机| 欧美午夜宅男影院| 亚洲福利一区二区| 欧美性猛交xxxx乱大交退制版| 一区二区视频在线看| 99re在线精品| 亚洲激情五月婷婷| 欧美做爰猛烈大尺度电影无法无天| 国产精品久久久久久久浪潮网站| 成人激情午夜影院| 亚洲国产成人一区二区三区| 成人激情动漫在线观看| 国产欧美日韩精品一区| www.性欧美| 亚洲乱码中文字幕| 91久久奴性调教| 亚洲成人综合网站| 5月丁香婷婷综合| 蜜桃精品视频在线观看| 久久亚洲春色中文字幕久久久| 国产一区欧美日韩| 国产精品三级久久久久三级| 不卡区在线中文字幕| 亚洲综合区在线| 宅男在线国产精品| 国内精品久久久久影院色| 国产午夜精品一区二区三区视频| 福利91精品一区二区三区| 中文字幕一区二区三区视频| 色婷婷精品久久二区二区蜜臂av | 精品欧美一区二区久久| 精品一区二区综合| 国产精品青草综合久久久久99| 97久久久精品综合88久久| 亚洲福利国产精品| 久久亚洲私人国产精品va媚药| 成人午夜在线播放| 亚洲国产另类av| 久久久久久毛片| 欧美中文字幕一区| 国产精品综合二区| 亚洲国产精品一区二区久久恐怖片| 欧美一区二区播放| av资源站一区| 麻豆国产91在线播放| 中文字幕一区二区三区在线播放 | 麻豆精品久久久| 91在线观看高清| 亚洲精选一二三| 欧美四级电影在线观看| 国产精品自产自拍| 一区二区三区在线视频观看58| 欧美成人精品二区三区99精品| 色综合天天综合在线视频| 国产精品亚洲一区二区三区妖精 | 高清在线成人网| 亚洲国产日韩精品| 中文一区二区在线观看| 欧美一级高清片在线观看| 91年精品国产| 国产成人在线视频网址| 日韩和欧美一区二区三区| 亚洲免费在线视频一区 二区| 日韩你懂的在线播放| 欧日韩精品视频| 99久免费精品视频在线观看| 国产精一区二区三区| 日韩av成人高清| 亚洲免费在线电影| 国产精品嫩草99a| 久久久99久久| 日韩一区二区三| 欧美日韩精品专区| 在线视频一区二区免费| 99riav一区二区三区| 国产成人久久精品77777最新版本| 日韩精品高清不卡| 亚洲一级二级三级| 一区二区三区欧美久久| 国产精品麻豆视频| 国产日本欧洲亚洲| 久久精品欧美一区二区三区不卡| 欧美成人女星排名| 精品99一区二区| 精品美女在线观看| 精品卡一卡二卡三卡四在线| 欧美一区二区三区免费视频 | 国产精品色哟哟| 国产亚洲精品7777| 国产色一区二区| 国产精品午夜久久| 专区另类欧美日韩| 中文字幕综合网| 尤物av一区二区| 亚洲精品国产视频| 亚洲一区二区视频在线观看| 亚洲一区二区三区四区在线 | 亚洲欧美视频在线观看| 亚洲日本va午夜在线影院| 亚洲欧美日韩人成在线播放| 一区二区三区日韩| 午夜成人免费视频| 黑人精品欧美一区二区蜜桃| 国产乱人伦偷精品视频不卡| 波多野结衣中文一区| 91性感美女视频| 欧美三级视频在线| 精品粉嫩超白一线天av| 国产色爱av资源综合区| 中文字幕av一区二区三区| 亚洲美女电影在线| 亚洲成a天堂v人片| 精品一区二区三区视频在线观看| 成人夜色视频网站在线观看| 色欧美片视频在线观看在线视频| 欧美性受极品xxxx喷水| 欧美mv和日韩mv的网站| 国产精品卡一卡二卡三| 亚洲国产精品久久艾草纯爱| 精品一区二区三区在线观看 | 亚洲黄一区二区三区| 亚洲成人777| 丁香啪啪综合成人亚洲小说 | 亚洲午夜精品17c| 免费不卡在线观看| av福利精品导航| 欧美一级二级三级蜜桃| 国产精品久久久久一区二区三区| 亚洲123区在线观看| 国产福利视频一区二区三区| 欧美亚洲动漫制服丝袜| 久久久久亚洲蜜桃| 五月激情综合婷婷| 成人伦理片在线| 91精品久久久久久蜜臀| 国产精品午夜电影| 久久精品国产999大香线蕉| 91久久久免费一区二区| 久久婷婷成人综合色| 五月婷婷综合激情| 99在线精品免费| 国产午夜精品一区二区三区嫩草| 午夜在线电影亚洲一区| 成人av影视在线观看| 日韩丝袜美女视频| 亚洲丰满少妇videoshd| 成人免费看视频| 精品99一区二区三区| 视频一区二区不卡| 在线免费观看视频一区| 欧美极品aⅴ影院| 久久超碰97中文字幕| 欧美日韩免费不卡视频一区二区三区| 国产精品乱人伦中文| 久久97超碰国产精品超碰| 欧美日韩日日摸| 亚洲精品一二三四区| jizzjizzjizz欧美| 国产女主播视频一区二区| 精品一二线国产| 欧美一级二级三级蜜桃| 日日摸夜夜添夜夜添国产精品 | 亚洲成人动漫精品| 欧美在线小视频| 亚洲一区二区三区四区五区黄| 91亚洲精品一区二区乱码| 国产精品国产精品国产专区不蜜 | 国产精品欧美极品| 国产精品456露脸| 国产欧美日韩中文久久| 国产91丝袜在线播放| 久久久亚洲国产美女国产盗摄| 精品一区二区三区视频 | 国产999精品久久久久久绿帽| 欧美成人精品福利| 久草中文综合在线|