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

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

?? emos_msgq.c

?? emos是一個新的類似于ucos的內核
?? C
?? 第 1 頁 / 共 2 頁
字號:
/****************************************************************************
 *
 * (c) Copyright 2001,2008, EMB system, All Rights Reserved.
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF EMB SYSTEM, INC.
 * The copyright notice above does not evidence any actual or intended
 * publication of such source code. 
 *
 *  Subsystem:   EMOS 
 *  File:        emos_q.c
 *  Author:      zenf zhao
 *  Description: EMOS msg queue management implement
 *               EVENT_T is like a MsgQId, with is eventPtr point to a EMOS_Q_T 
 *               element, the element is inited by Create CallBack whitch init the 
 *               element point to void* msg[size]  base address, the msg[i] will keep
 *               to every input pend msg address
 ****************************************************************************/
#include "emos_cfg.h"
#include "emos_core.h"

#if EMOS_Q_EN && (EMOS_MAX_QS >= 2)

/*LOCAL GLOBAL VARIABLES*/
typedef struct os_q 
{   
  /* QUEUE CONTROL BLOCK*/
  struct os_q  *osQPtr;          /* Link to next queue control block in list of free blocks      */
   void    **osQStart;           /* Pointer to start of queue data                               */
   void    **osQEnd;             /* Pointer to end   of queue data                               */
   void    **osQIn;              /* Pointer to where next message will be inserted  in   the Q   */
   void    **osQOut;             /* Pointer to where next message will be extracted from the Q   */
   uint16    osQSize;            /* Size of queue (maximum number of entries)                    */
   uint16    osQEntries;         /* Current number of entries in the queue                       */
} EMOS_Q_T;

 static  EMOS_Q_T  *gEmosQFreeList;             /* Pointer to list of free QUEUE control blocks */
 static  EMOS_Q_T   gEmosQTbl[EMOS_MAX_QS];     /* Table of QUEUE control blocks */

/*******************************************************************************************************
* QUEUE MODULE INITIALIZATION
* Description : This function is called by EMOS to initialize the message queue module.  Your
*               application MUST NOT call this function.
* Arguments   :  none
* Returns     :  none
**********************************************************************************************************/
void emosQInit (void)
{
    uint16 i;

    for (i = 0; i < (EMOS_MAX_QS - 1); i++) 
    {      /* Init. list of free QUEUE control blocks            */
        gEmosQTbl[i].osQPtr = &gEmosQTbl[i+1];
    }
    
    gEmosQTbl[EMOS_MAX_QS - 1].osQPtr = (EMOS_Q_T *)0;
    gEmosQFreeList  = &gEmosQTbl[0];
}


/*********************************************************************************************************
*  CREATE A MESSAGE QUEUE
* Description: This function creates a message queue if free event control blocks are available.
* Arguments  : start         is a pointer to the base address of the message queue storage area.  The
*                            storage area MUST be declared as an array of pointers to 'void' as follows
*                            void *MessageStorage[size]
*              size          is the number of elements in the storage area
* Returns    : != (void *)0  is a pointer to the event control clock (EMOS_EVENT_T) associated with the
*                            created queue
*              == (void *)0  if no event control blocks were available
**********************************************************************************************************/
EMOS_EVENT_T* emosQCreate (void **start, uint16 size)
{
    EMOS_EVENT_T *pevent;
    EMOS_Q_T     *pq;

    EMOS_ENTER_CRITICAL();
    pevent = gEmosEventFreeList;/* Get next free event control block*/
    if (gEmosEventFreeList != (EMOS_EVENT_T *)0) 
    {   
    	/* See if pool of free ECB pool was empty*/
        gEmosEventFreeList = (EMOS_EVENT_T *)gEmosEventFreeList->osEventPtr;
    }
    EMOS_EXIT_CRITICAL();
    
    if (pevent != (EMOS_EVENT_T *)0) 
    {   
    	/* See if we have an event control block 
    	   Get a free queue control block */
        EMOS_ENTER_CRITICAL(); 
        pq = gEmosQFreeList;
        if (gEmosQFreeList != (EMOS_Q_T *)0) 
        {
            gEmosQFreeList = gEmosQFreeList->osQPtr;
        }
        EMOS_EXIT_CRITICAL();
        
        if (pq != (EMOS_Q_T *)0) 
        {  
        	/* See if we were able to get a queue control block   */
            pq->osQStart        = start; /* Yes, initialize the queue */
            pq->osQEnd          = &start[size];
            pq->osQIn           = start;
            pq->osQOut          = start;
            pq->osQSize         = size;
            pq->osQEntries      = 0;
            pevent->osEventType = EMOS_EVENT_TYPE_Q;
            pevent->osEventPtr  = pq;
            emosEventWaitListInit(pevent);
        }
        
        else
        {     
        	/* No free Q control block, since we couldn't get a queue control block 
               Return event control block on error */
            EMOS_ENTER_CRITICAL();        
            pevent->osEventPtr = (void *)gEmosEventFreeList;
            gEmosEventFreeList    = pevent;
            EMOS_EXIT_CRITICAL();
            pevent = (EMOS_EVENT_T *)0;
        }     
    }
    
    return (pevent);
}

