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

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

?? os_sem.c

?? lWIP是TCPIP的協議的源代碼。采用的是最新LWIP0.6.4版本。為了得到最佳性能
?? 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一区二区三区免费野_久草精品视频
亚洲一卡二卡三卡四卡无卡久久 | 精品国产青草久久久久福利| 亚洲精品国产第一综合99久久| 国产一区91精品张津瑜| 日韩欧美国产系列| 捆绑调教美女网站视频一区| 日韩午夜av电影| 国产一区视频网站| 2024国产精品| 91玉足脚交白嫩脚丫在线播放| 亚洲精品国产a| 日本精品一级二级| 麻豆国产欧美一区二区三区| 国产做a爰片久久毛片| 欧美高清精品3d| 成人动漫中文字幕| 亚洲午夜电影网| 久久久九九九九| 欧美亚洲日本一区| 国产大陆a不卡| 舔着乳尖日韩一区| 国产精品麻豆一区二区| av不卡在线播放| 日韩福利电影在线| 亚洲小说春色综合另类电影| 久久久综合激的五月天| 日韩视频一区二区| 欧美中文一区二区三区| 91视频免费播放| 高清不卡一区二区| 国产剧情一区二区三区| 免费一级片91| 日本vs亚洲vs韩国一区三区二区| 国产精品二三区| 国产精品人人做人人爽人人添| 久久人人97超碰com| 日韩视频免费观看高清完整版在线观看| 99国产精品国产精品毛片| 高清在线成人网| 成人av网址在线| 99久久婷婷国产精品综合| www.欧美日韩| 色婷婷精品久久二区二区蜜臀av| av亚洲精华国产精华| 99视频精品全部免费在线| 一本色道久久综合狠狠躁的推荐| 一本大道久久a久久精品综合| 91久久一区二区| 日韩一级完整毛片| 欧美国产乱子伦| 亚洲一区免费视频| 精品一区二区三区免费播放| 波多野结衣91| 欧美日韩一区久久| 亚洲欧美一区二区三区久本道91| 18成人在线视频| 日韩—二三区免费观看av| 国产69精品久久777的优势| 欧美色男人天堂| 久久亚洲私人国产精品va媚药| ...xxx性欧美| 精品系列免费在线观看| 日本国产一区二区| 久久九九全国免费| 奇米影视在线99精品| 97久久精品人人爽人人爽蜜臀| 日韩一区二区高清| 亚洲精品国产视频| 成人国产精品免费网站| 日韩一区二区免费视频| 视频一区视频二区中文字幕| 91网站在线观看视频| 久久综合色播五月| 国产一区二区看久久| 日韩欧美在线影院| 美国精品在线观看| 欧美一级欧美一级在线播放| 亚洲一区在线观看免费观看电影高清 | 在线观看免费成人| 中文字幕一区二区三区四区不卡| 国产精品亚洲视频| 国产午夜精品久久久久久免费视| 麻豆国产欧美日韩综合精品二区 | 中文字幕电影一区| 另类的小说在线视频另类成人小视频在线 | 国产一本一道久久香蕉| 精品国产免费视频| 丰满岳乱妇一区二区三区| 国产欧美一区二区精品忘忧草 | 国产精品夜夜嗨| 国产精品天美传媒| 91影视在线播放| 性做久久久久久| 久久免费视频色| 91在线观看视频| 日韩1区2区3区| 国产欧美精品一区aⅴ影院| 福利一区在线观看| 亚洲一区二区在线视频| 欧美一区二区三区视频在线观看 | 一本到高清视频免费精品| 亚洲一区二区av电影| 精品少妇一区二区三区在线视频| 国产白丝网站精品污在线入口 | 亚洲香肠在线观看| 久久久精品国产免大香伊| 欧美日韩另类国产亚洲欧美一级| 国产激情一区二区三区| 天天操天天色综合| 亚洲午夜精品久久久久久久久| 久久亚洲一区二区三区四区| 欧美性大战xxxxx久久久| 国产jizzjizz一区二区| 国产一区二三区| 日韩精品欧美精品| 亚洲午夜久久久久久久久电影网| 国产精品天干天干在观线 | 日韩午夜电影av| 欧美日本一区二区在线观看| 欧美亚州韩日在线看免费版国语版| 国产99久久久国产精品潘金网站| 经典三级一区二区| 毛片不卡一区二区| 国产一区二区女| 国产成人免费视频一区| 国产高清久久久久| 国产精品一区在线观看乱码| 国产福利91精品一区| 97se亚洲国产综合自在线不卡| 福利视频网站一区二区三区| eeuss鲁片一区二区三区| av一二三不卡影片| 欧美午夜一区二区| 日韩午夜精品电影| 亚洲国产成人午夜在线一区| 亚洲精品免费在线| 国产在线播放一区二区三区| 国产成人精品免费| 欧美色综合网站| 久久午夜电影网| 一区二区三区精品视频在线| 日本aⅴ免费视频一区二区三区 | 91精品国产全国免费观看| 欧美日韩精品欧美日韩精品 | 欧美日韩成人一区| 久久久影院官网| 日韩av午夜在线观看| 99精品一区二区| 久久影院午夜论| 亚洲午夜免费电影| 成人一区二区三区| 精品国产三级电影在线观看| 亚洲精品水蜜桃| 国产69精品一区二区亚洲孕妇| 欧美视频在线播放| 中文乱码免费一区二区| 精品一二三四在线| 欧美mv日韩mv亚洲| 日韩电影免费在线观看网站| 欧美日韩性生活| 午夜精品久久久久久不卡8050| yourporn久久国产精品| 久久毛片高清国产| 久久99热99| 久久精品视频一区二区三区| 麻豆精品一区二区| 在线不卡一区二区| 欧美96一区二区免费视频| 在线播放中文一区| 经典三级在线一区| 国产精品久久久久久亚洲毛片| 国产精一区二区三区| 久久伊99综合婷婷久久伊| 成人毛片在线观看| 亚洲男帅同性gay1069| 91精品国产麻豆| 国产精品资源在线看| 国产精品电影一区二区| 在线观看日韩电影| 麻豆国产一区二区| 欧美国产综合色视频| 欧美三级三级三级| 国产美女一区二区| 亚洲色图制服丝袜| 欧美zozozo| 91视频国产观看| 国产精品一二三四| 亚洲成人动漫在线观看| 国产精品美女久久福利网站| 欧美日韩电影在线播放| 白白色 亚洲乱淫| 久久精品国产久精国产爱| 亚洲一区二区三区免费视频| 久久久久一区二区三区四区| 欧洲av一区二区嗯嗯嗯啊| 成人小视频在线| 国产揄拍国内精品对白| 美女性感视频久久| 亚洲r级在线视频| 一区二区三区蜜桃|