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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_sem.c

?? 51系列單片機(jī)的uCOS-II原代碼
?? C
字號(hào):
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
*                                           All Rights Reserved
*
*                                                  V2.00
*
* File : OS_SEM.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "includes.h"
#endif

#if OS_Sem_EN
/*
*********************************************************************************************************
*                                           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,
*                         you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/
#if OS_Sem_Accept_EN
INT16U OSSemAccept (OS_EVENT *pevent)reentrant
{
    INT16U cnt;


    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        OS_EXIT_CRITICAL();
        return (0);
    }
    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
*********************************************************************************************************
*/
#if OS_Sem_Create_EN
OS_EVENT *OSSemCreate (INT16U cnt)reentrant
{
    OS_EVENT *pevent;


    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                      */
        OSEventWaitListInit(pevent);
    }
    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:
*
*                            OS_NO_ERR          The call was successful and your task owns the resource 
*                                               or, the event you are waiting for occurred.
*                            OS_TIMEOUT         The semaphore was not received within the specified 
*                                               timeout.
*                            OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semaphore.
*                            OS_ERR_PEND_ISR    If you called this function from an ISR and the result
*                                               would lead to a suspension.
*
* Returns    : none
*********************************************************************************************************
*/
#if OS_Sem_Pend_EN
void OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)reentrant
{
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM)  /* Validate event block type                     */
    {  
        OS_EXIT_CRITICAL();
        *err = OS_ERR_EVENT_TYPE;
    }
    if (pevent->OSEventCnt > 0)  /* If sem. is positive, resource available ...   */
    {                    
        pevent->OSEventCnt--;                         /* ... decrement semaphore only if positive.     */
        OS_EXIT_CRITICAL();
        *err = OS_NO_ERR;
    } 
    else if (OSIntNesting > 0)  /* See if called from ISR ...                    */
    {                   
        OS_EXIT_CRITICAL();                           /* ... can't PEND from an ISR                    */
        *err = OS_ERR_PEND_ISR;
    } 
    else 
    {                                          /* Otherwise, must wait until event occurs       */
        OSTCBCur->OSTCBStat    |= OS_STAT_SEM;        /* Resource not available, pend on semaphore     */
        OSTCBCur->OSTCBDly      = timeout;            /* Store pend timeout in TCB                     */
        OSEventTaskWait(pevent);                      /* Suspend task until event or timeout occurs    */
        OS_EXIT_CRITICAL();
        OSSched();                                    /* Find next highest priority task ready         */
        OS_ENTER_CRITICAL();
        if (OSTCBCur->OSTCBStat & OS_STAT_SEM) 
        {      /* Must have timed out if still waiting for event*/
            OSEventTO(pevent);
            OS_EXIT_CRITICAL();
            *err = OS_TIMEOUT;                        /* Indicate that didn't get event within TO      */
        } 
        else 
        {
            OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;
            OS_EXIT_CRITICAL();
            *err = OS_NO_ERR;
        }
    }
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
*                                         POST TO A SEMAPHORE
*
* Description: This function signals a semaphore
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired 
*                            semaphore.
*
* Returns    : OS_NO_ERR          The call was successful and the semaphore was signaled.
*              OS_SEM_OVF         If the semaphore count exceeded its limit.  In other words, you have 
*                                 signalled the semaphore more often than you waited on it with either
*                                 OSSemAccept() or OSSemPend().
*              OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/
#if OS_Sem_Post_EN
INT8U OSSemPost (OS_EVENT *pevent)reentrant
{
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        OS_EXIT_CRITICAL();
        return (OS_ERR_EVENT_TYPE);
    }
    if (pevent->OSEventGrp) {                              /* See if any task waiting for semaphore    */
        OSEventTaskRdy(pevent, (void *)0, OS_STAT_SEM);    /* Ready highest prio task waiting on event */
        OS_EXIT_CRITICAL();
        OSSched();                                    /* Find highest priority task ready to run       */
        return (OS_NO_ERR);
    } else {
        if (pevent->OSEventCnt < 65535) {             /* Make sure semaphore will not overflow         */
            pevent->OSEventCnt++;                     /* Increment semaphore count to register event   */
            OS_EXIT_CRITICAL();
            return (OS_NO_ERR);
        } else {                                      /* Semaphore value has reached its maximum       */
            OS_EXIT_CRITICAL();
            return (OS_SEM_OVF);
        }
    }
}
#endif
/*
*********************************************************************************************************
*                                          QUERY A SEMAPHORE
*
* Description: This function obtains information about a semaphore
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired 
*                            semaphore
*
*              dataptr         is a pointer to a structure that will contain information about the 
*                            semaphore.
*
* Returns    : OS_NO_ERR          The call was successful and the message was sent
*              OS_ERR_EVENT_TYPE  If you are attempting to obtain data from a non semaphore.
*********************************************************************************************************
*/
#if   OS_Sem_Query_EN
INT8U OSSemQuery (OS_EVENT *pevent, OS_SEM_DATA *dataptr)reentrant
{
    INT8U  i;
    INT8U *psrc;
    INT8U *pdest;
    
    
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        OS_EXIT_CRITICAL();
        return (OS_ERR_EVENT_TYPE);
    }
    dataptr->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
    psrc              = &pevent->OSEventTbl[0];
    pdest             = &dataptr->OSEventTbl[0];
    for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
        *pdest++ = *psrc++;   
    }
    dataptr->OSCnt      = pevent->OSEventCnt;                /* Get semaphore count                      */
    OS_EXIT_CRITICAL();
    return (OS_NO_ERR);
}
#endif
#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜精品福利一区二区三区蜜桃| 一二三四社区欧美黄| 91视频.com| 琪琪久久久久日韩精品| 国产精品入口麻豆原神| 欧美日本在线播放| 福利一区福利二区| 麻豆91在线看| 亚洲一本大道在线| 国产精品丝袜久久久久久app| 7777女厕盗摄久久久| 91免费看视频| 粉嫩绯色av一区二区在线观看| 奇米精品一区二区三区在线观看 | 精品免费国产二区三区 | 一本色道亚洲精品aⅴ| 精品一区免费av| 亚洲电影在线播放| 亚洲欧美日韩国产中文在线| 久久蜜桃一区二区| 日韩精品中文字幕在线不卡尤物| 91久久一区二区| 97久久超碰国产精品| 国产精品一级二级三级| 久久精品国产网站| 日日夜夜精品视频免费| 亚洲综合在线电影| 亚洲女同女同女同女同女同69| 久久精品亚洲一区二区三区浴池| 91精品国产入口| 欧美美女一区二区在线观看| 色88888久久久久久影院按摩| 成人在线综合网| 国产91综合一区在线观看| 久久97超碰色| 久久99九九99精品| 蜜桃精品在线观看| 蜜臀av一区二区| 麻豆精品国产91久久久久久| 日本在线不卡视频| 日韩一区精品字幕| 日韩av不卡一区二区| 日韩激情视频在线观看| 亚洲成人午夜电影| 午夜精品免费在线| 香蕉久久夜色精品国产使用方法 | 亚洲动漫第一页| 五月婷婷综合在线| 天堂av在线一区| 日本欧美一区二区三区乱码| 美女网站视频久久| 黄网站免费久久| 国产成人综合自拍| av在线不卡免费看| 在线精品视频小说1| 欧美日韩视频专区在线播放| 欧美喷水一区二区| 欧美变态tickling挠脚心| 欧美精品一区二区精品网| 国产日韩精品视频一区| 国产精品蜜臀av| 亚洲免费观看视频| 三级久久三级久久| 国产在线播放一区三区四| 成人亚洲一区二区一| 色猫猫国产区一区二在线视频| 欧美日韩精品一区二区三区蜜桃| 欧美一区二区三区四区五区| 精品成人私密视频| 国产精品久久夜| 亚洲国产日韩在线一区模特| 免费观看在线综合色| 国产成人无遮挡在线视频| 91色视频在线| 日韩欧美中文字幕公布| 国产日韩欧美精品电影三级在线| 亚洲色图视频免费播放| 午夜婷婷国产麻豆精品| 激情综合色综合久久综合| 99久久久久免费精品国产| 欧美日韩mp4| 国产欧美日韩在线视频| 一区二区三区高清不卡| 精品一区二区免费视频| 91在线视频免费91| 欧美草草影院在线视频| 亚洲免费av高清| 日韩av二区在线播放| 99视频有精品| 欧美变态口味重另类| 亚洲精品国产一区二区精华液| 麻豆国产欧美日韩综合精品二区| 成年人午夜久久久| 欧美一区二区三区公司| 国产精品国产三级国产普通话99| 日本vs亚洲vs韩国一区三区二区| 成人午夜电影网站| 日韩午夜av一区| 一区二区三区在线观看国产| 国产一区二区久久| 制服丝袜亚洲网站| 亚洲免费观看高清完整版在线观看| 麻豆专区一区二区三区四区五区| 91性感美女视频| 久久欧美中文字幕| 天堂va蜜桃一区二区三区| 91蝌蚪porny| 国产午夜精品理论片a级大结局 | 免费看黄色91| 91国在线观看| 国产精品美女久久久久av爽李琼 | 欧美日韩中文字幕精品| 国产精品天美传媒沈樵| 日本久久一区二区| 中文字幕不卡在线| 韩国一区二区视频| 日韩天堂在线观看| 亚洲va在线va天堂| 色94色欧美sute亚洲13| 一区视频在线播放| 懂色av中文一区二区三区| 欧美大片免费久久精品三p| 一区二区成人在线| 一本久道久久综合中文字幕| 中文幕一区二区三区久久蜜桃| 国产在线国偷精品免费看| 日韩午夜激情免费电影| 日韩av网站在线观看| 欧美电影影音先锋| 亚洲电影第三页| 欧美亚州韩日在线看免费版国语版| 亚洲免费在线视频一区 二区| 播五月开心婷婷综合| 国产精品无圣光一区二区| 丁香六月久久综合狠狠色| 久久精品一二三| 懂色av一区二区在线播放| 国产欧美日韩另类视频免费观看| 国产一区 二区 三区一级| 久久天天做天天爱综合色| 久久99国产精品久久| 久久众筹精品私拍模特| 国产精品影视网| 欧美激情中文字幕一区二区| 成人网在线播放| 国产精品天干天干在观线| 99综合影院在线| 亚洲精品国久久99热| 欧美三级三级三级| 日韩在线观看一区二区| 日韩欧美二区三区| 国产福利91精品一区| 中文字幕+乱码+中文字幕一区| 暴力调教一区二区三区| 亚洲精品久久久蜜桃| 欧美日韩你懂得| 久久国产精品99久久久久久老狼| 久久综合九色综合久久久精品综合| 国产精一品亚洲二区在线视频| 国产午夜亚洲精品羞羞网站| 91视频免费观看| 亚州成人在线电影| 久久久久久久久久久99999| 粉嫩av亚洲一区二区图片| 亚洲精品久久久蜜桃| 欧美一级在线观看| 国产成人精品在线看| 一区二区三区日本| 欧美一卡二卡三卡| 国产福利不卡视频| 一区二区三区美女| 欧美岛国在线观看| av一区二区三区在线| 日韩中文字幕1| 久久久影视传媒| 在线观看91视频| 韩国成人在线视频| 亚洲综合成人在线视频| 欧美成人video| 91成人国产精品| 国内精品在线播放| 一区二区高清在线| 久久久久久久久久久电影| 欧美视频精品在线| 国产成人免费视频一区| 亚洲国产精品欧美一二99| 久久久av毛片精品| 欧美日韩在线精品一区二区三区激情| 国产在线精品一区二区不卡了| 一区二区三区日韩| 久久久国产午夜精品| 欧美日本一道本| 99久久综合国产精品| 久久精品国产在热久久| 亚洲精品老司机| 中文子幕无线码一区tr| 91精品国产综合久久香蕉的特点| 99久久久无码国产精品| 国产一区二区三区免费看 | 偷拍自拍另类欧美|