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

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

?? os_sem.c

?? 9200cpu的ucosii的移植代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.76
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "ucos_ii.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)
{
    INT16U     cnt;
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr;



    cpu_sr = 0;                                       /* Prevent compiler warning                      */
#endif    
#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        return (0);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
    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)
{
    OS_EVENT  *pevent;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;



    cpu_sr = 0;                                            /* Prevent compiler warning                 */
#endif    
    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                */
#if OS_EVENT_NAME_SIZE > 1
        pevent->OSEventName[0] = '?';                      /* Unknown name                             */
        pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
        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)
{
    BOOLEAN    tasks_waiting;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;



    cpu_sr = 0;                                            /* Prevent compiler warning                 */
#endif    
    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);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    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) {
#if OS_EVENT_NAME_SIZE > 1
                 pevent->OSEventName[0] = '?';             /* Unknown name                             */
                 pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
                 pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr     = OSEventFreeList; /* Return Event Control Block to free list  */
                 pevent->OSEventCnt     = 0;
                 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    */
                 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
#if OS_EVENT_NAME_SIZE > 1
             pevent->OSEventName[0] = '?';                 /* Unknown name                             */
             pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
             pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr     = OSEventFreeList;     /* Return Event Control Block to free list  */
             pevent->OSEventCnt     = 0;
             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);
    }
}
#endif

