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

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

?? os_sem.c

?? 在Visual C++環(huán)境下實(shí)現(xiàn)uC/OS-II的移植
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*
*********************************************************************************************************
*                                                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);

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久综合色之久久综合| 国产农村妇女毛片精品久久麻豆| 看电影不卡的网站| 国产精品视频免费| 欧美一区二区视频在线观看2020 | 日本黄色一区二区| 麻豆久久久久久久| 亚洲美女淫视频| 国产视频视频一区| 欧美一区二区三区在线视频 | 国产电影精品久久禁18| 亚洲午夜日本在线观看| 国产精品人成在线观看免费 | 日本成人在线电影网| 亚洲天天做日日做天天谢日日欢| 日韩欧美在线1卡| 欧美日韩亚洲综合在线| 成人av在线资源网| 国产高清不卡二三区| 久久精品国产第一区二区三区| 一区二区三区欧美亚洲| 国产精品国产三级国产aⅴ中文| 欧美mv日韩mv国产| 91精品国产综合久久久久| 欧亚一区二区三区| 色综合久久天天| 97久久精品人人爽人人爽蜜臀| 国产精品综合网| 久久99精品久久久久久| 日韩av一区二区三区| 亚洲成人手机在线| 亚洲黄色在线视频| 亚洲欧美日韩在线播放| 中文字幕在线不卡视频| 国产精品久久久久永久免费观看| 亚洲国产人成综合网站| 亚洲色图都市小说| 国产精品国产三级国产有无不卡| 国产亚洲欧美激情| 欧美激情自拍偷拍| 久久久久九九视频| 国产午夜精品一区二区 | 久久久久久久综合色一本| 日韩精品最新网址| 精品对白一区国产伦| www激情久久| 久久精品亚洲精品国产欧美kt∨| 久久综合久久综合九色| 久久久久久久久久久99999| 久久在线免费观看| 国产欧美日韩精品一区| 欧美激情一区二区在线| 国产精品久久久久久亚洲伦| 日韩一区在线看| 一区二区在线观看视频| 亚洲成人手机在线| 蜜臀久久久久久久| 国产高清不卡一区二区| 成人av资源站| 欧美撒尿777hd撒尿| 91精品国产综合久久久久久| 26uuu国产电影一区二区| 中文无字幕一区二区三区| 国产精品视频麻豆| 亚洲丰满少妇videoshd| 日本麻豆一区二区三区视频| 国产美女娇喘av呻吟久久| 成人福利电影精品一区二区在线观看| 99久久婷婷国产精品综合| 国产精品国产三级国产普通话蜜臀 | 欧美一区二区三区色| 久久综合色8888| 日韩美女视频一区| 日本美女一区二区三区| 国产成人丝袜美腿| 欧美性受xxxx黑人xyx性爽| 欧美一区欧美二区| 国产清纯在线一区二区www| 亚洲激情中文1区| 美国三级日本三级久久99| 岛国一区二区三区| 欧美日韩第一区日日骚| 久久久噜噜噜久噜久久综合| 亚洲精品视频一区二区| 裸体在线国模精品偷拍| 99精品视频在线观看免费| 欧美精品高清视频| 国产精品美女久久福利网站| 天天做天天摸天天爽国产一区| 国产一区二三区| 欧美午夜免费电影| 久久久激情视频| 亚洲国产美国国产综合一区二区| 国产激情一区二区三区| 精品视频在线免费看| 国产欧美精品一区二区三区四区| 亚洲一卡二卡三卡四卡无卡久久| 国产在线精品一区二区不卡了| 色偷偷久久人人79超碰人人澡| 精品久久久久一区二区国产| 亚洲欧美另类小说| 国产精品一区二区无线| 欧美日韩aaaaaa| 亚洲人成网站影音先锋播放| 九色porny丨国产精品| 欧美色电影在线| 亚洲欧洲精品一区二区精品久久久 | 欧美一区二区三区系列电影| 亚洲色图视频网| 国产成人夜色高潮福利影视| 91精品久久久久久久久99蜜臂| 中文字幕中文字幕在线一区| 国产毛片精品国产一区二区三区| 欧美日韩免费观看一区二区三区| 国产精品嫩草影院av蜜臀| 蜜臀av一区二区在线免费观看| 色就色 综合激情| 亚洲视频一区二区在线| 国产综合色视频| 精品久久人人做人人爽| 五月天激情小说综合| 日本韩国精品在线| 亚洲素人一区二区| 不卡在线观看av| 久久精品男人的天堂| 精品伊人久久久久7777人| 8x8x8国产精品| 日韩二区三区四区| 欧美日本一道本在线视频| 成人精品国产一区二区4080| 精品国产青草久久久久福利| 免费高清在线视频一区·| 欧美福利视频一区| 亚洲h在线观看| 欧美日韩电影在线播放| 午夜电影网一区| 欧美日韩一区二区三区在线看| 亚洲一区二区在线播放相泽| 日本韩国欧美一区二区三区| 亚洲精品国产品国语在线app| 97久久精品人人做人人爽50路| 中文字幕亚洲在| 91免费版pro下载短视频| 亚洲视频电影在线| 欧美伊人久久大香线蕉综合69| 亚洲激情成人在线| 欧美日韩一区 二区 三区 久久精品| 亚洲综合色网站| 欧美精品久久天天躁| 日本最新不卡在线| 欧美v国产在线一区二区三区| 狠狠色丁香久久婷婷综合丁香| 26uuuu精品一区二区| 成人免费不卡视频| 亚洲狼人国产精品| 欧美伦理电影网| 麻豆国产欧美一区二区三区| 久久久久久麻豆| 97se狠狠狠综合亚洲狠狠| 一区二区三区在线视频播放| 欧美美女喷水视频| 黄一区二区三区| 国产精品免费观看视频| 欧洲在线/亚洲| 免费看欧美女人艹b| 国产午夜精品福利| 91浏览器打开| 视频在线在亚洲| 欧美精品一区视频| av激情综合网| 亚洲va欧美va人人爽| 精品福利二区三区| 99久久综合色| 水蜜桃久久夜色精品一区的特点 | 国产精品免费网站在线观看| 一本一本大道香蕉久在线精品| 亚洲gay无套男同| 欧美精品一区二区三区高清aⅴ | 欧美高清dvd| 国产**成人网毛片九色| 伊人夜夜躁av伊人久久| 欧美一级二级三级蜜桃| 成人国产在线观看| 婷婷六月综合亚洲| 欧美激情在线看| 欧美精品久久一区二区三区| 国产老女人精品毛片久久| 亚洲精品写真福利| 久久综合久久综合九色| 欧美性大战久久| 国产成人午夜精品5599| 亚洲已满18点击进入久久| 国产亚洲一区二区三区四区| 欧美三级电影在线看| 粉嫩蜜臀av国产精品网站| 婷婷成人综合网| 亚洲男人的天堂网| 国产人久久人人人人爽| 5566中文字幕一区二区电影| 一本久久精品一区二区|