|
QP/C
|
00001 /***************************************************************************** 00002 * Product: QF/C 00003 * Last Updated for Version: 4.5.00 00004 * Date of the Last Update: May 18, 2012 00005 * 00006 * Q u a n t u m L e a P s 00007 * --------------------------- 00008 * innovating embedded systems 00009 * 00010 * Copyright (C) 2002-2012 Quantum Leaps, LLC. All rights reserved. 00011 * 00012 * This program is open source software: you can redistribute it and/or 00013 * modify it under the terms of the GNU General Public License as published 00014 * by the Free Software Foundation, either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * Alternatively, this program may be distributed and modified under the 00018 * terms of Quantum Leaps commercial licenses, which expressly supersede 00019 * the GNU General Public License and are specifically designed for 00020 * licensees interested in retaining the proprietary status of their code. 00021 * 00022 * This program is distributed in the hope that it will be useful, 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 * GNU General Public License for more details. 00026 * 00027 * You should have received a copy of the GNU General Public License 00028 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00029 * 00030 * Contact information: 00031 * Quantum Leaps Web sites: http://www.quantum-leaps.com 00032 * http://www.state-machine.com 00033 * e-mail: info@quantum-leaps.com 00034 *****************************************************************************/ 00035 #include "qf_pkg.h" 00036 #include "qassert.h" 00037 00038 Q_DEFINE_THIS_MODULE("qeq_fifo") 00039 00040 00047 /*..........................................................................*/ 00048 void QEQueue_postFIFO(QEQueue * const me, QEvt const * const e) { 00049 QF_CRIT_STAT_ 00050 QF_CRIT_ENTRY_(); 00051 00052 QS_BEGIN_NOCRIT_(QS_QF_EQUEUE_POST_FIFO, QS_eqObj_, me) 00053 QS_TIME_(); /* timestamp */ 00054 QS_SIG_(e->sig); /* the signal of this event */ 00055 QS_OBJ_(me); /* this queue object */ 00056 QS_U8_(QF_EVT_POOL_ID_(e)); /* the pool Id of the event */ 00057 QS_U8_(QF_EVT_REF_CTR_(e)); /* the ref count of the event */ 00058 QS_EQC_(me->nFree); /* number of free entries */ 00059 QS_EQC_(me->nMin); /* min number of free entries */ 00060 QS_END_NOCRIT_() 00061 00062 if (QF_EVT_POOL_ID_(e) != (uint8_t)0) { /* is it a pool event? */ 00063 QF_EVT_REF_CTR_INC_(e); /* increment the reference counter */ 00064 } 00065 00066 if (me->frontEvt == (QEvt const *)0) { /* is the queue empty? */ 00067 me->frontEvt = e; /* deliver event directly */ 00068 } 00069 else { /* queue is not empty, leave event in the ring-buffer */ 00070 /* the queue must be able to accept the event (cannot overflow) */ 00071 Q_ASSERT(me->nFree != (QEQueueCtr)0); 00072 00073 QF_PTR_AT_(me->ring, me->head) = e; /* insert e into buffer (FIFO) */ 00074 if (me->head == (QEQueueCtr)0) { /* need to wrap the head? */ 00075 me->head = me->end; /* wrap around */ 00076 } 00077 --me->head; 00078 00079 --me->nFree; /* update number of free events */ 00080 if (me->nMin > me->nFree) { 00081 me->nMin = me->nFree; /* update minimum so far */ 00082 } 00083 } 00084 QF_CRIT_EXIT_(); 00085 }
1.7.6.1