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

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

?? os_sem.c

?? 能夠直接在hf44b0板子上跑的uCOS,已經(jīng)測(cè)試通過(guò),在板子上跑的很流暢.
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(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);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
    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                */
#if OS_EVENT_NAME_SIZE > 0
        (void)strcpy(pevent->OSEventName, "?");
#endif
        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);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    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) {
#if OS_EVENT_NAME_SIZE > 0
                 (void)strcpy(pevent->OSEventName, "?");   /* Unknown name                             */
#endif
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
                 pevent->OSEventCnt  = 0;
                 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);
             }
#if OS_EVENT_NAME_SIZE > 0
             (void)strcpy(pevent->OSEventName, "?");       /* Unknown name                             */
#endif
             OS_EventWaitListInit(pevent);                 /* Clear out the wait list                  */
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
             pevent->OSEventCnt  = 0;
             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;

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人成人成人在线视频| 国产精品日韩精品欧美在线| 色成人在线视频| 99久久婷婷国产综合精品电影| 国内精品第一页| 国产成人免费av在线| 国产激情91久久精品导航| 高清在线成人网| 丁香婷婷综合色啪| 色综合婷婷久久| 久久综合色8888| 国产亚洲福利社区一区| 国产精品不卡在线观看| 亚洲一区二区三区爽爽爽爽爽| 亚洲综合免费观看高清完整版在线| 亚洲伊人伊色伊影伊综合网| 亚洲成av人片| 经典三级在线一区| 国产成人免费视频一区| 色呦呦一区二区三区| 欧美视频一区二区三区四区| 91精品国产综合久久精品| 精品国产91乱码一区二区三区 | 日韩欧美黄色影院| xfplay精品久久| 亚洲美女屁股眼交3| 日韩电影一区二区三区四区| 国产乱理伦片在线观看夜一区| 白白色 亚洲乱淫| 欧美老年两性高潮| 国产喂奶挤奶一区二区三区| 亚洲丝袜另类动漫二区| 毛片av一区二区| 99re在线精品| 欧美精品一区二区三区高清aⅴ| 国产精品毛片大码女人| 日韩二区三区四区| 91在线小视频| 欧美精品一区二区久久婷婷| 亚洲欧美日韩国产另类专区| 人人爽香蕉精品| 97超碰欧美中文字幕| 欧美电影免费观看高清完整版在 | 色婷婷精品大视频在线蜜桃视频| 欧美日韩情趣电影| 欧美韩日一区二区三区四区| 亚洲成人激情av| 99久久精品一区二区| 精品卡一卡二卡三卡四在线| 亚洲在线一区二区三区| 成人影视亚洲图片在线| 欧美一区三区四区| 一区二区三区.www| 成人激情av网| 国产日韩av一区二区| 奇米影视一区二区三区小说| 欧美亚州韩日在线看免费版国语版| 欧美大尺度电影在线| 亚洲va韩国va欧美va| 91视频免费观看| 国产精品视频一二三区| 国产乱妇无码大片在线观看| 欧美不卡一二三| 日本成人中文字幕| 欧美一区二区视频在线观看2020| 亚洲精品国产视频| 色综合久久久久综合体| 国产精品久久久99| av一区二区三区在线| 国产精品成人在线观看| 成人性色生活片| 国产拍揄自揄精品视频麻豆| 精品一区二区久久久| 欧美va亚洲va国产综合| 久久99久久久欧美国产| 日韩小视频在线观看专区| 爽爽淫人综合网网站 | 视频一区二区不卡| 欧美日韩免费在线视频| 午夜精品爽啪视频| 欧美日韩一区高清| 日本伊人色综合网| 日韩三级伦理片妻子的秘密按摩| 秋霞影院一区二区| 精品成a人在线观看| 国产精品综合av一区二区国产馆| 久久久久久久久久久99999| 成人一级片网址| 亚洲视频你懂的| 欧美日韩国产a| 美女脱光内衣内裤视频久久网站| 精品国产亚洲在线| 99在线精品一区二区三区| 中文字幕中文乱码欧美一区二区| 色伊人久久综合中文字幕| 亚洲一区二区三区在线播放| 欧美老肥妇做.爰bbww视频| 久久精品99国产精品| 欧美国产综合一区二区| 色婷婷综合久久久久中文| 午夜精品久久久久| 国产欧美日韩视频在线观看| 99精品一区二区| 日日摸夜夜添夜夜添国产精品| 欧美xxxxx裸体时装秀| av成人老司机| 天天色 色综合| 亚洲国产精品99久久久久久久久| 色哟哟精品一区| 国产一区二区主播在线| 亚洲女同女同女同女同女同69| 欧美一区二区视频在线观看2022| 国产成人啪免费观看软件| 亚洲国产日韩a在线播放| 337p日本欧洲亚洲大胆精品| 92国产精品观看| 激情偷乱视频一区二区三区| 一区二区久久久久久| 精品国产一区二区三区四区四 | 国产一区二区三区久久悠悠色av| 一区精品在线播放| 日韩欧美国产综合一区| 日本黄色一区二区| 国产福利一区在线| 国产乱码精品一区二区三区av| 一二三区精品视频| 中文无字幕一区二区三区 | 欧美zozo另类异族| 欧美视频中文一区二区三区在线观看| 久久狠狠亚洲综合| 亚洲444eee在线观看| 最新日韩在线视频| 国产女同互慰高潮91漫画| 欧美一区二区三区在线视频| 色综合咪咪久久| 成人网在线免费视频| 激情综合五月天| 免费观看91视频大全| 亚洲不卡av一区二区三区| 日韩一区在线播放| 中文字幕av一区二区三区高| 亚洲精品一区二区精华| 欧美一区二区三区性视频| 欧美日韩国产在线播放网站| 色老汉一区二区三区| 一本一本大道香蕉久在线精品 | 99久久婷婷国产综合精品电影| 国产麻豆一精品一av一免费 | 亚洲电影激情视频网站| 亚洲女性喷水在线观看一区| 成人欧美一区二区三区1314| 中文字幕的久久| 国产精品人妖ts系列视频| 国产欧美一区视频| 国产精品天天摸av网| 欧美极品美女视频| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 久久久精品日韩欧美| 精品久久久久久亚洲综合网| 日韩午夜在线观看视频| 欧美xxxxx裸体时装秀| 亚洲视频你懂的| 亚洲欧美日韩中文字幕一区二区三区 | 精品嫩草影院久久| 久久久美女毛片| 中文字幕成人网| 亚洲日本韩国一区| 天堂蜜桃一区二区三区| 美女视频免费一区| 国产高清久久久久| 91浏览器在线视频| 欧美日韩国产a| 欧美不卡一区二区三区| 国产视频一区在线观看| 亚洲丝袜美腿综合| 天堂蜜桃一区二区三区| 麻豆91免费看| 成人丝袜18视频在线观看| 色综合天天性综合| 91精品久久久久久蜜臀| 久久婷婷国产综合精品青草| 中文字幕乱码亚洲精品一区| 尤物在线观看一区| 久久99久久久久| 99久久综合国产精品| 欧美精品日韩一本| 国产精品久久久久久久久免费丝袜 | 99久久伊人网影院| 91精品国产综合久久精品app | 成人网页在线观看| 欧美日韩一区视频| 中文字幕一区免费在线观看 | 精品播放一区二区| 亚洲午夜久久久久| 激情图区综合网| 欧美精品色综合| 综合久久久久久| 国产一区二区在线看| 欧美精品一卡二卡| 亚洲欧美一区二区三区国产精品|