QP/C  8.0.0
Real-Time Embedded Framework
Loading...
Searching...
No Matches
qf_actq.c
Go to the documentation of this file.
1//$file${src::qf::qf_actq.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2//
3// Model: qpc.qm
4// File: ${src::qf::qf_actq.c}
5//
6// This code has been generated by QM 7.0.0 <www.state-machine.com/qm>.
7// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
8//
9// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
10//
11// Q u a n t u m L e a P s
12// ------------------------
13// Modern Embedded Software
14//
15// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
16//
17// The QP/C software is dual-licensed under the terms of the open-source GNU
18// General Public License (GPL) or under the terms of one of the closed-
19// source Quantum Leaps commercial licenses.
20//
21// Redistributions in source code must retain this top-level comment block.
22// Plagiarizing this software to sidestep the license obligations is illegal.
23//
24// NOTE:
25// The GPL does NOT permit the incorporation of this code into proprietary
26// programs. Please contact Quantum Leaps for commercial licensing options,
27// which expressly supersede the GPL and are designed explicitly for
28// closed-source distribution.
29//
30// Quantum Leaps contact information:
31// <www.state-machine.com/licensing>
32// <info@state-machine.com>
33//
34//$endhead${src::qf::qf_actq.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35#define QP_IMPL // this is QP implementation
36#include "qp_port.h" // QP port
37#include "qp_pkg.h" // QP package-scope interface
38#include "qsafe.h" // QP Functional Safety (FuSa) Subsystem
39#ifdef Q_SPY // QS software tracing enabled?
40 #include "qs_port.h" // QS port
41 #include "qs_pkg.h" // QS facilities for pre-defined trace records
42#else
43 #include "qs_dummy.h" // disable the QS software tracing
44#endif // Q_SPY
45
46Q_DEFINE_THIS_MODULE("qf_actq")
47
48//============================================================================
49//$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
50// Check for the minimum required QP version
51#if (QP_VERSION < 730U) || (QP_VERSION != ((QP_RELEASE^4294967295U)%0x2710U))
52#error qpc version 7.3.0 or higher required
53#endif
54//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55//$define${QF::QActive::post_} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
56
57//${QF::QActive::post_} ......................................................
58//! @private @memberof QActive
59bool QActive_post_(QActive * const me,
60 QEvt const * const e,
61 uint_fast16_t const margin,
62 void const * const sender)
63{
64 #ifndef Q_SPY
65 Q_UNUSED_PAR(sender);
66 #endif
67
68 #ifdef Q_UTEST // test?
69 #if (Q_UTEST != 0) // testing QP-stub?
70 if (me->super.temp.fun == Q_STATE_CAST(0)) { // QActiveDummy?
71 return QActiveDummy_fakePost_(me, e, margin, sender);
72 }
73 #endif // (Q_UTEST != 0)
74 #endif // def Q_UTEST
75
78 QF_MEM_SYS();
79
80 Q_REQUIRE_INCRIT(200, e != (QEvt *)0);
81
82 QEQueueCtr tmp = me->eQueue.nFree; // get volatile into temporary
83 #ifndef Q_UNSAFE
84 QEQueueCtr dis = (QEQueueCtr)~me->eQueue.nFree_dis;
85 Q_INVARIANT_INCRIT(201, (QEvt_verify_(e)) && (tmp == dis));
86 #endif // ndef Q_UNSAFE
87
88 // test-probe#1 for faking queue overflow
89 QS_TEST_PROBE_DEF(&QActive_post_)
91 tmp = 0U; // fake no free events
92 )
93
94 // required margin available?
95 bool status;
96 if (margin == QF_NO_MARGIN) {
97 if (tmp > 0U) { // free entries available in the queue?
98 status = true; // can post
99 }
100 else { // no free entries available
101 status = false; // cannot post
102
103 // The queue overflows, but QF_NO_MARGIN indicates that
104 // the "event delivery guarantee" is required.
105 Q_ERROR_INCRIT(210); // must be able to post the event
106 }
107 }
108 else if (tmp > (QEQueueCtr)margin) { // enough free entries?
109 status = true; // can post
110 }
111 else { // the # free entries below the requested margin
112 status = false; // cannot post, but don't assert
113 }
114
115 // is it a mutable event?
116 if (QEvt_getPoolNum_(e) != 0U) {
117 QEvt_refCtr_inc_(e); // increment the reference counter
118 }
119
120 if (status) { // can post the event?
121 --tmp; // one free entry just used up
122
123 me->eQueue.nFree = tmp; // update the original
124 #ifndef Q_UNSAFE
125 me->eQueue.nFree_dis = (QEQueueCtr)~tmp; // update the DIS
126
127 if (me->eQueue.nMin > tmp) {
128 me->eQueue.nMin = tmp; // update minimum so far
129 }
130 #endif // ndef Q_UNSAFE
131
132 QS_BEGIN_PRE(QS_QF_ACTIVE_POST, me->prio)
133 QS_TIME_PRE(); // timestamp
134 QS_OBJ_PRE(sender); // the sender object
135 QS_SIG_PRE(e->sig); // the signal of the event
136 QS_OBJ_PRE(me); // this active object (recipient)
137 QS_2U8_PRE(QEvt_getPoolNum_(e), e->refCtr_);
138 QS_EQC_PRE(tmp); // # free entries
139 #ifndef Q_UNSAFE
140 QS_EQC_PRE(me->eQueue.nMin); // min # free entries
141 #else
142 QS_EQC_PRE(0U); // min # free entries
143 #endif
144 QS_END_PRE()
145
146 #ifdef Q_UTEST
147 // callback to examine the posted event under the same conditions
148 // as producing the #QS_QF_ACTIVE_POST trace record, which are:
149 // the local filter for this AO ('me->prio') is set
150 if (QS_LOC_CHECK_(me->prio)) {
151 QF_MEM_APP();
152 QF_CRIT_EXIT();
153
154 QS_onTestPost(sender, me, e, status);
155
157 QF_MEM_SYS();
158 }
159 #endif // def Q_UTEST
160
161 if (me->eQueue.frontEvt == (QEvt *)0) { // is the queue empty?
162 me->eQueue.frontEvt = e; // deliver event directly
163 #ifndef Q_UNSAFE
164 Q_INVARIANT_INCRIT(211, me->eQueue.frontEvt_dis
165 == (uintptr_t)~Q_PTR2UINT_CAST_((QEvt *)0));
166 me->eQueue.frontEvt_dis = (uintptr_t)~Q_PTR2UINT_CAST_(e);
167 #endif // ndef Q_UNSAFE
168
169 #ifdef QXK_H_
170 if (me->super.state.act == Q_ACTION_CAST(0)) { // eXtended?
171 QXTHREAD_EQUEUE_SIGNAL_(me); // signal eXtended Thread
172 }
173 else {
174 QACTIVE_EQUEUE_SIGNAL_(me); // signal the Active Object
175 }
176 #else
177 QACTIVE_EQUEUE_SIGNAL_(me); // signal the Active Object
178 #endif // def QXK_H_
179 }
180 else { // queue was not empty, insert event into the ring-buffer
181 tmp = me->eQueue.head; // get volatile into temporary
182 #ifndef Q_UNSAFE
183 dis = (QEQueueCtr)~me->eQueue.head_dis;
184 Q_INVARIANT_INCRIT(212, tmp == dis);
185 #endif // ndef Q_UNSAFE
186 me->eQueue.ring[tmp] = e; // insert e into buffer
187
188 if (tmp == 0U) { // need to wrap the head?
189 tmp = me->eQueue.end;
190 }
191 --tmp; // advance the head (counter-clockwise)
192
193 me->eQueue.head = tmp; // update the original
194 #ifndef Q_UNSAFE
195 me->eQueue.head_dis = (QEQueueCtr)~tmp;
196 #endif // ndef Q_UNSAFE
197 }
198
199 QF_MEM_APP();
200 QF_CRIT_EXIT();
201 }
202 else { // event cannot be posted
203
204 QS_BEGIN_PRE(QS_QF_ACTIVE_POST_ATTEMPT, me->prio)
205 QS_TIME_PRE(); // timestamp
206 QS_OBJ_PRE(sender); // the sender object
207 QS_SIG_PRE(e->sig); // the signal of the event
208 QS_OBJ_PRE(me); // this active object (recipient)
209 QS_2U8_PRE(QEvt_getPoolNum_(e), e->refCtr_);
210 QS_EQC_PRE(tmp); // # free entries
211 QS_EQC_PRE(margin); // margin requested
212 QS_END_PRE()
213
214 #ifdef Q_UTEST
215 // callback to examine the posted event under the same conditions
216 // as producing the #QS_QF_ACTIVE_POST trace record, which are:
217 // the local filter for this AO ('me->prio') is set
218 if (QS_LOC_CHECK_(me->prio)) {
219 QF_MEM_APP();
220 QF_CRIT_EXIT();
221
222 QS_onTestPost(sender, me, e, status);
223
225 QF_MEM_SYS();
226 }
227 #endif // def Q_USTEST
228
229 QF_MEM_APP();
230 QF_CRIT_EXIT();
231
232 #if (QF_MAX_EPOOL > 0U)
233 QF_gc(e); // recycle the event to avoid a leak
234 #endif // (QF_MAX_EPOOL > 0U)
235 }
236
237 return status;
238}
239//$enddef${QF::QActive::post_} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
240//$define${QF::QActive::postLIFO_} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
241
242//${QF::QActive::postLIFO_} ..................................................
243//! @private @memberof QActive
244void QActive_postLIFO_(QActive * const me,
245 QEvt const * const e)
246{
247 #ifdef Q_UTEST // test?
248 #if (Q_UTEST != 0) // testing QP-stub?
249 if (me->super.temp.fun == Q_STATE_CAST(0)) { // QActiveDummy?
250 QActiveDummy_fakePostLIFO_(me, e);
251 return;
252 }
253 #endif // (Q_UTEST != 0)
254 #endif // def Q_UTEST
255
258 QF_MEM_SYS();
259
260 // the posted event must be be valid (which includes not NULL)
261 Q_REQUIRE_INCRIT(300, e != (QEvt *)0);
262
263 QEQueueCtr tmp = me->eQueue.nFree; // get volatile into temporary
264 #ifndef Q_UNSAFE
265 QEQueueCtr dis = (QEQueueCtr)~me->eQueue.nFree_dis;
266 Q_INVARIANT_INCRIT(301, (QEvt_verify_(e)) && (tmp == dis));
267 #endif // ndef Q_UNSAFE
268
269 // test-probe#1 for faking queue overflow
270 QS_TEST_PROBE_DEF(&QActive_postLIFO_)
272 tmp = 0U; // fake no free events
273 )
274
275 // The queue must NOT overflow for the LIFO posting policy.
276 Q_REQUIRE_INCRIT(310, tmp != 0U);
277
278 if (QEvt_getPoolNum_(e) != 0U) { // is it a mutable event?
279 QEvt_refCtr_inc_(e); // increment the reference counter
280 }
281
282 --tmp; // one free entry just used up
283
284 me->eQueue.nFree = tmp; // update the original
285 #ifndef Q_UNSAFE
286 me->eQueue.nFree_dis = (QEQueueCtr)~tmp;
287
288 if (me->eQueue.nMin > tmp) {
289 me->eQueue.nMin = tmp; // update minimum so far
290 }
291 #endif // ndef Q_UNSAFE
292
293 QS_BEGIN_PRE(QS_QF_ACTIVE_POST_LIFO, me->prio)
294 QS_TIME_PRE(); // timestamp
295 QS_SIG_PRE(e->sig); // the signal of this event
296 QS_OBJ_PRE(me); // this active object
297 QS_2U8_PRE(QEvt_getPoolNum_(e), e->refCtr_);
298 QS_EQC_PRE(tmp); // # free entries
299 #ifndef Q_UNSAFE
300 QS_EQC_PRE(me->eQueue.nMin); // min # free entries
301 #else
302 QS_EQC_PRE(0U); // min # free entries
303 #endif
304 QS_END_PRE()
305
306 #ifdef Q_UTEST
307 // callback to examine the posted event under the same conditions
308 // as producing the #QS_QF_ACTIVE_POST trace record, which are:
309 // the local filter for this AO ('me->prio') is set
310 if (QS_LOC_CHECK_(me->prio)) {
311 QF_MEM_APP();
312 QF_CRIT_EXIT();
313
314 QS_onTestPost((QActive *)0, me, e, true);
315
317 QF_MEM_SYS();
318 }
319 #endif // def Q_UTEST
320
321 QEvt const * const frontEvt = me->eQueue.frontEvt;
322 me->eQueue.frontEvt = e; // deliver the event directly to the front
323 #ifndef Q_UNSAFE
324 me->eQueue.frontEvt_dis = (uintptr_t)~Q_PTR2UINT_CAST_(e);
325 #endif // ndef Q_UNSAFE
326
327 if (frontEvt != (QEvt *)0) { // was the queue NOT empty?
328 tmp = me->eQueue.tail; // get volatile into temporary;
329 #ifndef Q_UNSAFE
330 dis = (QEQueueCtr)~me->eQueue.tail_dis;
331 Q_INVARIANT_INCRIT(311, tmp == dis);
332 #endif // ndef Q_UNSAFE
333 ++tmp;
334 if (tmp == me->eQueue.end) { // need to wrap the tail?
335 tmp = 0U; // wrap around
336 }
337 me->eQueue.tail = tmp;
338 #ifndef Q_UNSAFE
339 me->eQueue.tail_dis = (QEQueueCtr)~tmp;
340 #endif // ndef Q_UNSAFE
341 me->eQueue.ring[tmp] = frontEvt;
342 }
343 else { // queue was empty
344 QACTIVE_EQUEUE_SIGNAL_(me); // signal the event queue
345 }
346
347 QF_MEM_APP();
348 QF_CRIT_EXIT();
349}
350//$enddef${QF::QActive::postLIFO_} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
351//$define${QF::QActive::get_} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
352
353//${QF::QActive::get_} .......................................................
354//! @private @memberof QActive
355QEvt const * QActive_get_(QActive * const me) {
358 QF_MEM_SYS();
359
360 // wait for event to arrive directly (depends on QP port)
361 // NOTE: might use assertion-IDs 400-409
363
364 // always remove event from the front
365 QEvt const * const e = me->eQueue.frontEvt;
366 QEQueueCtr tmp = me->eQueue.nFree; // get volatile into temporary
367
368 #ifndef Q_UNSAFE
369 Q_INVARIANT_INCRIT(410, e != (QEvt *)0); // queue must NOT be empty
371 == (uintptr_t)~me->eQueue.frontEvt_dis);
372 QEQueueCtr dis = (QEQueueCtr)~me->eQueue.nFree_dis;
373 Q_INVARIANT_INCRIT(412, tmp == dis);
374 #endif // ndef Q_UNSAFE
375
376 ++tmp; // one more free event in the queue
377
378 me->eQueue.nFree = tmp; // update the # free
379 #ifndef Q_UNSAFE
380 me->eQueue.nFree_dis = (QEQueueCtr)~tmp;
381 #endif // ndef Q_UNSAFE
382
383 if (tmp <= me->eQueue.end) { // any events in the ring buffer?
384
385 QS_BEGIN_PRE(QS_QF_ACTIVE_GET, me->prio)
386 QS_TIME_PRE(); // timestamp
387 QS_SIG_PRE(e->sig); // the signal of this event
388 QS_OBJ_PRE(me); // this active object
389 QS_2U8_PRE(QEvt_getPoolNum_(e), e->refCtr_);
390 QS_EQC_PRE(tmp); // # free entries
391 QS_END_PRE()
392
393 // remove event from the tail
394 tmp = me->eQueue.tail; // get volatile into temporary
395 #ifndef Q_UNSAFE
396 dis = (QEQueueCtr)~me->eQueue.tail_dis;
397 Q_INVARIANT_INCRIT(420, tmp == dis);
398 #endif // ndef Q_UNSAFE
399 QEvt const * const frontEvt = me->eQueue.ring[tmp];
400 #ifndef Q_UNSAFE
401 Q_ASSERT_INCRIT(421, frontEvt != (QEvt *)0);
402 me->eQueue.frontEvt_dis = (uintptr_t)~Q_PTR2UINT_CAST_(frontEvt);
403 #endif // ndef Q_UNSAFE
404 me->eQueue.frontEvt = frontEvt; // update the original
405
406 if (tmp == 0U) { // need to wrap the tail?
407 tmp = me->eQueue.end;
408 }
409 --tmp; // advance the tail (counter-clockwise)
410
411 me->eQueue.tail = tmp; // update the original
412 #ifndef Q_UNSAFE
413 me->eQueue.tail_dis = (QEQueueCtr)~tmp;
414 #endif // ndef Q_UNSAFE
415 }
416 else {
417 me->eQueue.frontEvt = (QEvt *)0; // queue becomes empty
418 #ifndef Q_UNSAFE
419 me->eQueue.frontEvt_dis = (uintptr_t)~Q_PTR2UINT_CAST_((QEvt *)0);
420 #endif // ndef Q_UNSAFE
421
422 // all entries in the queue must be free (+1 for fronEvt)
423 Q_ASSERT_INCRIT(440, tmp == (me->eQueue.end + 1U));
424
425 QS_BEGIN_PRE(QS_QF_ACTIVE_GET_LAST, me->prio)
426 QS_TIME_PRE(); // timestamp
427 QS_SIG_PRE(e->sig); // the signal of this event
428 QS_OBJ_PRE(me); // this active object
429 QS_2U8_PRE(QEvt_getPoolNum_(e), e->refCtr_);
430 QS_END_PRE()
431 }
432
433 QF_MEM_APP();
434 QF_CRIT_EXIT();
435
436 return e;
437}
438//$enddef${QF::QActive::get_} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
439
440//$define${QF::QF-base::getQueueMin} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
441
442//${QF::QF-base::getQueueMin} ................................................
443//! @static @public @memberof QF
444uint_fast16_t QF_getQueueMin(uint_fast8_t const prio) {
447 Q_REQUIRE_INCRIT(400, (prio <= QF_MAX_ACTIVE)
448 && (QActive_registry_[prio] != (QActive *)0));
449 #ifndef Q_UNSAFE
450 uint_fast16_t const min =
451 (uint_fast16_t)QActive_registry_[prio]->eQueue.nMin;
452 #else
453 uint_fast16_t const min = 0U;
454 #endif
455 QF_CRIT_EXIT();
456
457 return min;
458}
459//$enddef${QF::QF-base::getQueueMin} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
460//$define${QF::QTicker} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
461
462//${QF::QTicker} .............................................................
463
464//${QF::QTicker::ctor} .......................................................
465//! @public @memberof QTicker
466void QTicker_ctor(QTicker * const me,
467 uint_fast8_t const tickRate)
468{
469 QActive_ctor(&me->super, Q_STATE_CAST(0)); // superclass' ctor
470
471 static struct QAsmVtable const vtable = { // QTicker virtual table
472 &QTicker_init_,
473 &QTicker_dispatch_,
474 &QHsm_isIn_
475 #ifdef Q_SPY
476 ,&QHsm_getStateHandler_
477 #endif
478 };
479 me->super.super.vptr = &vtable; // hook the vptr
480
481 // reuse eQueue.head for tick-rate
482 me->super.eQueue.head = (QEQueueCtr)tickRate;
483 #ifndef Q_UNSAFE
484 me->super.eQueue.head_dis = (QEQueueCtr)~tickRate;
485 #endif // ndef Q_UNSAFE
486}
487
488//${QF::QTicker::init_} ......................................................
489//! @private @memberof QTicker
490void QTicker_init_(
491 QAsm * const me,
492 void const * const par,
493 uint_fast8_t const qsId)
494{
495 Q_UNUSED_PAR(me);
496 Q_UNUSED_PAR(par);
497 Q_UNUSED_PAR(qsId);
498
501 QF_MEM_SYS();
502
503 QACTIVE_CAST_(me)->eQueue.tail = 0U;
504 #ifndef Q_UNSAFE
505 QACTIVE_CAST_(me)->eQueue.tail_dis = (QEQueueCtr)~0U;
506 #endif // ndef Q_UNSAFE
507
508 QF_MEM_APP();
509 QF_CRIT_EXIT();
510}
511
512//${QF::QTicker::dispatch_} ..................................................
513//! @private @memberof QTicker
514void QTicker_dispatch_(
515 QAsm * const me,
516 QEvt const * const e,
517 uint_fast8_t const qsId)
518{
519 Q_UNUSED_PAR(e);
520 Q_UNUSED_PAR(qsId);
521
524 QF_MEM_SYS();
525
526 // get volatile into temporaries
527 QEQueueCtr nTicks = QACTIVE_CAST_(me)->eQueue.tail;
528 QEQueueCtr const tickRate = QACTIVE_CAST_(me)->eQueue.head;
529
530 #ifndef Q_UNSAFE
531 Q_REQUIRE_INCRIT(700, nTicks > 0U);
532 QEQueueCtr dis = (QEQueueCtr)~QACTIVE_CAST_(me)->eQueue.tail_dis;
533 Q_INVARIANT_INCRIT(701, nTicks == dis);
534 dis = (QEQueueCtr)~QACTIVE_CAST_(me)->eQueue.head_dis;
535 Q_INVARIANT_INCRIT(702, tickRate == dis);
536 #endif // ndef Q_UNSAFE
537
538 QACTIVE_CAST_(me)->eQueue.tail = 0U; // clear # ticks
539 #ifndef Q_UNSAFE
540 QACTIVE_CAST_(me)->eQueue.tail_dis = (QEQueueCtr)~0U;
541 #endif // ndef Q_UNSAFE
542
543 QF_MEM_APP();
544 QF_CRIT_EXIT();
545
546 for (; nTicks > 0U; --nTicks) {
547 QTimeEvt_tick_((uint_fast8_t)tickRate, me);
548 }
549}
550
551//${QF::QTicker::trig_} ......................................................
552//! @private @memberof QTicker
553void QTicker_trig_(
554 QActive * const me,
555 void const * const sender)
556{
557 #ifndef Q_SPY
558 Q_UNUSED_PAR(sender);
559 #endif
560
561 static QEvt const tickEvt = QEVT_INITIALIZER(0);
562
565 QF_MEM_SYS();
566
567 QEQueueCtr nTicks = me->eQueue.tail; // get volatile into temporary
568
569 if (me->eQueue.frontEvt == (QEvt *)0) { // no tick events?
570 #ifndef Q_UNSAFE
571 Q_REQUIRE_INCRIT(800, nTicks == 0U);
572 Q_REQUIRE_INCRIT(801, me->eQueue.nFree == 1U);
573 Q_INVARIANT_INCRIT(802, me->eQueue.frontEvt_dis
574 == (uintptr_t)~Q_PTR2UINT_CAST_((QEvt *)0));
575 QEQueueCtr dis = (QEQueueCtr)~me->eQueue.nFree_dis;
576 Q_INVARIANT_INCRIT(803, 1U == dis);
577 dis = (QEQueueCtr)~me->eQueue.tail_dis;
578 Q_INVARIANT_INCRIT(804, 0U == dis);
579 #endif // ndef Q_UNSAFE
580
581 me->eQueue.frontEvt = &tickEvt; // deliver event directly
582 me->eQueue.nFree = 0U;
583 #ifndef Q_UNSAFE
584 me->eQueue.frontEvt_dis = (uintptr_t)~Q_PTR2UINT_CAST_(&tickEvt);
585 me->eQueue.nFree_dis = (QEQueueCtr)~0U;
586 #endif // ndef Q_UNSAFE
587
588 QACTIVE_EQUEUE_SIGNAL_(me); // signal the event queue
589 }
590 else {
591 #ifndef Q_UNSAFE
592 Q_REQUIRE_INCRIT(810, (nTicks > 0U) && (nTicks < 0xFFU));
593 Q_REQUIRE_INCRIT(811, me->eQueue.nFree == 0U);
594 Q_INVARIANT_INCRIT(812, me->eQueue.frontEvt_dis
595 == (uintptr_t)~Q_PTR2UINT_CAST_(&tickEvt));
596 QEQueueCtr dis = (QEQueueCtr)~me->eQueue.nFree_dis;
597 Q_INVARIANT_INCRIT(813, 0U == dis);
598 dis = (QEQueueCtr)~me->eQueue.tail_dis;
599 Q_INVARIANT_INCRIT(814, nTicks == dis);
600 #endif // ndef Q_UNSAFE
601 }
602
603 ++nTicks; // account for one more tick event
604
605 me->eQueue.tail = nTicks; // update the original
606 #ifndef Q_UNSAFE
607 me->eQueue.tail_dis = (QEQueueCtr)~nTicks;
608 #endif // ndef Q_UNSAFE
609
610 QS_BEGIN_PRE(QS_QF_ACTIVE_POST, me->prio)
611 QS_TIME_PRE(); // timestamp
612 QS_OBJ_PRE(sender); // the sender object
613 QS_SIG_PRE(0U); // the signal of the event
614 QS_OBJ_PRE(me); // this active object
615 QS_2U8_PRE(0U, 0U); // poolNum & refCtr
616 QS_EQC_PRE(0U); // # free entries
617 QS_EQC_PRE(0U); // min # free entries
618 QS_END_PRE()
619
620 QF_MEM_APP();
621 QF_CRIT_EXIT();
622}
623//$enddef${QF::QTicker} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
uint16_t QEQueueCtr
Definition qequeue.h:45
#define QACTIVE_EQUEUE_SIGNAL_(me_)
Definition qk.h:161
#define QACTIVE_EQUEUE_WAIT_(me_)
Definition qk.h:157
#define QF_MEM_APP()
Definition qp.h:1276
#define Q_UNUSED_PAR(par_)
Helper macro to clearly mark unused parameters of functions.
Definition qp.h:521
#define QF_NO_MARGIN
Special value of margin that causes asserting failure in case event allocation or event posting fails...
Definition qp.h:1151
#define Q_STATE_CAST(handler_)
Perform cast to QStateHandler.
Definition qp.h:515
#define Q_ACTION_CAST(action_)
Perform cast to QActionHandler.
Definition qp.h:518
#define QF_MEM_SYS()
Definition qp.h:1271
#define QEVT_INITIALIZER(sig_)
Initializer for immutable (constant) QEvt instances.
Definition qp.h:430
#define QF_MAX_ACTIVE
Maximum # Active Objects in the system (1..64)
Definition qp_config.h:123
Internal (package scope) QP/C interface.
#define Q_PTR2UINT_CAST_(ptr_)
Definition qp_pkg.h:95
#define QACTIVE_CAST_(ptr_)
Definition qp_pkg.h:94
Sample QP/C port.
void QS_onTestPost(void const *sender, QActive *recipient, QEvt const *e, bool status)
#define QS_OBJ_PRE(obj_)
Definition qs_dummy.h:150
#define QS_EQC_PRE(ctr_)
Definition qs_dummy.h:152
#define QS_SIG_PRE(sig_)
Definition qs_dummy.h:148
#define QS_TIME_PRE()
Definition qs_dummy.h:147
#define QS_2U8_PRE(data1_, data2_)
Definition qs_dummy.h:144
#define QS_TEST_PROBE_DEF(fun_)
Definition qs_dummy.h:78
#define QS_TEST_PROBE_ID(id_, code_)
Definition qs_dummy.h:80
#define QS_END_PRE()
Definition qs_dummy.h:142
#define QS_BEGIN_PRE(rec_, qsId_)
Definition qs_dummy.h:141
Sample QS/C port.
QP Functional Safety (FuSa) Subsystem.
#define QF_CRIT_ENTRY()
Definition qsafe.h:50
#define Q_ASSERT_INCRIT(id_, expr_)
Definition qsafe.h:64
#define Q_INVARIANT_INCRIT(id_, expr_)
Definition qsafe.h:146
#define QF_CRIT_EXIT()
Definition qsafe.h:54
#define Q_REQUIRE_INCRIT(id_, expr_)
Definition qsafe.h:128
#define Q_ERROR_INCRIT(id_)
Definition qsafe.h:68
#define QF_CRIT_STAT
Definition qsafe.h:46
Active object class (based on the QHsm implementation strategy)
Definition qp.h:775
QACTIVE_EQUEUE_TYPE eQueue
Port-dependent event-queue type (often QEQueue)
Definition qp.h:797
QAsm super
Definition qp.h:777
uint8_t prio
QF-priority [1..QF_MAX_ACTIVE] of this AO.
Definition qp.h:780
Abstract State Machine class (state machine interface)
Definition qp.h:256
struct QAsmVtable const * vptr
Virtual pointer inherited by all QAsm subclasses (see also Object Orientation)
Definition qp.h:260
union QAsmAttr temp
Temporary storage for target/act-table etc.
Definition qp.h:268
Virtual table for the QAsm class.
Definition qp.h:277
Event class.
Definition qp.h:131
QSignal sig
Signal of the event (see Event Signal)
Definition qp.h:135
uint8_t volatile refCtr_
Event reference counter.
Definition qp.h:143
"Ticker" Active Object class
Definition qp.h:1039
QActive super
Definition qp.h:1041
QStateHandler fun
Definition qp.h:244