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

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

?? os_sem.c

?? lpc2368-keil環境下的ucos的移植例程
?? 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 "..\APP\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一区二区三区免费野_久草精品视频
亚洲高清免费观看| 欧美日韩国产首页| 久久久国际精品| 国内精品写真在线观看| 欧美大白屁股肥臀xxxxxx| 天天综合天天综合色| 欧美精品久久一区| 美女视频黄免费的久久| 精品国产麻豆免费人成网站| 国产一区视频网站| 国产精品亲子伦对白| 99精品视频在线播放观看| 洋洋av久久久久久久一区| 欧美日韩三级在线| 麻豆精品在线播放| 国产欧美日韩在线视频| 91蜜桃网址入口| 亚洲大片精品永久免费| 日韩欧美亚洲国产另类| 成人免费福利片| 一区二区三区四区激情| 日韩欧美国产不卡| 成人性色生活片| 午夜精品久久久久| 亚洲精品一区二区三区精华液| 成人动漫在线一区| 亚洲一区二区欧美日韩| 久久亚洲影视婷婷| 91麻豆精品秘密| 久久国产免费看| 亚洲手机成人高清视频| 91精品国产乱| 99国内精品久久| 日本不卡视频在线观看| 1024国产精品| 6080午夜不卡| 色婷婷一区二区| 激情欧美日韩一区二区| 亚洲欧美日韩国产手机在线| 91精品综合久久久久久| 成人av综合一区| 久久精品国产久精国产爱| 国产精品少妇自拍| 欧美一级免费大片| 一本久道久久综合中文字幕| 国产在线乱码一区二区三区| 一区二区三区在线观看网站| www国产精品av| 欧美日韩和欧美的一区二区| 丰满少妇久久久久久久| 日本欧美在线观看| 夜夜精品视频一区二区| 国产免费观看久久| 日韩欧美一区二区视频| 欧美日韩精品免费| 色综合天天综合网天天狠天天| 国产一区视频在线看| 日本色综合中文字幕| 亚洲精品福利视频网站| 国产精品毛片久久久久久久| 日韩美一区二区三区| 欧美剧情片在线观看| 色综合亚洲欧洲| 99精品久久99久久久久| 国产高清一区日本| 麻豆成人91精品二区三区| 石原莉奈在线亚洲二区| 一区二区三区不卡视频| 国产精品乱码一区二区三区软件 | 国产精品女同互慰在线看| 日韩免费看的电影| 欧美一区二区观看视频| 欧美一区二区三区性视频| 欧美在线短视频| 欧美伊人久久久久久午夜久久久久| 成人av网址在线| 成人sese在线| 色婷婷综合激情| 在线看国产一区| 欧美调教femdomvk| 欧美系列亚洲系列| 欧美日韩视频不卡| 欧美一区二区三区在线| 欧美一级xxx| 精品免费视频一区二区| 国产亚洲精久久久久久| 中文一区在线播放| 亚洲免费资源在线播放| 亚洲午夜精品网| 日韩不卡一区二区三区| 蜜桃免费网站一区二区三区| 国模无码大尺度一区二区三区| 国产乱子伦视频一区二区三区| 国产传媒日韩欧美成人| 成人app网站| 老司机午夜精品| 首页国产欧美久久| 亚洲精品菠萝久久久久久久| 夜夜精品视频一区二区| 亚洲国产视频直播| 青青草国产精品97视觉盛宴| 日韩av电影天堂| 日韩avvvv在线播放| 青椒成人免费视频| 麻豆国产欧美日韩综合精品二区| 亚洲第四色夜色| 精品一区二区三区在线视频| 久久精品国产99久久6| 国产在线麻豆精品观看| 国产成人一区二区精品非洲| 成人av在线电影| 色拍拍在线精品视频8848| 色婷婷综合久久久久中文一区二区 | 亚洲成人黄色小说| 日本不卡高清视频| 国产在线视频一区二区三区| 成人晚上爱看视频| 欧美日韩国产大片| 精品久久久久久久久久久院品网 | 亚洲欧美区自拍先锋| 亚洲一区二区精品3399| 久草精品在线观看| 95精品视频在线| 欧美伦理视频网站| 久久女同精品一区二区| 亚洲天堂网中文字| 日韩国产精品久久久| k8久久久一区二区三区 | 亚洲午夜精品17c| 韩国精品免费视频| 99在线精品视频| 欧美久久久久久蜜桃| 精品久久一区二区三区| 中文字幕欧美日本乱码一线二线| 亚洲视频 欧洲视频| 亚洲电影一级黄| 国产乱对白刺激视频不卡| 99久久777色| 欧美成人一级视频| 亚洲九九爱视频| 国产裸体歌舞团一区二区| 欧美三电影在线| 国产女主播视频一区二区| 亚洲午夜视频在线| 国产成人综合网| 欧美日韩国产中文| 久久视频一区二区| 久久精品国产一区二区三区免费看| 波多野洁衣一区| 精品毛片乱码1区2区3区| 一区二区三区不卡在线观看| 国产成人综合亚洲网站| 精品欧美一区二区在线观看 | 91高清在线观看| 国产日韩亚洲欧美综合| 水蜜桃久久夜色精品一区的特点| 成人激情小说网站| 欧美吻胸吃奶大尺度电影| 国产日产欧美一区| 久久成人av少妇免费| 欧美视频在线一区| 亚洲欧美一区二区视频| 国产麻豆一精品一av一免费 | 亚洲精品一区二区三区蜜桃下载| 自拍偷拍亚洲欧美日韩| 国产乱理伦片在线观看夜一区| 欧美日韩国产综合久久| 亚洲精品成人精品456| av成人老司机| 亚洲图片激情小说| 成人av高清在线| 中文字幕乱码久久午夜不卡| 国产中文字幕精品| 日韩欧美美女一区二区三区| 国产欧美精品一区| 成人一区二区三区视频| 国产日韩成人精品| 精品影视av免费| 欧美精品一区二区三区四区| 日本系列欧美系列| 日本道免费精品一区二区三区| 久久久久国产成人精品亚洲午夜| 成人午夜在线视频| 国产欧美一区二区三区网站| 国产高清一区日本| 中文字幕精品综合| 国产不卡视频在线播放| 亚洲日穴在线视频| 91在线观看免费视频| 亚洲免费观看在线视频| 91一区一区三区| 中文字幕av不卡| 欧美亚洲动漫制服丝袜| 午夜精品福利一区二区三区av | 国产不卡在线一区| 中文字幕av一区二区三区免费看| 成人美女视频在线看| 亚洲少妇最新在线视频| 8v天堂国产在线一区二区| 老司机免费视频一区二区三区|