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

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

?? os_sem.c

?? protues仿真ARM ARM的I2C
?? 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一区二区三区免费野_久草精品视频
亚洲成人动漫一区| 国产女人18水真多18精品一级做| 国产亚洲欧美一级| 亚洲va欧美va国产va天堂影院| 国产黑丝在线一区二区三区| 欧美高清www午色夜在线视频| 亚洲特黄一级片| 国产美女视频一区| 欧美一区二区日韩| 亚洲高清久久久| 97精品超碰一区二区三区| 精品国精品国产| 亚洲 欧美综合在线网络| 99re视频这里只有精品| 国产欧美一区二区精品仙草咪 | 欧美日韩国产综合一区二区| 久久久91精品国产一区二区精品| 日韩av网站在线观看| 欧美性视频一区二区三区| 国产精品视频一区二区三区不卡| 久久精品国产999大香线蕉| 7777精品伊人久久久大香线蕉超级流畅 | 色妹子一区二区| 中文一区二区在线观看| 国产一区二区日韩精品| 日韩欧美国产综合在线一区二区三区| 亚洲国产sm捆绑调教视频| jiyouzz国产精品久久| 国产喷白浆一区二区三区| 美国十次综合导航| 欧美一区二区日韩| 奇米色777欧美一区二区| 欧美老女人第四色| 美腿丝袜在线亚洲一区| 欧美日韩国产一级二级| 一区二区三区四区不卡视频| 99精品视频在线观看| 1024成人网| 99精品在线免费| 亚洲欧洲另类国产综合| 成人sese在线| 亚洲欧洲日韩在线| 99久久免费视频.com| 中文字幕日韩一区| 成人av资源网站| 亚洲欧美韩国综合色| 91九色02白丝porn| 亚洲综合一区二区精品导航| 成人久久久精品乱码一区二区三区| 欧美sm美女调教| 久久国产精品免费| 精品国产乱码久久久久久牛牛| 麻豆精品精品国产自在97香蕉| 欧美tk—视频vk| 国产精品一区二区在线观看不卡| 精品88久久久久88久久久| 久久99久久99| 国产女人18毛片水真多成人如厕| 不卡一区中文字幕| 亚洲精品自拍动漫在线| 欧美体内she精高潮| 日韩国产精品久久| 久久综合成人精品亚洲另类欧美 | 免费在线观看不卡| 欧美电视剧在线观看完整版| 国产黄人亚洲片| 国产做a爰片久久毛片| 国产免费久久精品| 欧美不卡一区二区| 欧美欧美欧美欧美| 在线观看国产日韩| www.日韩精品| 色老汉一区二区三区| 久久精品一二三| 日韩一区二区三区在线| 欧美丰满一区二区免费视频| 日韩一级视频免费观看在线| 伊人开心综合网| 7777精品伊人久久久大香线蕉的| 紧缚奴在线一区二区三区| 国产女主播在线一区二区| 91免费小视频| 奇米777欧美一区二区| 欧美激情艳妇裸体舞| 欧美日韩国产综合一区二区三区| 国内成+人亚洲+欧美+综合在线| 一区二区免费看| 91精品国产手机| 国产成人精品免费网站| 亚洲午夜视频在线观看| 久久综合网色—综合色88| 91网上在线视频| 麻豆一区二区三区| 亚洲欧洲日本在线| 欧美一区二区视频观看视频| 成人性生交大片免费看视频在线 | 国产精品全国免费观看高清| 日本久久电影网| 免费看日韩精品| 亚洲欧洲日韩在线| 精品福利视频一区二区三区| 91久久精品日日躁夜夜躁欧美| 国内久久精品视频| 一片黄亚洲嫩模| 国产日产亚洲精品系列| 欧美久久久影院| 99精品在线免费| 国产一区二区三区免费观看| 午夜精品久久久久久久99樱桃| 欧美国产日韩在线观看| 欧美一区二区三区婷婷月色| 97成人超碰视| 黑人巨大精品欧美黑白配亚洲| 亚洲在线观看免费| 欧美国产欧美亚州国产日韩mv天天看完整| 欧美精选午夜久久久乱码6080| 成人av影院在线| 国产一区二区三区电影在线观看| 五月天中文字幕一区二区| ㊣最新国产の精品bt伙计久久| 精品日产卡一卡二卡麻豆| 欧美日韩一区三区| 97久久精品人人澡人人爽| 国产成人综合亚洲91猫咪| 蜜桃精品在线观看| 亚洲1区2区3区视频| 亚洲欧美怡红院| 国产精品久久久久久亚洲伦| www激情久久| 日韩精品一区二区三区四区视频| 欧美亚洲国产一区二区三区va| www.欧美日韩国产在线| 国产精品一区二区久久不卡| 老司机精品视频导航| 日韩极品在线观看| 亚洲影院在线观看| 最新中文字幕一区二区三区 | 欧美人与z0zoxxxx视频| 日本韩国精品一区二区在线观看| 东方aⅴ免费观看久久av| 激情综合网最新| 久久91精品国产91久久小草| 日本成人在线看| 日本女人一区二区三区| 午夜精品福利在线| 亚洲第一搞黄网站| 性欧美大战久久久久久久久| 亚洲小说欧美激情另类| 亚洲国产精品嫩草影院| 亚洲国产成人av| 天天色综合天天| 香蕉成人啪国产精品视频综合网| 亚洲福利一区二区三区| 日日夜夜一区二区| 三级在线观看一区二区| 日本伊人午夜精品| 麻豆精品视频在线观看免费| 免费成人av在线| 精品一区中文字幕| 国产一区美女在线| 成人爽a毛片一区二区免费| 成人综合婷婷国产精品久久| 成人h动漫精品一区二| 91视频免费播放| 色婷婷激情久久| 欧美高清视频在线高清观看mv色露露十八| 欧美三级电影一区| 欧美一区二区三区影视| 精品国产伦一区二区三区免费| 精品国内二区三区| 日本一区二区三区高清不卡| 最新高清无码专区| 亚洲一区二区3| 青青草原综合久久大伊人精品优势| 日本成人在线网站| 国产精一品亚洲二区在线视频| 国产成人aaaa| 在线影视一区二区三区| 欧美精选午夜久久久乱码6080| 精品少妇一区二区三区在线播放| 国产日韩影视精品| 亚洲少妇最新在线视频| 午夜精品福利在线| 国产麻豆91精品| 91丨九色porny丨蝌蚪| 欧美偷拍一区二区| 精品成人一区二区三区| 亚洲国产高清aⅴ视频| 亚洲一区二区高清| 精品一区二区三区日韩| 成人做爰69片免费看网站| 在线看一区二区| 精品国产亚洲一区二区三区在线观看| 国产喂奶挤奶一区二区三区| 亚洲精品乱码久久久久久| 蜜桃视频免费观看一区| 成人国产视频在线观看| 欧美精品日韩综合在线| 国产亚洲综合在线| 亚洲午夜一区二区三区|