/*$PAGE*/
/*
*********************************************************************************************************
*                                           PEND ON SEMAPHORE
*
* Description: This function waits for a semaphore.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired
*                            semaphore.
*
*              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
*                            wait for the resource up to the amount of time specified by this argument.
*                            If you specify 0, however, your task will wait forever at the specified
*                            semaphore or, until the resource becomes available (or the event occurs).
*
*              err           is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本大胆欧美人术艺术动态| 五月天精品一区二区三区| 日韩欧美色综合| 制服丝袜在线91| 欧美浪妇xxxx高跟鞋交| 91精品国产91热久久久做人人 | 国产成人精品免费在线| 久久疯狂做爰流白浆xx| 国内精品不卡在线| 国产a区久久久| 色诱视频网站一区| 欧美日韩国产123区| 欧美大肚乱孕交hd孕妇| 国产亚洲一区二区在线观看| 国产精品久久久一本精品| 亚洲综合色噜噜狠狠| 日韩高清国产一区在线| 国产盗摄一区二区| 在线观看视频91| 精品毛片乱码1区2区3区| 中文字幕乱码久久午夜不卡 | 2021中文字幕一区亚洲| 国产精品久久久久永久免费观看| 亚洲精品ww久久久久久p站| 日韩av一区二区在线影视| 国产精品一区二区x88av| 日本精品一级二级| 久久一区二区三区四区| 亚洲欧美aⅴ...| 美脚の诱脚舐め脚责91| 99这里都是精品| 欧美不卡一区二区三区| 亚洲欧洲三级电影| 激情综合网av| 色综合 综合色| 久久亚洲精品国产精品紫薇| 亚洲一区在线观看免费观看电影高清| 免费久久99精品国产| 9久草视频在线视频精品| 精品少妇一区二区三区免费观看| 亚洲图片另类小说| 精品一区二区三区免费视频| 色成年激情久久综合| 久久综合一区二区| 五月天网站亚洲| 99re这里都是精品| 久久久另类综合| 秋霞av亚洲一区二区三| 91福利在线免费观看| 久久人人爽爽爽人久久久| 亚洲国产成人porn| 91在线观看美女| 久久精品欧美日韩| 日本不卡视频一二三区| 欧美午夜精品一区二区三区| 国产精品蜜臀在线观看| 国产精品亚洲人在线观看| 制服丝袜亚洲色图| 亚洲va欧美va人人爽| 色婷婷狠狠综合| 中文无字幕一区二区三区| 国产在线一区二区综合免费视频| 日韩一区二区三区在线视频| 亚洲一区二区欧美激情| 91福利社在线观看| 一区二区三区日本| 色综合久久久网| 亚洲人成网站色在线观看| 91在线观看免费视频| 中文天堂在线一区| aaa亚洲精品| 亚洲欧美日韩国产综合| 99在线热播精品免费| 亚洲久草在线视频| 色婷婷精品久久二区二区蜜臂av | 日本欧美在线看| 91精品国产综合久久香蕉的特点| 一区二区高清免费观看影视大全| 色老汉一区二区三区| 又紧又大又爽精品一区二区| 在线精品视频一区二区三四 | 久久美女艺术照精彩视频福利播放| 麻豆一区二区在线| 久久久久一区二区三区四区| 丁香婷婷综合五月| 一区免费观看视频| 欧美日韩久久一区二区| 毛片av一区二区三区| 国产欧美精品一区| 99视频超级精品| 亚洲一区二区三区四区在线观看 | 天堂久久一区二区三区| 日韩精品一区二区三区四区| 国产精品亚洲午夜一区二区三区| 国产精品色婷婷| 欧美日韩在线免费视频| 热久久一区二区| 国产精品乱人伦一区二区| 91在线视频18| 日韩中文字幕亚洲一区二区va在线| 欧美成人国产一区二区| 成人av在线一区二区| 亚洲高清免费观看| 久久亚洲精品国产精品紫薇| 99精品1区2区| 蜜桃av噜噜一区二区三区小说| 中文一区二区完整视频在线观看| 在线观看日韩精品| 国产精品99久久久久久有的能看| 亚洲精品国产a| 亚洲精品一区二区三区福利| 91蜜桃在线观看| 狠狠色狠狠色综合| 亚洲成a人片综合在线| 国产喷白浆一区二区三区| 欧美日韩电影在线播放| 国产成人综合在线播放| 日韩精品电影一区亚洲| 亚洲三级免费电影| 久久精品一区二区三区不卡牛牛 | 久久综合资源网| 欧美三级日韩三级| 成人高清免费观看| 激情成人综合网| 丝瓜av网站精品一区二区| 亚洲欧美偷拍另类a∨色屁股| 久久亚洲免费视频| 制服丝袜成人动漫| 在线观看成人免费视频| www.欧美日韩| 国产宾馆实践打屁股91| 久久99精品国产麻豆婷婷| 亚洲成精国产精品女| 一区二区三区电影在线播| 中文字幕第一区综合| 久久久久久综合| www日韩大片| 欧美r级在线观看| 欧美电视剧免费观看| 日韩精品中文字幕一区| 欧美精品v国产精品v日韩精品| 一道本成人在线| 91麻豆swag| 日本丶国产丶欧美色综合| 色综合色综合色综合色综合色综合| 大尺度一区二区| 成人免费高清视频| 成人蜜臀av电影| 99久久99久久精品国产片果冻| 国产91露脸合集magnet | 在线视频国内一区二区| 色综合久久久久| 91国产免费看| 精品视频一区 二区 三区| 欧美色图激情小说| 欧美高清视频一二三区| 911国产精品| 日韩欧美国产wwwww| 久久综合一区二区| 国产精品久久毛片av大全日韩| 1024精品合集| 午夜国产不卡在线观看视频| 日本亚洲视频在线| 国产精品99久久久久久久女警| 成人蜜臀av电影| 91极品美女在线| 7777精品伊人久久久大香线蕉超级流畅| 91超碰这里只有精品国产| 日韩免费一区二区| 中文字幕精品—区二区四季| 一区二区三区国产精华| 男人的j进女人的j一区| 国产99精品在线观看| 色94色欧美sute亚洲线路二| 欧美日韩不卡视频| 久久久美女艺术照精彩视频福利播放 | 日本韩国视频一区二区| 欧美精品 国产精品| 亚洲精品在线免费播放| 亚洲日本青草视频在线怡红院| 偷偷要91色婷婷| 国产福利不卡视频| 91传媒视频在线播放| 精品久久一区二区三区| 中文字幕一区二区三| 午夜精品福利在线| yourporn久久国产精品| 欧美一二三区精品| 国产精品久久久久四虎| 日本人妖一区二区| 99久久精品国产一区二区三区| 91精品久久久久久蜜臀| 国产精品美女久久久久久2018| 日韩和的一区二区| 97se亚洲国产综合自在线不卡| 欧美一二三区在线观看| 亚洲免费观看高清完整版在线观看 | 日韩欧美在线不卡| 亚洲六月丁香色婷婷综合久久| 久99久精品视频免费观看|