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

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

?? os_sem._c

?? ucos如何移植到單片機mega128
?? _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 "..\ucos2_application\includes.h"
#endif

#if !defined(__UCOS_II_H)
	#include "..\ucos2_without_cpu\ucos_ii.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();

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
韩国一区二区在线观看| 成人一区二区三区中文字幕| 亚洲成人激情综合网| 国产精品久久久久久久久果冻传媒| 一区二区三区波多野结衣在线观看| 久久电影国产免费久久电影 | 在线播放中文字幕一区| 国产日产欧美一区二区视频| 亚洲午夜成aⅴ人片| 93久久精品日日躁夜夜躁欧美| 91精品国产综合久久精品性色| 国产精品狼人久久影院观看方式| 国产丝袜在线精品| 亚洲乱码中文字幕| 亚洲h动漫在线| 精品一区二区三区日韩| 成人性生交大片免费看中文| 欧美日韩黄色一区二区| 国产精品毛片高清在线完整版| 蜜桃视频第一区免费观看| 成人一级片网址| 日韩欧美国产精品| 亚洲二区视频在线| 91香蕉国产在线观看软件| 国产日产欧产精品推荐色| 亚洲一区二区在线观看视频| 国产激情一区二区三区| 日韩一级黄色片| 亚洲成人免费影院| 欧美视频三区在线播放| 一区精品在线播放| 成人国产亚洲欧美成人综合网| 日韩欧美在线网站| 美女视频网站黄色亚洲| 欧美另类久久久品| 久久国产精品露脸对白| 美日韩黄色大片| 久久久另类综合| 免费美女久久99| 久久国产夜色精品鲁鲁99| 狠狠网亚洲精品| 欧美日韩免费一区二区三区| 中文字幕成人av| 亚洲mv大片欧洲mv大片精品| 一本大道久久a久久综合婷婷 | 欧美激情一区二区三区全黄| 美女精品自拍一二三四| 欧美色国产精品| 日本中文字幕一区二区有限公司| 欧美视频在线播放| 日韩精品一二三区| 91精品国产综合久久久久| 日韩福利视频导航| 久久久久久免费毛片精品| 福利视频网站一区二区三区| 成人欧美一区二区三区小说| 色又黄又爽网站www久久| 国产精品久久久久久久岛一牛影视| 成人黄色电影在线| 成人欧美一区二区三区视频网页| 欧美在线观看视频一区二区| 日本不卡一区二区三区 | 丁香婷婷综合色啪| 亚洲欧美乱综合| 精品黑人一区二区三区久久 | 久久久久久久久97黄色工厂| 成人精品免费视频| 日韩影院在线观看| 中文无字幕一区二区三区| 欧美在线免费观看亚洲| 九九**精品视频免费播放| 亚洲视频在线一区观看| 欧美大肚乱孕交hd孕妇| 91免费版在线看| 国产在线精品一区二区不卡了| 亚洲精品亚洲人成人网在线播放| 精品久久久久一区| 欧美三级三级三级| 成人av网站在线观看| 美腿丝袜一区二区三区| 亚洲国产视频网站| 久久亚洲一级片| 欧美乱妇20p| 99久久99久久精品免费观看| 日韩不卡免费视频| 亚洲六月丁香色婷婷综合久久 | 天堂精品中文字幕在线| 国产欧美视频一区二区| 精品成人佐山爱一区二区| 欧美日本免费一区二区三区| 日本精品裸体写真集在线观看| 国产伦精品一区二区三区视频青涩| 亚洲第一电影网| 午夜视频一区二区三区| 亚洲最色的网站| 亚洲一二三区不卡| 亚洲成人免费在线观看| 日韩va欧美va亚洲va久久| 奇米综合一区二区三区精品视频| 图片区日韩欧美亚洲| 日韩 欧美一区二区三区| 麻豆91小视频| 国产成人亚洲综合a∨婷婷| 高清国产一区二区| hitomi一区二区三区精品| 91香蕉国产在线观看软件| 97精品国产97久久久久久久久久久久 | 中文字幕精品—区二区四季| 久久―日本道色综合久久| 国产亚洲一区二区三区四区| 国产女主播视频一区二区| 亚洲欧美在线观看| 亚洲亚洲精品在线观看| 成人高清视频在线| 久久av资源网| 色偷偷一区二区三区| 国产欧美一区视频| 91免费视频网址| 久久网站热最新地址| 青青青爽久久午夜综合久久午夜 | 欧美xxxxx裸体时装秀| 日韩午夜激情免费电影| 精品婷婷伊人一区三区三| 精品国产91亚洲一区二区三区婷婷| 国产精品午夜在线| 美女视频免费一区| 欧美少妇xxx| 一区视频在线播放| 风间由美中文字幕在线看视频国产欧美| 欧美日本国产视频| 亚洲国产精品ⅴa在线观看| 久久66热偷产精品| 欧美一区二区三区精品| 中文字幕一区二区日韩精品绯色| 另类欧美日韩国产在线| 日韩欧美国产综合一区| 综合久久久久综合| 处破女av一区二区| 日本一区二区成人| 激情综合色综合久久| 精品视频在线看| 亚洲国产精品一区二区www在线 | 在线观看三级视频欧美| 亚洲色图欧美激情| 91美女视频网站| 亚洲一区成人在线| 日韩欧美国产一区二区三区 | 亚洲欧美日韩成人高清在线一区| 成人丝袜高跟foot| 欧美国产禁国产网站cc| 国产成人综合亚洲网站| 国产精品久久777777| 91在线国产福利| 亚洲狠狠爱一区二区三区| 欧美高清hd18日本| 久久超碰97中文字幕| 国产三级久久久| 在线中文字幕一区二区| 日韩精品免费专区| 亚洲精品一区二区精华| 成人精品视频一区二区三区| 亚洲女同一区二区| 欧美一级黄色大片| 成人午夜视频在线观看| 一区二区在线电影| 精品剧情在线观看| 91国偷自产一区二区三区观看| 美女视频网站久久| 夜夜精品视频一区二区 | 国产精品一区二区三区网站| 午夜精品一区二区三区三上悠亚 | 欧美精品aⅴ在线视频| 久久精品国产免费看久久精品| 日韩理论片一区二区| 日韩欧美成人一区二区| 91九色02白丝porn| 国产成人精品综合在线观看| 亚洲一区二区三区中文字幕| 中文字幕不卡三区| 久久影院午夜片一区| 欧美精品一区二区三区在线播放| 欧美区视频在线观看| 色综合欧美在线视频区| 激情五月激情综合网| 丝袜美腿高跟呻吟高潮一区| 国产精品欧美一级免费| 久久综合九色综合97婷婷女人 | 在线免费观看日本欧美| 国产福利一区二区三区在线视频| 日本中文在线一区| 国产麻豆精品视频| 午夜欧美大尺度福利影院在线看 | 亚洲成人一区二区| 国产精品天干天干在线综合| 中文字幕亚洲一区二区av在线| 欧美一区二区二区| 欧美精品一区二区在线观看| 精品少妇一区二区三区视频免付费 | 精品亚洲成a人| 亚洲国产精华液网站w|