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

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

?? os_sem.c

?? ARM7Proteus.rar
?? 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一区二区三区免费野_久草精品视频
亚洲女同ⅹxx女同tv| 日韩电影在线观看电影| 宅男在线国产精品| 成人在线一区二区三区| 日韩中文字幕亚洲一区二区va在线| 国产午夜精品福利| 日韩美女一区二区三区四区| 欧美在线不卡视频| 99久久国产综合精品色伊| 国产一区二区三区四区在线观看| 亚洲福利一二三区| 亚洲裸体在线观看| 国产日本欧美一区二区| 久久综合九色综合久久久精品综合| 欧美日韩一区精品| 91成人在线观看喷潮| 91女厕偷拍女厕偷拍高清| 国产精品77777| 国产美女久久久久| 韩国欧美国产一区| 久久国产欧美日韩精品| 午夜在线成人av| 亚洲综合色噜噜狠狠| 亚洲精品美国一| 亚洲免费观看高清| 亚洲欧洲精品一区二区三区| 欧美激情资源网| 国产女同互慰高潮91漫画| 久久久久久久久久美女| 26uuu亚洲| 久久男人中文字幕资源站| 精品免费国产二区三区| 欧美精品一区二区三区高清aⅴ| 91精品视频网| 欧美一区二区三区日韩| 91精品国产综合久久久久| 欧美人狂配大交3d怪物一区| 制服丝袜亚洲播放| 欧美一区日本一区韩国一区| 欧美一级黄色片| 精品少妇一区二区三区在线视频| 欧美一卡2卡三卡4卡5免费| 日韩精品专区在线影院重磅| 日韩精品专区在线影院观看| 337p粉嫩大胆噜噜噜噜噜91av| 久久久久久夜精品精品免费| 久久久99久久| 国产蜜臀97一区二区三区| 国产精品麻豆一区二区 | 欧美成人一区二区三区在线观看| 91精品国产日韩91久久久久久| 欧美电影免费提供在线观看| 久久人人爽爽爽人久久久| 国产午夜亚洲精品理论片色戒| 国产精品伦理在线| 亚洲一卡二卡三卡四卡无卡久久| 香蕉久久夜色精品国产使用方法| 毛片av一区二区| 丰满白嫩尤物一区二区| 91亚洲大成网污www| 欧美日韩精品一二三区| 欧美成人福利视频| 亚洲欧美在线视频观看| 午夜视频在线观看一区| 久久精品国产亚洲一区二区三区| 国产高清不卡二三区| 色综合久久综合网97色综合| 91精品国产入口| 中文字幕二三区不卡| 亚洲成av人综合在线观看| 黄网站免费久久| 色综合久久中文字幕综合网| 日韩欧美一区在线| 国产精品欧美一级免费| 日本在线播放一区二区三区| 国产ts人妖一区二区| 欧美揉bbbbb揉bbbbb| 2023国产精华国产精品| 亚洲精品久久嫩草网站秘色| 黄页网站大全一区二区| 色中色一区二区| 久久久久9999亚洲精品| 亚洲高清不卡在线| 成人黄色网址在线观看| 91精品婷婷国产综合久久性色| 国产精品青草久久| 麻豆免费精品视频| 欧美亚洲一区三区| 国产精品丝袜91| 免费视频一区二区| 欧美自拍偷拍一区| 日本一区二区三区免费乱视频| 亚洲.国产.中文慕字在线| 成人黄色在线看| 精品久久国产字幕高潮| 亚洲成人综合网站| 波多野结衣欧美| 亚洲精品一线二线三线| 亚洲不卡在线观看| 91欧美一区二区| 中文字幕不卡在线| 国产一区二区91| 欧美变态tickling挠脚心| 洋洋av久久久久久久一区| 成人午夜激情影院| 精品va天堂亚洲国产| 日韩av网站免费在线| 91国产精品成人| 亚洲男人天堂一区| 成人av网站大全| 国产日韩一级二级三级| 国产在线精品不卡| 日韩色视频在线观看| 日精品一区二区三区| 色婷婷精品久久二区二区蜜臂av| 国产三区在线成人av| 极品销魂美女一区二区三区| 欧美一卡二卡在线| 日韩成人午夜电影| 欧美精品v日韩精品v韩国精品v| 亚洲免费观看视频| 91日韩一区二区三区| 亚洲婷婷国产精品电影人久久| 盗摄精品av一区二区三区| 久久久www免费人成精品| 激情综合网最新| 精品第一国产综合精品aⅴ| 久久精品国产精品亚洲红杏| 日韩女优av电影| 韩国一区二区三区| 国产午夜精品在线观看| 成人性视频免费网站| 中文字幕第一区综合| 99在线热播精品免费| 亚洲天堂av老司机| 欧美在线看片a免费观看| 亚洲线精品一区二区三区| 欧美日韩一级视频| 日本午夜一区二区| 精品国产乱码久久久久久老虎| 精品一区二区三区免费观看| 精品久久人人做人人爽| 国产麻豆成人传媒免费观看| 欧美激情一区三区| 色综合天天视频在线观看| 亚洲一区二区在线免费观看视频| 欧美日韩国产首页在线观看| 日本成人中文字幕在线视频| 日韩欧美中文字幕精品| 风间由美一区二区三区在线观看| 国产精品视频第一区| 91国偷自产一区二区三区成为亚洲经典 | 亚洲视频中文字幕| 91在线观看污| 亚洲线精品一区二区三区| 日韩欧美国产综合| 国产精品亚洲专一区二区三区| 久久综合九色综合97婷婷| 国产成人在线观看免费网站| 国产精品国模大尺度视频| 在线观看免费亚洲| 精品一区二区三区在线播放 | 国内精品不卡在线| 国产精品九色蝌蚪自拍| 欧美三级视频在线| 韩国成人在线视频| 亚洲人成在线观看一区二区| 欧美一区二区三区四区五区 | 中文字幕一区二区不卡| 欧美三级电影在线看| 国产一区二区三区四| 亚洲欧洲精品一区二区精品久久久| 欧美日韩另类国产亚洲欧美一级| 国产在线播放一区三区四| 亚洲精品国久久99热| 日韩欧美一级二级三级久久久| 成人av网站在线观看| 日韩高清在线观看| 国产精品久久久久婷婷二区次| 欧美日韩久久一区| 丁香六月综合激情| 青青草国产成人av片免费| 亚洲视频综合在线| 精品国产123| 欧美日韩一级黄| av不卡一区二区三区| 精品一区二区三区免费播放| 亚洲欧美日韩电影| 国产亚洲成aⅴ人片在线观看| 欧美性色黄大片| 成人aa视频在线观看| 激情六月婷婷综合| 视频一区视频二区中文字幕| 国产精品久久久久久久岛一牛影视 | 欧美国产日本韩| 在线电影院国产精品| 99久久婷婷国产| 国产不卡在线播放| 日本美女一区二区三区视频| 亚洲欧洲在线观看av|