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

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

?? os_sem.c

?? 實現ucos任務調度時保存LCD上的顯示信息
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                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) KCREENTRANT
{
#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) KCREENTRANT
{
#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                */
        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) KCREENTRANT
{
#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日本精品| 精品国产sm最大网站| 国产精品久久看| 夜夜嗨av一区二区三区四季av | 一区二区三区日本| 91免费视频网址| 一区二区三区不卡在线观看 | 色欧美片视频在线观看| 国产欧美日韩精品在线| 午夜电影一区二区| 欧美三级中文字幕| 亚洲精品成人少妇| 色综合久久久久| 日韩毛片一二三区| 不卡的av中国片| 国产精品黄色在线观看| 91色婷婷久久久久合中文| 国产精品久久久久影视| 99视频精品在线| 一区二区三区四区蜜桃| 精品1区2区3区| 激情五月播播久久久精品| 精品国产一区二区三区久久久蜜月| 日韩av一二三| 91麻豆精品国产91久久久资源速度| 亚洲高清视频中文字幕| 欧美猛男超大videosgay| 天涯成人国产亚洲精品一区av| 日韩一区二区三区电影 | 日韩精品三区四区| 久久久精品国产免大香伊| 99久久久国产精品免费蜜臀| 亚洲男同1069视频| 亚洲精品一区二区三区精华液 | 丝袜美腿高跟呻吟高潮一区| 中文字幕精品一区二区三区精品 | 成人综合婷婷国产精品久久免费| 亚洲欧美偷拍另类a∨色屁股| 欧美色综合天天久久综合精品| 蜜桃91丨九色丨蝌蚪91桃色| 中文字幕不卡在线播放| 91丝袜国产在线播放| 激情av综合网| 亚洲美女偷拍久久| 欧美电影免费观看高清完整版在 | 亚洲人成在线播放网站岛国 | 日韩国产在线观看一区| 国产欧美一区二区精品仙草咪 | 国产日韩高清在线| 日韩一区二区视频| 99热国产精品| 免费观看91视频大全| 五月婷婷综合激情| 天天综合天天综合色| 日本亚洲三级在线| 久久www免费人成看片高清| 一区视频在线播放| 一区二区三区中文字幕电影| 国产亚洲欧美激情| 欧美一级视频精品观看| 91日韩精品一区| 亚洲成人综合视频| 中文字幕日本乱码精品影院| 久久综合久久综合亚洲| 在线不卡中文字幕| 欧美综合在线视频| 成人一级片网址| 精品一区二区免费视频| 中文字幕一区av| 欧美成人精品福利| 精品日韩欧美在线| 欧美一级搡bbbb搡bbbb| 欧美日韩国产乱码电影| 欧美日韩综合在线| 91激情在线视频| 波多野结衣一区二区三区| 国产69精品久久99不卡| 91视频国产观看| 国产aⅴ精品一区二区三区色成熟| 丁香桃色午夜亚洲一区二区三区| 精品系列免费在线观看| 成人精品视频.| 欧洲色大大久久| 欧美综合天天夜夜久久| 日韩欧美资源站| 国产区在线观看成人精品 | 亚洲人快播电影网| 美女诱惑一区二区| 国产在线精品一区二区夜色| 秋霞影院一区二区| 国产精品99久| 91蝌蚪国产九色| 欧美一区二区福利在线| 精品久久久久久综合日本欧美 | 麻豆91小视频| 色综合色综合色综合色综合色综合 | 免费在线观看精品| 欧美日本韩国一区| 国产精品美女久久久久久久久久久 | 国产欧美日韩另类视频免费观看| 久久www免费人成看片高清| 欧美日韩一级黄| 日产欧产美韩系列久久99| 欧美丰满少妇xxxbbb| 亚洲综合丁香婷婷六月香| 欧美日韩日日夜夜| 看电视剧不卡顿的网站| 精品国产乱子伦一区| 粉嫩av一区二区三区粉嫩 | 亚洲综合在线视频| 欧美一级xxx| 日韩在线一二三区| 91精品免费在线| 九九久久精品视频| 欧美一级一级性生活免费录像| 中文字幕av一区二区三区高| 国产乱一区二区| 中文一区一区三区高中清不卡| 麻豆91在线观看| 国产调教视频一区| 成人午夜激情片| 亚洲视频精选在线| 7777精品伊人久久久大香线蕉经典版下载 | 欧美成人精品3d动漫h| 午夜成人免费电影| 欧美精品一区二区三区蜜桃| 91免费观看视频| 国内国产精品久久| 亚洲综合激情网| 久久亚洲综合色| 欧美老女人在线| 国产激情视频一区二区三区欧美 | 亚洲超碰精品一区二区| 精品福利一区二区三区| 欧美午夜不卡视频| 在线视频欧美精品| 97se狠狠狠综合亚洲狠狠| 精品在线观看免费| 视频一区二区国产| 亚洲视频在线一区| 国产精品视频一二| 久久午夜国产精品| 精品国产乱码久久久久久免费| 欧美mv日韩mv国产网站| 欧美日韩一区 二区 三区 久久精品| 国产在线精品一区二区夜色| 亚洲一区成人在线| 亚洲欧美日韩国产一区二区三区| 国产色综合久久| 26uuu色噜噜精品一区| 亚洲精品一区二区三区精华液| 日韩手机在线导航| 精品噜噜噜噜久久久久久久久试看 | 色综合中文综合网| 久久―日本道色综合久久| 2017欧美狠狠色| 欧美国产一区在线| 一区免费观看视频| 丝袜亚洲精品中文字幕一区| 蜜臀av性久久久久av蜜臀妖精| 1024成人网| 久久精品99国产精品日本| 豆国产96在线|亚洲| 欧美丝袜第三区| 国产视频一区不卡| 亚洲自拍偷拍网站| 成人激情免费视频| 在线观看日韩电影| 日韩三级电影网址| 国产精品欧美一级免费| 一区二区欧美国产| 美日韩黄色大片| 91在线观看美女| 日韩一区二区三区四区| 亚洲免费伊人电影| 日韩精品一区第一页| 国产精品亚洲人在线观看| 91浏览器在线视频| 精品国产百合女同互慰| 亚洲午夜av在线| 不卡在线观看av| 精品美女在线播放| 午夜欧美电影在线观看| 国产91精品露脸国语对白| 欧美哺乳videos| 日本欧美在线观看| 欧美影院一区二区三区| 成人免费视频在线观看| 国产成人午夜片在线观看高清观看| 欧美无砖专区一中文字| 亚洲一区免费视频| 欧美视频精品在线观看| 亚洲最色的网站| 91精品午夜视频| 免费在线视频一区|