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

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

?? os_sem.c

?? 學習嵌入式arm的資料
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2001, 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                      */
        OS_EventWaitListInit(pevent);
    }
    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一区二区三区免费野_久草精品视频
日韩一区二区精品| 亚洲五月六月丁香激情| 日韩欧美国产精品| 欧美另类高清zo欧美| 欧美亚洲国产一区二区三区va | 久久国产日韩欧美精品| 日韩综合在线视频| 天堂一区二区在线| 蜜臀av性久久久久蜜臀aⅴ | 欧美日韩色综合| 久久久一区二区| 国产亚洲1区2区3区| 国产三级精品三级在线专区| 欧美国产欧美亚州国产日韩mv天天看完整| 精品99999| 国产三级久久久| 中文字幕中文乱码欧美一区二区| 国产精品久久看| 亚洲精品视频免费观看| 亚洲国产日韩在线一区模特| 日日欢夜夜爽一区| 美女脱光内衣内裤视频久久网站| 精品一区二区精品| 国产不卡视频一区| 一本久久综合亚洲鲁鲁五月天| 欧美最新大片在线看| 欧美一区二区三区免费在线看 | 中文字幕中文字幕在线一区| 亚洲视频在线一区二区| 亚洲国产成人va在线观看天堂| 午夜精品福利久久久| 麻豆一区二区99久久久久| 国产精品18久久久久久久久 | 色婷婷一区二区| 欧美人狂配大交3d怪物一区| 精品伦理精品一区| 中文字幕一区二区三区精华液| 亚洲主播在线观看| 久久不见久久见中文字幕免费| 国产成人精品在线看| 91久久精品网| 精品成人免费观看| 18欧美亚洲精品| 日韩**一区毛片| 欧美成人精品高清在线播放| 国产精品美女视频| 偷拍亚洲欧洲综合| 国产精品自拍av| 欧美视频一区二区三区在线观看 | 国产精品久久久爽爽爽麻豆色哟哟 | 欧美三级中文字幕在线观看| 精品国产一区二区亚洲人成毛片 | 国产成人免费在线观看不卡| 欧美视频完全免费看| 久久久精品tv| 香蕉成人伊视频在线观看| 国内国产精品久久| 欧美视频中文一区二区三区在线观看 | 日本一区免费视频| 性欧美疯狂xxxxbbbb| 国产白丝网站精品污在线入口| 欧美性大战久久久久久久| 久久无码av三级| 五月婷婷综合在线| 99国产精品久久久久久久久久久| 这里只有精品视频在线观看| 国产精品色一区二区三区| 日韩av电影免费观看高清完整版| 91麻豆精品在线观看| 久久夜色精品一区| 午夜精品免费在线观看| 91在线免费播放| 精品国产乱子伦一区| 亚洲va天堂va国产va久| 成人午夜看片网址| 精品国产精品一区二区夜夜嗨| 一区二区三区日韩精品视频| 成人午夜激情影院| 久久精品夜色噜噜亚洲a∨| 日本亚洲欧美天堂免费| 91激情在线视频| 国产精品进线69影院| 国产精一区二区三区| 欧美sm美女调教| 免费观看日韩电影| 欧美另类一区二区三区| 亚洲国产你懂的| 色噜噜久久综合| 亚洲欧美另类久久久精品2019| 成人激情校园春色| 国产嫩草影院久久久久| 国内精品免费**视频| 精品噜噜噜噜久久久久久久久试看 | 国产精品国产三级国产普通话三级| 精品中文字幕一区二区| 日韩欧美黄色影院| 日韩黄色免费电影| 欧美精品九九99久久| 亚洲图片欧美色图| 欧美性猛交一区二区三区精品| 亚洲人成人一区二区在线观看 | 丁香桃色午夜亚洲一区二区三区| 精品久久久久久久人人人人传媒| 免费亚洲电影在线| 欧美一级爆毛片| 精品午夜久久福利影院| 精品成人一区二区三区| 国内精品不卡在线| 国产欧美一区二区精品婷婷 | 欧美电视剧在线观看完整版| 狠狠色综合播放一区二区| 精品国产亚洲一区二区三区在线观看| 六月丁香婷婷色狠狠久久| 337p粉嫩大胆色噜噜噜噜亚洲| 国产资源精品在线观看| 国产亚洲综合色| 成人h动漫精品一区二区| 综合久久给合久久狠狠狠97色 | 精品少妇一区二区三区在线播放| 免费观看在线综合| 久久精品视频一区| 成人深夜福利app| 亚洲男人的天堂在线aⅴ视频| 在线观看91精品国产入口| 日韩激情中文字幕| 精品99一区二区三区| 成人综合婷婷国产精品久久蜜臀 | 中文字幕一区二区不卡 | 精品乱人伦小说| 成人av在线播放网站| 亚洲最大成人综合| 日韩美女一区二区三区| 国产九色sp调教91| 亚洲视频一区在线| 欧美久久久一区| 国产成人精品一区二区三区四区| 亚洲欧美另类小说视频| 91精品国产福利在线观看| 国产精品一区在线观看你懂的| 国产精品美日韩| 欧美精品免费视频| 丰满放荡岳乱妇91ww| 亚洲影视在线播放| 日韩精品一区二区三区swag| www.色精品| 日韩成人伦理电影在线观看| 久久久午夜电影| 色综合夜色一区| 久久精品国产精品青草| 国产精品国产馆在线真实露脸| 欧美视频在线播放| 久久精品国产久精国产爱| 亚洲女子a中天字幕| 日韩三级视频在线看| www.日韩av| 激情综合色播五月| 亚洲精品高清在线观看| 337p日本欧洲亚洲大胆色噜噜| 色88888久久久久久影院野外| 久久精品理论片| 亚洲欧洲韩国日本视频 | 另类综合日韩欧美亚洲| 亚洲视频一区二区在线观看| 久久综合久久综合亚洲| 在线视频欧美区| 国产成人精品三级| 日本美女一区二区三区| 亚洲日本青草视频在线怡红院| 日韩欧美精品在线| 欧美午夜影院一区| 成人午夜av影视| 韩日av一区二区| 97超碰欧美中文字幕| 国产在线精品免费| 亚洲成a天堂v人片| 综合电影一区二区三区 | 蜜桃视频在线观看一区| 亚洲综合精品久久| 国产精品天干天干在线综合| 亚洲精品在线观看视频| 欧美日韩免费一区二区三区 | 懂色av一区二区夜夜嗨| 久久精品国产在热久久| 亚洲国产一区二区视频| 亚洲三级免费观看| 国产精品视频你懂的| 久久久国产精华| 久久这里只精品最新地址| 91精品在线麻豆| 欧美区在线观看| 在线看日本不卡| av一二三不卡影片| 粉嫩蜜臀av国产精品网站| 国产麻豆午夜三级精品| 激情综合五月天| 久久er99热精品一区二区| 久久精品理论片| 狠狠色丁香婷婷综合久久片| 美女高潮久久久| 蜜桃av噜噜一区|