/*********************************************************************************************************
* FLUSH QUEUE
* Description : This function is used to flush the contents of the message queue.
* Arguments   : none
* Returns     : EMOS_NO_ERR  upon success
*               EMOS_ERR_EVENT_TYPE  If you didn't pass a pointer to a queue
**********************************************************************************************************/
uint8 emosQFlush (EMOS_EVENT_T *pevent)
{
    EMOS_Q_T  *pq;
    
    EMOS_ENTER_CRITICAL();
    if (pevent->osEventType != EMOS_EVENT_TYPE_Q) 
    {     
    	/* Validate event block type */
        EMOS_EXIT_CRITICAL();
        return (EMOS_ERR_EVENT_TYPE);
    }

    /* Point to queue storage structure */
    pq             = pevent->osEventPtr; 
    pq->osQIn      = pq->osQStart;
    pq->osQOut     = pq->osQStart;
    pq->osQEntries = 0;
    EMOS_EXIT_CRITICAL();
    return (EMOS_NO_ERR);
}


/*********************************************************************************************************
* ACCEPT MESSAGE FROM QUEUE
* Description: This function checks the queue to see if a message is available.  Unlike osQPend(),
*              emosQAccept() does not suspend the calling task if a message is not available.
* Arguments  : pevent        is a pointer to the event control block
* Returns    : != (void *)0  is the message in the queue if one is available.  The message is removed
*                            from the so the next time osQAccept() is called, the queue will contain
*                            one less entry.
*              == (void *)0  if the queue is empty
*                            if you passed an invalid event type
**********************************************************************************************************/
void *emosQAccept (EMOS_EVENT_T* pevent)
{
    void* msg;
    EMOS_Q_T* pq;

    EMOS_ENTER_CRITICAL();
    if (pevent->osEventType != EMOS_EVENT_TYPE_Q)
    {    
    	/* Validate event block type */
        EMOS_EXIT_CRITICAL();
        return ((void *)0);
    }
    
    pq = pevent->osEventPtr;  /* Point at queue control block */
    if (pq->osQEntries != 0) 
    { 
    	/* See if any messages in the queue*/
        msg = *pq->osQOut++;   /* Yes, extract oldest message from the queue */
        pq->osQEntries--;      /* Update the number of entries in the queue */
        if (pq->osQOut == pq->osQEnd)
        {  
        	/* Wrap OUT pointer if we are at the end of the queue */
            pq->osQOut = pq->osQStart;
        }
    } 
    else
    {
        msg = (void *)0; /* Queue is empty */
    }
    
    EMOS_EXIT_CRITICAL();
    return (msg);        /* Return message received (or NULL) */
}

