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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_sem.c

?? transplant uc/os2 on coldfire5307 編譯通過
?? 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);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美成人猛片aaaaaaa| 亚洲午夜激情av| 亚洲美女少妇撒尿| 蜜桃久久久久久久| 不卡一区二区在线| 精品国产亚洲在线| 午夜日韩在线电影| 99精品久久免费看蜜臀剧情介绍| 日韩精品专区在线影院观看| 亚洲主播在线播放| 99久久er热在这里只有精品15 | 免费人成在线不卡| 99这里都是精品| 久久综合九色综合97婷婷女人| 亚洲综合成人在线视频| 亚洲夂夂婷婷色拍ww47 | 欧美一区午夜精品| 亚洲人成网站精品片在线观看| 国产一区二区按摩在线观看| 91超碰这里只有精品国产| 亚洲欧洲另类国产综合| 国产成人精品三级| 欧美videos大乳护士334| 亚洲成人av资源| 91成人免费在线| 尤物在线观看一区| 色先锋资源久久综合| **网站欧美大片在线观看| 国产成人亚洲精品狼色在线| 久久久久久久久蜜桃| 九一九一国产精品| 欧美mv和日韩mv的网站| 麻豆91精品视频| 日韩午夜在线影院| 久久精品国产亚洲高清剧情介绍| 欧美精品123区| 日韩福利视频导航| 这里是久久伊人| 久久爱另类一区二区小说| 日韩精品一区二区三区视频 | 亚洲已满18点击进入久久| 色综合久久六月婷婷中文字幕| 中文字幕日本不卡| 91免费视频网址| 亚洲国产视频在线| 91.成人天堂一区| 精品在线一区二区| 18欧美亚洲精品| 欧美在线免费观看亚洲| 五月天激情小说综合| 91麻豆精品国产91| 国产一区二三区好的| 国产精品剧情在线亚洲| 色88888久久久久久影院野外| 亚洲一区二区三区小说| 7777精品伊人久久久大香线蕉完整版 | 亚洲精品在线观看视频| 国产一区不卡在线| 1024成人网| 欧美日韩日日摸| 国产一区欧美二区| 一区二区在线观看视频在线观看| 欧美亚洲综合色| 久久精品国产77777蜜臀| 欧美国产激情一区二区三区蜜月| 色综合久久综合中文综合网| 无码av中文一区二区三区桃花岛| 2022国产精品视频| 色偷偷久久一区二区三区| 免费美女久久99| 中文字幕一区二区5566日韩| 欧美军同video69gay| 成人性色生活片免费看爆迷你毛片| 亚洲日本一区二区| 欧美mv和日韩mv的网站| 一本色道**综合亚洲精品蜜桃冫| 免费成人深夜小野草| 国产欧美日韩激情| 在线不卡一区二区| 99久久精品国产一区| 久久99国产精品成人| 亚洲综合色视频| 国产精品午夜电影| 日韩一区二区不卡| 一本久道久久综合中文字幕| 国产精品一区二区无线| 亚洲第一电影网| 亚洲天堂2016| 国产午夜精品在线观看| 6080yy午夜一二三区久久| k8久久久一区二区三区| 国产又粗又猛又爽又黄91精品| 亚洲图片欧美一区| 亚洲欧美日本韩国| 国产精品福利一区二区| 国产亚洲自拍一区| 日韩欧美一二三四区| 欧美男男青年gay1069videost | 亚洲自拍都市欧美小说| 国产精品电影一区二区| 久久久国产精品不卡| 日韩精品一区二区在线| 欧美一级国产精品| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 国产成人在线看| 国产一区二区三区视频在线播放| 亚瑟在线精品视频| 亚洲一区二区三区影院| 亚洲综合免费观看高清在线观看| 中文字幕欧美区| 国产欧美一二三区| 欧美国产综合色视频| 亚洲国产精品ⅴa在线观看| 国产欧美日韩中文久久| 久久久电影一区二区三区| 久久久久久麻豆| 国产日韩在线不卡| 国产精品国产三级国产aⅴ中文| 国产精品久久毛片av大全日韩| 国产午夜精品理论片a级大结局| 久久综合色播五月| 久久久久国产成人精品亚洲午夜 | 成人一道本在线| 国产乱淫av一区二区三区| 国产乱子轮精品视频| 国产精品1区2区| av资源站一区| 在线观看免费一区| 精品视频999| 91精品国产综合久久久蜜臀粉嫩| 日韩亚洲欧美一区| 久久久久久一二三区| 亚洲视频在线观看三级| 亚洲国产一二三| 久久 天天综合| 99re6这里只有精品视频在线观看| 91麻豆精品一区二区三区| 在线视频国内一区二区| 欧美高清性hdvideosex| 欧美精品一区二区三区很污很色的| 久久久久久久一区| 一区二区三区精密机械公司| 日韩电影在线一区| 狠狠网亚洲精品| 色999日韩国产欧美一区二区| 欧美一区二区三区四区视频| 久久久久国产精品人| 亚洲美女视频在线观看| 麻豆91在线播放免费| 成年人国产精品| 6080午夜不卡| 亚洲欧洲av一区二区三区久久| 亚洲综合色成人| 国产成人精品亚洲日本在线桃色| 色一情一乱一乱一91av| 日韩亚洲欧美高清| 亚洲婷婷在线视频| 麻豆高清免费国产一区| 91在线精品秘密一区二区| 日韩限制级电影在线观看| 亚洲免费观看高清| 国产一区二区伦理片| 日本黄色一区二区| 久久久久久久久岛国免费| 午夜电影久久久| 色综合中文字幕国产 | 男男视频亚洲欧美| voyeur盗摄精品| 欧美sm美女调教| 夜夜精品视频一区二区| 国产大陆a不卡| 91精品在线免费| 亚洲精品一二三| 高清在线成人网| 日韩久久久久久| 日日摸夜夜添夜夜添亚洲女人| 成人av免费观看| 久久久美女毛片 | 亚洲123区在线观看| 91伊人久久大香线蕉| 国产亚洲视频系列| 麻豆国产精品官网| 日韩一区国产二区欧美三区| 亚洲图片一区二区| 在线观看亚洲专区| 综合久久综合久久| 成人在线一区二区三区| 国产亚洲欧洲一区高清在线观看| 日韩精品高清不卡| 欧美日韩视频第一区| 亚洲综合另类小说| 在线观看视频一区| 亚洲人成人一区二区在线观看| 成人av资源网站| 亚洲欧美自拍偷拍| www.欧美日韩| 亚洲激情欧美激情| 欧美性淫爽ww久久久久无| 一区二区三区日韩精品视频| 99精品视频免费在线观看|