亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产喷白浆一区二区三区| 精品成人一区二区三区| 成人av手机在线观看| 国产成人av电影在线播放| 国产91精品一区二区| 菠萝蜜视频在线观看一区| 99久久精品国产毛片| 欧美亚洲一区三区| 欧美性感一区二区三区| 日韩一区二区在线看片| 精品免费视频.| 国产目拍亚洲精品99久久精品| 国产亚洲va综合人人澡精品 | 在线成人免费观看| 欧美男男青年gay1069videost | 亚洲欧美日韩国产综合在线| 伊人色综合久久天天人手人婷| 亚洲欧美日韩系列| 欧美a级一区二区| 成人免费看视频| 欧美日韩精品专区| 久久久精品免费免费| 一区二区三区波多野结衣在线观看 | 欧美一区二区三区视频在线观看 | 色综合天天综合| 欧美另类一区二区三区| 国产日韩欧美激情| 亚洲韩国精品一区| 大美女一区二区三区| 91成人在线精品| 久久婷婷成人综合色| 亚洲精品日韩一| 国产精品1区二区.| 欧美精品黑人性xxxx| 中文字幕 久热精品 视频在线| 亚洲一级二级在线| 国产91清纯白嫩初高中在线观看 | 欧美自拍丝袜亚洲| 精品国产电影一区二区| 一区二区三区在线免费播放| 久久激五月天综合精品| 欧美性猛片aaaaaaa做受| 久久久不卡影院| 日韩电影免费在线看| 在线免费不卡电影| 国产婷婷色一区二区三区在线| 亚洲成人免费看| 一本到不卡免费一区二区| 久久亚洲捆绑美女| 蜜臀久久99精品久久久久久9| 成人小视频在线| 久久久久久亚洲综合影院红桃| 亚洲成人精品一区| 色综合久久久久| 国产女主播一区| 国内精品嫩模私拍在线| 欧美日韩高清在线播放| 自拍视频在线观看一区二区| 国产成人在线视频网址| 久久蜜桃av一区精品变态类天堂 | 欧美极品aⅴ影院| 韩国女主播一区| 日韩欧美成人午夜| 蜜臀久久99精品久久久久久9| 欧美日韩国产经典色站一区二区三区| 亚洲精品va在线观看| 91视频在线观看| 中文字幕视频一区二区三区久| 国产福利一区二区| 中文字幕欧美国产| 国产91精品一区二区| 欧美激情中文不卡| 粉嫩绯色av一区二区在线观看 | 欧美一级日韩一级| 日韩电影一区二区三区四区| 69成人精品免费视频| 日本成人超碰在线观看| 日韩精品专区在线| 韩国成人精品a∨在线观看| 精品久久久久一区| 国产高清亚洲一区| 日韩码欧中文字| 欧美日韩黄色一区二区| 日本成人在线看| 国产欧美一区二区精品性色| 成人小视频在线| 亚洲综合一区二区| 欧美一区二区大片| 国产精品一区二区无线| 中文字幕日韩欧美一区二区三区| av网站一区二区三区| 一区二区三区成人| 日韩欧美国产综合| 成人激情免费网站| 一二三四区精品视频| 日韩午夜激情电影| 99久免费精品视频在线观看| 一区二区三区免费在线观看| 51精品秘密在线观看| 懂色av一区二区三区免费观看| 日韩伦理av电影| 日韩三级精品电影久久久| 国产91色综合久久免费分享| 亚洲一区二区三区美女| 久久久久久夜精品精品免费| 在线欧美一区二区| 久久99国产精品免费| 亚洲乱码国产乱码精品精的特点 | 国产一区二区三区蝌蚪| 亚洲精品水蜜桃| 久久中文娱乐网| 欧美在线观看禁18| 成人网男人的天堂| 久久精工是国产品牌吗| 一区二区三区产品免费精品久久75| 欧美一级片在线看| 欧美亚洲日本国产| 成人永久免费视频| 老司机精品视频在线| 亚洲激情av在线| 国产欧美日韩三级| 精品国产露脸精彩对白| 欧美视频中文一区二区三区在线观看| 国产成人自拍高清视频在线免费播放| 亚洲大尺度视频在线观看| 国产精品另类一区| 久久久久久久久久看片| 欧美一区二区三区性视频| 欧美色综合网站| av电影在线观看不卡| 国产精品自拍三区| 狠狠网亚洲精品| 免费在线观看视频一区| 亚洲成av人片一区二区三区| 国产精品久久福利| 中文字幕精品三区| 国产三区在线成人av| 26uuu亚洲| 欧美精品一区二区久久久 | 国产一区二区剧情av在线| 天堂久久久久va久久久久| 亚洲一区二区三区免费视频| 一区二区三区不卡在线观看 | 欧美哺乳videos| 91精品福利在线一区二区三区 | 亚洲成人先锋电影| 亚洲二区视频在线| 日韩精品视频网| 日韩高清欧美激情| 久久99久久久欧美国产| 麻豆成人91精品二区三区| 蜜臀国产一区二区三区在线播放| 天天操天天干天天综合网| 午夜电影网亚洲视频| 日韩av高清在线观看| 日av在线不卡| 国内久久婷婷综合| va亚洲va日韩不卡在线观看| 91香蕉视频在线| 在线观看视频一区二区| 欧美精品一卡二卡| 亚洲图片另类小说| 亚洲精品五月天| 丝袜国产日韩另类美女| 免费在线看一区| 国产精品888| 色婷婷亚洲综合| 欧美一区二区三区系列电影| 2022国产精品视频| 国产精品不卡一区二区三区| 夜夜亚洲天天久久| 精品一区二区三区影院在线午夜 | 在线观看欧美日本| 5月丁香婷婷综合| 日韩精品中午字幕| 椎名由奈av一区二区三区| 天天射综合影视| 成人午夜激情在线| 欧美日韩一区二区在线观看视频| 欧美不卡一区二区| 亚洲精品国产精华液| 免费成人美女在线观看| 成人精品国产免费网站| 欧美日韩国产经典色站一区二区三区| 精品国产乱码久久久久久夜甘婷婷 | 日韩欧美激情一区| 国产精品电影院| 蜜桃一区二区三区在线| 99re这里只有精品视频首页| 91精品国产综合久久蜜臀| 国产精品每日更新| 美女精品一区二区| 在线看日本不卡| 中文字幕国产一区二区| 麻豆视频观看网址久久| 在线观看日韩av先锋影音电影院| 久久综合九色综合97婷婷女人| 亚洲成人激情av| 波多野结衣视频一区| 久久香蕉国产线看观看99|