/*********************************************************************************************************
* PEND ON A QUEUE FOR A MESSAGE
* Description: This function waits for a message to be sent to a queue
* Arguments  : pevent        is a pointer to the event control block associated with the desired queue
*
*              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
*                            wait for a message to arrive at the queue up to the amount of time 
*                            specified by this argument.  If you specify 0, however, your task will wait 
*                            forever at the specified queue or, until a message arrives.
*              err           is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*                            EMOS_NO_ERR         The call was successful and your task received a message.
*                            EMOS_TIMEOUT        A message was not received within the specified timeout
*                            EMOS_ERR_EVENT_TYPE You didn't pass a pointer to a queue
*                            EMOS_ERR_PEND_ISR  If you called this function from an ISR and the result
*                                               would lead to a suspension.
* Returns    : != (void *)0  is a pointer to the message received
*              == (void *)0  if no message was received or you didn't pass a pointer to a queue.
**********************************************************************************************************/
void *emosQPend (EMOS_EVENT_T *pevent, uint16 timeout, uint8 *err)
{
    void  *msg;
    EMOS_Q_T  *pq;

    EMOS_ENTER_CRITICAL();
    if (pevent->osEventType != EMOS_EVENT_TYPE_Q) 
    {
    	/* Validate event block type*/
        EMOS_EXIT_CRITICAL();
        *err = EMOS_ERR_EVENT_TYPE;
        return ((void *)0);
    }
    
    pq = pevent->osEventPtr;  /* Point at queue control block */
    if (pq->osQEntries != 0) 
    {   
    	/* See if any messages in the queue */
        msg = *pq->osQOut++; /* Yes, extract oldest message from the queue */
        pq->osQEntries--;    /* Update the number of entries in the queue */

        if (pq->osQOut == pq->osQEnd) 
        {   
        	/* Wrap OUT pointer if we are at the end of the queue */
            pq->osQOut = pq->osQStart;
        }
        
        EMOS_EXIT_CRITICAL();
        *err = EMOS_NO_ERR;
    } 
    else if (gEmosIntNesting > 0)
    {  
    	/* See if called from ISR ...*/
         EMOS_EXIT_CRITICAL();                      /* ... can't PEND from an ISR */
         *err = EMOS_ERR_PEND_ISR;
     } 
    else 
    {
        gEmosTCBCur->osTCBStat    |= EMOS_STAT_Q;   /* Task will have to pend for a message to be posted  */
        gEmosTCBCur->osTCBDly      = timeout;       /* Load timeout into TCB*/
        emosEventTaskWait(pevent);                  /* Suspend task until event or timeout occurs*/
        EMOS_EXIT_CRITICAL();
        emosSched();                                /* Find next highest priority task ready to run*/
        EMOS_ENTER_CRITICAL();
        
        if ((msg = gEmosTCBCur->osTCBMsg) != (void *)0)
        {
        	/* Did we get a message,Extract message from TCB (Put there by QPost) */
            gEmosTCBCur->osTCBMsg      = (void *)0;      
            gEmosTCBCur->osTCBStat     = EMOS_STAT_RDY;
            gEmosTCBCur->osTCBEventPtr = (EMOS_EVENT_T *)0;  /* No longer waiting for event*/
            EMOS_EXIT_CRITICAL();
            *err = EMOS_NO_ERR;
        } 
        else if (gEmosTCBCur->osTCBStat & EMOS_STAT_Q)
        {
        	/* Timed out if status indicates pending on Q    */
            emosEventTo(pevent);
            EMOS_EXIT_CRITICAL();
            msg = (void *)0;      /* No message received */
            *err = EMOS_TIMEOUT;     /* Indicate a timeout occured */
        } 
        else 
        {
            msg = *pq->osQOut++;                      /* Extract message from queue */
            pq->osQEntries--;                         /* Update the number of entries in the queue */
            if (pq->osQOut == pq->osQEnd) 
            {  
            	/* Wrap OUT pointer if we are at the end of Q    */
                pq->osQOut = pq->osQStart;
            }
            
            gEmosTCBCur->osTCBEventPtr = (EMOS_EVENT_T *)0;
            EMOS_EXIT_CRITICAL();
            *err = EMOS_NO_ERR;
        }
    }  
    
    return (msg); /* Return message received (or NULL)  */
}

/*********************************************************************************************************
* POST MESSAGE TO A QUEUE
* Description: This function sends a message to a queue
* Arguments  : pevent        is a pointer to the event control block associated with the desired queue
*              msg           is a pointer to the message to send.  You MUST NOT send a NULL pointer.  
* Returns    : EMOS_NO_ERR          The call was successful and the message was sent
*              EMOS_Q_T_FULL          If the queue cannot accept any more messages because it is full.
*              EMOS_ERR_EVENT_TYPE  If you didn't pass a pointer to a queue.
**********************************************************************************************************/
uint8 emosQPost (EMOS_EVENT_T *pevent, void *msg)
{
    EMOS_Q_T   *pq;

    EMOS_ENTER_CRITICAL();
    if (pevent->osEventType != EMOS_EVENT_TYPE_Q)
    {   
    	/* Validate event block type */
        EMOS_EXIT_CRITICAL();
        return (EMOS_ERR_EVENT_TYPE);
    }
    
    if (pevent->osEventGrp)
    {   
    	/* See if any task pending on queue, then directly send the msg to ptcb->osTCBMsg,
    	   and the emosQPend will recv of the first if((msg = gEmosTCBCur->osTCBMsg) != (void *)0),
    	   don't need the msg storing operation*/
        emosEventTaskRdy(pevent, msg, EMOS_STAT_Q); /* Ready highest priority task waiting on event  */
        EMOS_EXIT_CRITICAL();
        emosSched(); 
        return (EMOS_NO_ERR);
    } 
    else
    {
        pq = pevent->osEventPtr;   /* Point to queue control block*/
        if (pq->osQEntries >= pq->osQSize) 
        {   
        	/* Make sure queue is not full*/
            EMOS_EXIT_CRITICAL();
            return (EMOS_Q_FULL);
        } 
        else 
        {
            *pq->osQIn++ = msg;                       /* Insert message into queue*/
            pq->osQEntries++;                         /* Update the nbr of entries in the queue*/
            if (pq->osQIn == pq->osQEnd)
            {  
            	/* Wrap IN ptr if we are at end of queue*/
                pq->osQIn = pq->osQStart;
            }
            EMOS_EXIT_CRITICAL();
        }
        
        return (EMOS_NO_ERR);
    }
}

