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

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

?? os_sem.c

?? 基于STR711的PRCCU程序
?? 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一区二区三区免费野_久草精品视频
av动漫一区二区| 国产原创一区二区| 国产精品第一页第二页第三页| 91精品国产综合久久国产大片| 欧美三级乱人伦电影| 欧美日韩在线播放| 91麻豆精品国产91久久久资源速度| 在线欧美一区二区| 欧美视频一区二区三区| 欧美一级久久久| 国产欧美一区二区在线| 中文av一区二区| 一区二区三区日韩精品| 亚洲午夜激情网站| 日本一不卡视频| 国产精品亚洲第一区在线暖暖韩国| 丁香六月综合激情| 色呦呦日韩精品| 91精品国产综合久久小美女| 26uuu成人网一区二区三区| 欧美激情中文字幕| 亚洲午夜一二三区视频| 裸体歌舞表演一区二区| 国产+成+人+亚洲欧洲自线| 色哟哟欧美精品| 欧美一区二区福利在线| 国产精品麻豆欧美日韩ww| 亚洲乱码国产乱码精品精的特点| 一区二区三区久久| 国内精品伊人久久久久av影院| 成人av在线播放网址| 欧美精品在线观看播放| 欧美激情资源网| 日韩国产欧美在线观看| 国产成人av一区二区三区在线| 欧美专区日韩专区| 久久免费看少妇高潮| 曰韩精品一区二区| 国产精品资源在线观看| 欧美性xxxxxxxx| 中文字幕av在线一区二区三区| 亚洲一区二区三区四区中文字幕| 久久成人麻豆午夜电影| 91福利资源站| 亚洲国产岛国毛片在线| 日日夜夜免费精品| 91原创在线视频| 国产性色一区二区| 奇米色777欧美一区二区| 色综合色狠狠综合色| 久久久久久久久蜜桃| 日韩av一区二区三区| 91丝袜美女网| 国产日产精品1区| 加勒比av一区二区| 日韩欧美三级在线| 亚洲www啪成人一区二区麻豆| 成人动漫一区二区在线| 久久久综合视频| 秋霞午夜鲁丝一区二区老狼| 欧美性生交片4| 最新热久久免费视频| 国产99久久精品| 欧美精品一区二区三区久久久| 亚洲永久精品大片| 欧美亚洲丝袜传媒另类| 一区二区视频免费在线观看| 岛国av在线一区| 欧美高清一级片在线观看| 国产一区二区三区久久悠悠色av| 日韩免费观看高清完整版在线观看| 午夜国产不卡在线观看视频| 欧美伊人精品成人久久综合97| 国产精品欧美精品| 91影视在线播放| 中文字幕一区二区日韩精品绯色| 国产精品一二三四| 国产精品天天摸av网| 国产凹凸在线观看一区二区| 国产亚洲精品aa午夜观看| 国产成人av影院| 中文字幕+乱码+中文字幕一区| 国产福利一区在线观看| 欧美国产激情二区三区| 成人精品国产一区二区4080| 成人欧美一区二区三区黑人麻豆 | 国产欧美日韩在线视频| 国产成人精品www牛牛影视| 欧美国产一区视频在线观看| 不卡的电视剧免费网站有什么| 亚洲欧洲精品一区二区三区| 色婷婷精品大在线视频| 午夜激情综合网| 精品久久久网站| 成人蜜臀av电影| 亚洲一区二区在线免费观看视频 | 在线观看免费一区| 亚洲成av人片在线| 欧美大黄免费观看| 福利电影一区二区| 亚洲一区二区三区四区在线观看 | 国产精品一区二区x88av| 日本一区二区三区免费乱视频| 成人av中文字幕| 午夜天堂影视香蕉久久| 久久众筹精品私拍模特| 99精品国产热久久91蜜凸| 天堂在线一区二区| 日本一区二区电影| 欧美精品国产精品| 成人午夜又粗又硬又大| 亚洲成人免费在线| 欧美激情一区三区| 欧美日本在线观看| 国产成人午夜视频| 亚洲国产日韩av| 久久久99精品免费观看不卡| 91高清视频在线| 国产成人av电影在线| 亚洲gay无套男同| 日韩一区欧美一区| www久久精品| 88在线观看91蜜桃国自产| 成人免费看视频| 久久精品国产一区二区三区免费看| 亚洲欧美一区二区三区极速播放 | 中文字幕字幕中文在线中不卡视频| 欧美视频日韩视频在线观看| hitomi一区二区三区精品| 久久精品国产亚洲aⅴ| 亚洲国产精品久久人人爱 | 欧美亚洲高清一区| 成人午夜大片免费观看| 麻豆精品国产91久久久久久| 亚洲激情一二三区| 国产精品欧美一区喷水| 精品国产乱码久久久久久影片| 欧美性猛交xxxx乱大交退制版 | 欧美日韩综合在线免费观看| 成人免费毛片高清视频| 国产成人在线网站| 国产一区二区中文字幕| 精品一区二区三区久久久| 亚洲国产精品久久不卡毛片| 亚洲色欲色欲www| 中文成人综合网| 国产欧美精品一区| 精品美女一区二区| 9191成人精品久久| 777午夜精品视频在线播放| 欧美日韩和欧美的一区二区| 色婷婷av一区二区三区软件| 成人久久18免费网站麻豆| 国产成人亚洲综合色影视| 国产大陆a不卡| 成人精品高清在线| 99r国产精品| 在线一区二区观看| 欧美精品一卡二卡| 欧美一区日韩一区| 日韩欧美国产不卡| 2023国产精品自拍| 欧美国产一区二区在线观看| 欧美国产成人精品| 亚洲精品第一国产综合野| 亚洲永久精品国产| 麻豆国产欧美日韩综合精品二区| 久久国产生活片100| 国产乱理伦片在线观看夜一区| 久久精品国产99国产精品| 国产美女精品人人做人人爽| 国产 欧美在线| 色噜噜久久综合| 欧美一区二区国产| 国产精品久久毛片| 亚洲高清免费观看高清完整版在线观看| 国产成人在线色| 91浏览器在线视频| 欧美一区二区三区爱爱| 久久精品亚洲国产奇米99| 国产喷白浆一区二区三区| 亚洲美女精品一区| 美国欧美日韩国产在线播放| 国产999精品久久| 欧美日韩免费高清一区色橹橹| 日韩免费观看高清完整版| 国产精品久久久久精k8| 日韩国产欧美在线观看| 成人激情av网| 日韩一区二区三区高清免费看看| 国产视频一区在线观看| 亚洲一区av在线| 国产精品一区免费视频| 欧美日韩一区二区三区高清 | 国产精品国产三级国产有无不卡| 亚洲伊人伊色伊影伊综合网| 久久成人免费电影| 欧美三级电影精品| 中文字幕中文乱码欧美一区二区| 日韩激情中文字幕|