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

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

?? os_sem.c

?? ucos移植到mpc860的源碼
?? 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);
    }
#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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一区在线| 久久理论电影网| 国产自产视频一区二区三区 | 国产午夜精品理论片a级大结局| 成人av一区二区三区| 丝袜诱惑制服诱惑色一区在线观看| 久久久久久亚洲综合影院红桃| 欧美日韩高清一区二区三区| 成人黄色a**站在线观看| 麻豆精品国产91久久久久久| 一区二区三区在线视频观看| 欧美高清在线一区二区| 91精品国产综合久久精品| 99国产精品久久久久久久久久 | 久久99国产精品久久| 亚洲自拍都市欧美小说| 国产精品免费久久| 精品国产欧美一区二区| 日韩一级高清毛片| 欧美性色aⅴ视频一区日韩精品| av激情综合网| 成人精品亚洲人成在线| 国产综合色视频| 精品无人区卡一卡二卡三乱码免费卡 | 欧美二区三区的天堂| 色狠狠色噜噜噜综合网| 91一区在线观看| 99热精品国产| 91在线精品一区二区| 北条麻妃一区二区三区| 大陆成人av片| 国产成人免费xxxxxxxx| 粉嫩久久99精品久久久久久夜| 国产乱妇无码大片在线观看| 久久国产精品免费| 久久疯狂做爰流白浆xx| 精品制服美女久久| 狠狠狠色丁香婷婷综合激情| 精品综合久久久久久8888| 久久精品72免费观看| 久久不见久久见中文字幕免费| 日韩**一区毛片| 麻豆精品视频在线观看视频| 久久97超碰色| 国产精品一二三在| 成人精品鲁一区一区二区| 不卡的电影网站| 91在线国产福利| 欧美性大战xxxxx久久久| 欧美在线免费播放| 欧美电影在线免费观看| 日韩一区二区在线观看视频播放| 欧美v国产在线一区二区三区| 26uuu亚洲综合色| 欧美激情一区二区在线| 中文字幕一区二区三区四区不卡| 亚洲三级免费观看| 亚洲电影欧美电影有声小说| 日本在线不卡一区| 极品美女销魂一区二区三区| 国产成人免费av在线| 色呦呦网站一区| 欧美日韩高清在线| 国产亚洲一区二区在线观看| 最新久久zyz资源站| 亚洲va国产va欧美va观看| 久久国产欧美日韩精品| 成人在线一区二区三区| 欧美色欧美亚洲另类二区| 日韩精品资源二区在线| 国产精品久久毛片av大全日韩| 亚洲午夜成aⅴ人片| 精品亚洲成a人在线观看| 99国产精品国产精品久久| 欧美日韩国产综合视频在线观看| 欧美精品一区二区三| 国产精品亚洲第一区在线暖暖韩国| 成人性色生活片免费看爆迷你毛片| 99久久99久久免费精品蜜臀| 制服丝袜中文字幕亚洲| 欧美经典一区二区| 亚洲18女电影在线观看| 成人性色生活片免费看爆迷你毛片| 91久久香蕉国产日韩欧美9色| 日韩一区二区三区视频在线| 中文字幕在线免费不卡| 久久国产日韩欧美精品| 在线观看免费成人| 欧美激情在线看| 免费高清视频精品| 91色九色蝌蚪| 欧美精品一区二区三区蜜桃| 亚洲一区成人在线| 成人精品免费看| 日韩一级二级三级精品视频| 亚洲欧美乱综合| 国产91在线|亚洲| 91精品国产一区二区三区蜜臀| 成人欧美一区二区三区| 精品亚洲porn| 欧美精品自拍偷拍动漫精品| 亚洲欧美日韩国产综合在线| 精品无人码麻豆乱码1区2区| 欧美日本一道本在线视频| 国产精品久久福利| 韩国毛片一区二区三区| 欧美在线视频日韩| 中文字幕一区视频| 国产成人午夜片在线观看高清观看| 欧美乱妇15p| 一区二区三区在线看| 99在线视频精品| 国产片一区二区| 国内精品久久久久影院薰衣草 | 亚洲人精品午夜| 成人中文字幕电影| 精品91自产拍在线观看一区| 石原莉奈在线亚洲三区| 在线观看国产精品网站| 国产精品高潮呻吟| 国产v综合v亚洲欧| 国产亚洲一区字幕| 国产精品中文有码| 欧美精品一区二区高清在线观看| 日韩国产欧美视频| 欧美精品久久久久久久多人混战| 亚洲视频1区2区| 99精品国产热久久91蜜凸| 中文字幕中文字幕在线一区| 丁香另类激情小说| 国产精品国产三级国产aⅴ原创 | 欧美大胆人体bbbb| 麻豆成人免费电影| 亚洲精品在线观| 国内一区二区视频| 久久婷婷综合激情| 欧美v日韩v国产v| 精品一区二区在线视频| 美女视频黄免费的久久| 精品美女一区二区| 中文av字幕一区| 成人一区在线观看| 国产精品久久久久久户外露出 | 国产日韩精品久久久| 国产激情偷乱视频一区二区三区| 国产欧美日韩综合| 成人黄色小视频在线观看| 国产精品不卡在线| 在线精品视频免费播放| 亚洲成人tv网| 日韩免费高清av| 国产精品1024| 亚洲欧美日韩国产一区二区三区 | 欧美一区二区三区日韩| 久久精品99国产精品日本| 久久久久久久久一| 不卡av电影在线播放| 亚洲激情在线激情| 欧美高清精品3d| 国产精品综合久久| 中文字幕视频一区二区三区久| 欧美在线视频日韩| 精品一二线国产| 成人免费在线播放视频| 欧美理论电影在线| 国产成人亚洲综合a∨猫咪| 亚洲精品成人精品456| 日韩三级av在线播放| 波多野洁衣一区| 日韩激情一区二区| 国产午夜精品一区二区三区视频 | 91网站在线观看视频| 亚洲成人1区2区| 国产无人区一区二区三区| 91啪在线观看| 激情成人午夜视频| 亚洲另类春色校园小说| www激情久久| 色综合天天性综合| 国产在线一区二区| 亚洲午夜视频在线观看| 久久亚洲二区三区| 欧美日韩一区不卡| 成a人片国产精品| 奇米一区二区三区av| 亚洲美女一区二区三区| 欧美变态tickling挠脚心| 91麻豆福利精品推荐| 国产在线观看一区二区| 亚洲国产aⅴ天堂久久| 国产亚洲欧美日韩在线一区| 欧美日韩国产美女| 99久久精品国产网站| 国内精品久久久久影院薰衣草| 亚洲一区二区精品3399| 国产精品电影一区二区| 精品少妇一区二区三区日产乱码 | 久久爱另类一区二区小说| 亚洲国产一区二区视频| 欧美国产一区二区|