/**********************************************************************************************************
* POST MESSAGE TO THE FRONT OF A QUEUE
* Description: This function sends a message to a queue but unlike osQPost(), the message is posted at
*              the front instead of the end of the queue.  Using osQPostFront() allows you to send
*              'priority' messages.  
* Arguments  : pevent        is a pointer to the event control block associated with the desired queue
*              msg           is a pointer to the message to send.  You MUST NOT send a NULL pointer.  
* Returns    : EMOS_NO_ERR          The call was successful and the message was sent
*              EMOS_Q_T_FULL          If the queue cannot accept any more messages because it is full.
*              EMOS_ERR_EVENT_TYPE  If you didn't pass a pointer to a queue.
**********************************************************************************************************/
uint8 emosQPostFront (EMOS_EVENT_T *pevent, void *msg)
{
    EMOS_Q_T   *pq;

    EMOS_ENTER_CRITICAL();
    if (pevent->osEventType != EMOS_EVENT_TYPE_Q) 
    {  
    	EMOS_EXIT_CRITICAL();
        return (EMOS_ERR_EVENT_TYPE);
    }
    
    if (pevent->osEventGrp)
    {   
    	/* See if any task pending on queue*/
        emosEventTaskRdy(pevent, msg, EMOS_STAT_Q);       /* Ready highest priority task waiting on event  */
        EMOS_EXIT_CRITICAL();
        emosSched(); 
        return (EMOS_NO_ERR);
    } 
    else 
    {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人性生交大片| 亚洲成人手机在线| 久久一留热品黄| 欧美一级日韩免费不卡| 欧美猛男gaygay网站| 欧美在线色视频| 欧美高清视频www夜色资源网| 欧美综合亚洲图片综合区| 欧美性猛交xxxx黑人交| 欧美日产在线观看| 欧美变态tickling挠脚心| 2欧美一区二区三区在线观看视频| 精品福利二区三区| 国产精品私人自拍| 亚洲精品第1页| 日本人妖一区二区| 精品一区二区三区视频| 成人免费毛片嘿嘿连载视频| 91在线一区二区| 欧美一区二区三区在| 久久久精品综合| 亚洲欧美日韩久久精品| 亚洲国产精品视频| 成人午夜在线免费| 精品在线观看免费| 亚洲激情一二三区| 亚洲 欧美综合在线网络| 男女激情视频一区| 成人aa视频在线观看| 欧美性猛交xxxx黑人交| 久久你懂得1024| 亚洲午夜一区二区三区| 国产精品久久免费看| 国产一区二区电影| 欧美激情艳妇裸体舞| 成人丝袜18视频在线观看| 国产成人超碰人人澡人人澡| 成人在线视频一区二区| 久久国产精品99久久久久久老狼 | 久久综合九色综合欧美亚洲| 麻豆专区一区二区三区四区五区| 日韩一区二区三区电影在线观看 | 亚洲精品国产一区二区三区四区在线| 成人av在线播放网址| 亚洲视频在线一区二区| 欧洲另类一二三四区| 三级在线观看一区二区| 日韩精品一区国产麻豆| 国产成人丝袜美腿| 亚洲欧美电影院| 欧美浪妇xxxx高跟鞋交| 久久er99热精品一区二区| 日本黄色一区二区| 国产精品一区二区三区乱码| 国产精品亚洲人在线观看| 2019国产精品| 91丨porny丨蝌蚪视频| 亚洲成人www| xf在线a精品一区二区视频网站| 国产精品18久久久久久久网站| 亚洲欧美一区二区视频| 6080yy午夜一二三区久久| 国产精品亚洲人在线观看| 亚洲午夜久久久久| 国产欧美一区视频| 精品视频免费在线| 国产成人在线视频网址| 亚洲国产欧美另类丝袜| 久久久噜噜噜久久人人看| 欧美探花视频资源| 国产乱码一区二区三区| 亚洲国产aⅴ成人精品无吗| 精品国内片67194| 91女厕偷拍女厕偷拍高清| 激情文学综合网| 亚洲自拍偷拍麻豆| 国产欧美精品一区| 9191精品国产综合久久久久久| 波多野结衣视频一区| 久久99久久99精品免视看婷婷| 亚洲精品写真福利| 欧美激情一区二区三区全黄| 日韩一区二区三区精品视频| 欧美午夜精品久久久久久孕妇| 国产一区欧美二区| 日本大胆欧美人术艺术动态| 亚洲日本韩国一区| 欧美国产精品一区二区三区| 欧美一级欧美三级在线观看| 欧美主播一区二区三区美女| 成人丝袜18视频在线观看| 经典三级一区二区| 视频在线观看国产精品| 亚洲精品乱码久久久久久久久| 国产日韩精品视频一区| 日韩丝袜情趣美女图片| 欧美美女视频在线观看| 欧美在线一区二区| 日本精品一区二区三区高清| 成人av综合一区| 懂色av噜噜一区二区三区av| 国产一区二区三区美女| 九九精品视频在线看| 日韩电影在线免费观看| 午夜精品一区在线观看| 亚洲国产成人av网| 日韩精品久久久久久| 亚洲一区二区欧美| 亚洲国产美女搞黄色| 亚洲国产中文字幕在线视频综合| 亚洲欧美偷拍三级| 玉足女爽爽91| 亚洲国产视频在线| 同产精品九九九| 蜜臀国产一区二区三区在线播放| 天堂一区二区在线免费观看| 日韩av一区二| 久久精品国产精品亚洲精品 | 日韩免费在线观看| 日韩免费性生活视频播放| 欧美v日韩v国产v| 精品久久久久久无| 欧美激情一区在线观看| 国产精品久久精品日日| 亚洲精品高清视频在线观看| 亚洲大片免费看| 麻豆精品蜜桃视频网站| 国产一区二区三区| av资源站一区| 欧美在线free| 欧美成人三级电影在线| 亚洲国产精品ⅴa在线观看| 中文字幕综合网| 午夜av一区二区| 国产原创一区二区| 一本到高清视频免费精品| 欧美天堂一区二区三区| 精品第一国产综合精品aⅴ| 中文av一区特黄| 亚洲午夜精品久久久久久久久| 久久99国产精品免费网站| 国产福利一区二区三区| 在线看国产一区二区| 欧美成va人片在线观看| 国产精品卡一卡二卡三| 亚洲123区在线观看| 国产v日产∨综合v精品视频| 欧美在线观看一二区| www国产成人| 亚洲综合男人的天堂| 国产一区二区精品久久| 欧美日韩亚洲高清一区二区| 精品福利在线导航| 亚洲成人精品在线观看| 国产99久久久精品| 欧美一区二区三区视频在线| 最新国产の精品合集bt伙计| 免费观看日韩电影| 99精品久久只有精品| 日韩欧美国产一区二区三区| 综合色中文字幕| 国产精品456| 日韩亚洲欧美在线| 亚洲综合色噜噜狠狠| 成人久久视频在线观看| 欧美一级日韩一级| 亚洲国产va精品久久久不卡综合 | 亚洲精品国产精品乱码不99| 精品一区中文字幕| 欧美片在线播放| 亚洲一级二级在线| 不卡视频在线观看| 国产性做久久久久久| 日韩二区三区在线观看| 欧美主播一区二区三区美女| 亚洲欧洲精品一区二区精品久久久| 久久激情五月婷婷| 在线播放日韩导航| 亚洲国产精品嫩草影院| 成人免费毛片app| 国产亚洲精品免费| 黄色日韩网站视频| 欧美一级高清片在线观看| 午夜精品国产更新| 欧美日韩一区视频| 悠悠色在线精品| 色综合久久久久综合| 中文字幕在线视频一区| 国产69精品久久99不卡| 久久精品视频一区二区三区| 久久99精品视频| 26uuu另类欧美亚洲曰本| 久99久精品视频免费观看| 日韩午夜在线影院| 久久成人av少妇免费| 日韩美女一区二区三区| 久久99蜜桃精品| 久久香蕉国产线看观看99| 国产一本一道久久香蕉| 久久久影视传媒|