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

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

?? os_sem.c

?? uCOSII在motorala單片機上的移植
?? 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精品视频| 自拍偷拍亚洲欧美日韩| 午夜精品免费在线观看| 日韩欧美区一区二| 色婷婷综合久久久| 久久激五月天综合精品| 亚洲激情五月婷婷| 中文字幕不卡的av| 日韩欧美黄色影院| 久久综合给合久久狠狠狠97色69| 日本道色综合久久| 国产v综合v亚洲欧| 久久av老司机精品网站导航| 精品亚洲成a人| 午夜欧美电影在线观看| 青青草一区二区三区| 亚洲另类一区二区| 日韩中文字幕不卡| 亚洲综合一区在线| 中文字幕一区二区三区在线播放 | 国产精品1区二区.| 日韩电影一区二区三区| 亚洲一区二区三区在线播放| 午夜精品一区二区三区免费视频| 秋霞午夜av一区二区三区| 国产美女一区二区| 国产一区二区三区在线观看免费 | 丝袜a∨在线一区二区三区不卡| 午夜欧美电影在线观看| 狠狠色丁香久久婷婷综合丁香| 亚洲成a人v欧美综合天堂| 一区二区三区在线观看动漫| 国产精品嫩草99a| 中文字幕不卡三区| 调教+趴+乳夹+国产+精品| 国产精品一品二品| 91 com成人网| 日韩一区二区三区观看| 日韩三级在线免费观看| 亚洲日本免费电影| 国产九色精品成人porny | 精品少妇一区二区三区视频免付费| 欧美无乱码久久久免费午夜一区 | 91在线看国产| 欧美视频在线一区| 亚洲国产激情av| 老司机免费视频一区二区| 91福利精品第一导航| 国产免费久久精品| 精品一区二区日韩| 欧美一区二区视频免费观看| 欧美一区二区在线看| 最新成人av在线| 国产成人午夜电影网| 99视频热这里只有精品免费| 欧美伊人精品成人久久综合97| 久久综合给合久久狠狠狠97色69| 亚洲电影第三页| 欧美亚洲动漫另类| 亚洲人精品一区| 日韩av二区在线播放| 欧美中文字幕久久 | 国产成人在线视频免费播放| 欧美高清一级片在线| 国产亚洲欧洲一区高清在线观看| 亚洲人成亚洲人成在线观看图片| 国产精品91xxx| 久久精品亚洲一区二区三区浴池| 青草国产精品久久久久久| 91精品国产入口| 婷婷国产v国产偷v亚洲高清| 欧美人牲a欧美精品| 国产欧美日韩另类视频免费观看| 国产综合色精品一区二区三区| 精品日韩一区二区三区| 美女网站视频久久| 色94色欧美sute亚洲线路一久 | 成人一区二区三区视频| 欧美日韩视频在线一区二区| 国产欧美日产一区| 成人综合在线观看| 中文字幕在线观看一区| 色94色欧美sute亚洲线路一久 | eeuss国产一区二区三区| 久久久久久久精| 天天av天天翘天天综合网色鬼国产| 欧美亚洲另类激情小说| 日韩中文字幕一区二区三区| 日韩女同互慰一区二区| 国产成人在线视频免费播放| 中文字幕亚洲区| 欧美色涩在线第一页| 免费观看日韩电影| 国产精品拍天天在线| 色婷婷综合久色| 麻豆精品一区二区三区| 国产欧美视频一区二区| 色狠狠一区二区三区香蕉| 亚洲国产乱码最新视频| 91高清视频免费看| 美女爽到高潮91| 国产人妖乱国产精品人妖| 色婷婷久久综合| 日本免费新一区视频| 国产精品婷婷午夜在线观看| 色婷婷亚洲综合| 国产一区二区三区高清播放| 亚洲精品中文在线影院| 精品国产一区二区亚洲人成毛片| 男女男精品网站| 国产精品的网站| 日本高清成人免费播放| 免费三级欧美电影| 国产精品卡一卡二卡三| 制服.丝袜.亚洲.另类.中文| 成人激情黄色小说| 亚洲欧美日韩综合aⅴ视频| 日韩视频免费观看高清完整版在线观看| 国产福利视频一区二区三区| 一区二区三区日韩| 国产拍揄自揄精品视频麻豆| 欧美美女一区二区三区| 99re热这里只有精品视频| 精品中文av资源站在线观看| 亚洲一卡二卡三卡四卡无卡久久| 欧美激情一区二区三区全黄| 日韩欧美国产综合一区| 日本精品一区二区三区高清| 成人免费视频一区| 精品一区二区在线视频| 婷婷六月综合网| 亚洲自拍偷拍九九九| 综合电影一区二区三区 | 亚洲欧美另类在线| 国产精品卡一卡二卡三| 久久久国产一区二区三区四区小说| 欧美日韩国产美| 色狠狠一区二区三区香蕉| 懂色av一区二区三区免费看| 久久爱www久久做| 麻豆精品新av中文字幕| 日韩av高清在线观看| 亚洲成人自拍网| 午夜影院在线观看欧美| 亚洲成人黄色小说| 亚洲国产一区视频| 香蕉成人啪国产精品视频综合网| 亚洲国产日韩av| 午夜视频在线观看一区二区三区| 亚洲一区在线视频| 亚洲成人动漫在线观看| 亚洲观看高清完整版在线观看| 一区二区三区小说| 亚洲国产精品尤物yw在线观看| 一区二区三区色| 日本不卡视频在线| 狠狠色丁香婷婷综合| 国产成人午夜精品影院观看视频 | 91精品国产高清一区二区三区蜜臀| 91成人在线免费观看| 欧美区一区二区三区| 91麻豆精品国产91久久久更新时间| 欧美午夜宅男影院| 日韩一级精品视频在线观看| 亚洲精品在线免费观看视频| 国产欧美视频一区二区| 中文字幕中文字幕一区二区| 亚洲精品高清在线| 日韩av电影免费观看高清完整版| 狠狠色丁香九九婷婷综合五月| 国产精品一区二区久久不卡| 99在线精品免费| 欧美精选午夜久久久乱码6080| 精品久久久久久久一区二区蜜臀| 久久久午夜精品| 亚洲自拍偷拍综合| 精品一区二区日韩| 色就色 综合激情| 欧美v亚洲v综合ⅴ国产v| 中文字幕在线免费不卡| 视频一区国产视频| 成人免费毛片aaaaa**| 欧美日韩国产三级| 中文字幕av免费专区久久| 亚洲国产乱码最新视频| 国产精品亚洲成人| 欧美猛男男办公室激情| 国产视频一区二区三区在线观看 | 欧美一区日本一区韩国一区| 国产欧美一区二区精品性| 香蕉加勒比综合久久| 国产高清成人在线| 欧美在线999| 中文字幕欧美区| 肉色丝袜一区二区| 91片在线免费观看| 色综合久久天天综合网| 日韩一卡二卡三卡四卡| 亚洲一级二级在线| 99综合影院在线|