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

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

?? os_sem.c

?? ucosii下的arm9LCD程序
?? 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)
{
#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                      */
        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)
{
#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高清| 欧美亚男人的天堂| 国产麻豆91精品| 精品久久国产97色综合| 欧美一区二区啪啪| 成年人午夜久久久| 亚洲综合在线电影| 91原创在线视频| 欧美成人福利视频| 91蜜桃网址入口| 青青草原综合久久大伊人精品优势| 久久久精品国产99久久精品芒果 | 精品亚洲aⅴ乱码一区二区三区| 久久精品这里都是精品| 精品乱码亚洲一区二区不卡| 蜜臀久久久久久久| 一区二区三区蜜桃网| 久久精品人人做人人爽97| 精品视频一区二区三区免费| 99久久精品免费看国产免费软件| 激情六月婷婷久久| 日韩av网站在线观看| 亚洲一区欧美一区| 亚洲人亚洲人成电影网站色| 国产亚洲综合色| 久久亚洲一区二区三区明星换脸| 91精品国产综合久久久久久漫画| 色婷婷一区二区| 在线观看日韩国产| 色呦呦一区二区三区| jvid福利写真一区二区三区| 国产剧情在线观看一区二区 | 日本一不卡视频| 亚洲国产欧美在线| 亚洲激情男女视频| 亚洲免费观看高清完整版在线观看 | 亚洲国产精品嫩草影院| 日韩伦理av电影| 亚洲日本va午夜在线电影| 日韩毛片精品高清免费| 综合久久给合久久狠狠狠97色| 中文字幕亚洲成人| 综合久久久久综合| 一二三区精品视频| 亚洲自拍另类综合| 亚洲123区在线观看| 日韩成人一级片| 美女视频一区在线观看| 另类小说欧美激情| 国产美女主播视频一区| 国产乱子轮精品视频| 国产成人综合在线观看| 国产高清在线精品| 成人精品视频一区二区三区尤物| 国产一区二区三区美女| 高清视频一区二区| 成人深夜视频在线观看| 色综合久久99| 欧美日韩另类一区| 欧美电视剧免费全集观看| 精品久久久久久亚洲综合网| 国产日产欧美一区二区三区| 中文av一区特黄| 亚洲另类一区二区| 日韩激情在线观看| 国产乱码精品一品二品| av成人老司机| 欧美日韩综合一区| 3d成人动漫网站| 久久在线免费观看| 中文字幕中文字幕中文字幕亚洲无线| 亚洲人成影院在线观看| 日本欧美韩国一区三区| 国产精品一区一区三区| 成人网男人的天堂| 欧美网站一区二区| 精品欧美一区二区三区精品久久| 国产免费成人在线视频| 一区二区三区小说| 国产一区二区不卡在线| 色综合久久66| 精品盗摄一区二区三区| 亚洲精品乱码久久久久久黑人| 美女精品自拍一二三四| www.欧美亚洲| 在线成人高清不卡| 国产精品成人在线观看| 日韩成人一级片| 色综合久久综合网欧美综合网| 日韩午夜三级在线| 一区二区三区高清不卡| 国产精品99久| 欧美日韩国产一级二级| 国产精品网站在线| 成人性生交大片免费看中文 | 美女精品一区二区| 91丨porny丨户外露出| 日韩精品专区在线影院观看| 亚洲精品国产第一综合99久久| 精品制服美女丁香| 精品视频全国免费看| 亚洲欧美怡红院| 激情综合五月婷婷| 欧美日韩一区二区三区在线看 | 一区二区在线观看视频| 国产一区二区三区四区在线观看| 欧美日韩一区成人| 综合久久综合久久| 国产河南妇女毛片精品久久久| 欧美精品aⅴ在线视频| 中文字幕一区日韩精品欧美| 看电视剧不卡顿的网站| 精品污污网站免费看| 亚洲欧美偷拍另类a∨色屁股| 国产成人精品一区二区三区四区| 在线播放91灌醉迷j高跟美女 | 欧美日韩在线播放三区四区| 国产精品久久久久久久久免费桃花 | 夜夜嗨av一区二区三区网页| 国产大陆a不卡| 欧美精品一区二区三区久久久| 婷婷一区二区三区| 欧美午夜一区二区三区| 国产精品免费丝袜| 国产91精品露脸国语对白| 日韩精品中午字幕| 日本在线观看不卡视频| 欧美日韩国产a| 一区二区三区久久| 91在线观看污| 国产精品福利一区二区三区| 成人在线综合网站| 久久噜噜亚洲综合| 久久se精品一区二区| 欧美成人精品1314www| 日本伊人色综合网| 日韩三级电影网址| 久草热8精品视频在线观看| 日韩一区二区免费电影| 免费在线观看精品| 8v天堂国产在线一区二区| 日韩电影在线看| 91精品国产综合久久精品| 日韩av中文字幕一区二区| 91精品婷婷国产综合久久| 日本视频在线一区| 日韩午夜在线观看视频| 国产资源精品在线观看| 久久久久久久久久久久久女国产乱| 精品亚洲国产成人av制服丝袜| 久久久久久久久久久久电影| 国产一区二区不卡在线| 国产精品麻豆一区二区 | 91欧美激情一区二区三区成人| 国产精品理论片| 色婷婷亚洲婷婷| 亚洲午夜激情网站| 日韩欧美一二三| 国产河南妇女毛片精品久久久| 免费美女久久99| 欧美成人精品高清在线播放| 粉嫩嫩av羞羞动漫久久久 | 免费一区二区视频| 精品国产一区二区三区四区四 | 国产美女在线精品| 亚洲免费成人av| 欧美日韩黄色一区二区| 精品午夜久久福利影院| 国产精品视频麻豆| 欧美亚洲高清一区二区三区不卡| 青青草成人在线观看| 欧美激情在线看| 在线观看国产日韩| 狠狠色狠狠色综合| 国产精品乱码人人做人人爱| 欧美日韩综合一区| 国产精品911| 婷婷一区二区三区| 国产精品视频在线看| 欧美日韩国产大片| 国产白丝精品91爽爽久久 | 国产乱国产乱300精品| 亚洲精品免费在线播放| 欧美大片一区二区| 99视频在线精品| 久久99热国产| 亚洲综合在线第一页| 久久这里只有精品首页| 欧美在线看片a免费观看| 国产精品一区二区果冻传媒| 亚洲国产视频直播| 国产日韩成人精品| 69堂国产成人免费视频| jvid福利写真一区二区三区| 麻豆免费看一区二区三区| 亚洲欧美影音先锋| 久久久精品tv| 3d成人动漫网站| 在线国产亚洲欧美|