QP/C 6.9.1
qv.c File Reference

Cooperative QV kernel, definition of QP::QV_readySet_ and implementation of kernel-specific functions. More...

#include "qf_port.h"
#include "qf_pkg.h"
#include "qassert.h"
#include "qs_port.h"
#include "qs_pkg.h"
Include dependency graph for qv.c:

Go to the source code of this file.


void QF_init (void)
 QF initialization. More...
void QF_stop (void)
 Function invoked by the application layer to stop the QF application and return control to the OS/Kernel. More...
int_t QF_run (void)
 Transfers control to QF to run the application. More...
void QActive_start_ (QActive *const me, uint_fast8_t prio, QEvt const **const qSto, uint_fast16_t const qLen, void *const stkSto, uint_fast16_t const stkSize, void const *const par)
 Implementation of the active object start operation. More...


QPSet QV_readySet_
 QV ready-set of AOs. More...

Detailed Description

Cooperative QV kernel, definition of QP::QV_readySet_ and implementation of kernel-specific functions.

Definition in file qv.c.

Function Documentation

◆ QF_init()

void QF_init ( void  )

QF initialization.

Initializes QF and must be called exactly once before any other QF function. Typically, QF_init() is called from main() even before initializing the Board Support Package (BSP).
QF_init() clears the internal QF variables, so that the framework can start correctly even if the startup code fails to clear the uninitialized data (as is required by the C Standard).

Definition at line 73 of file qv.c.

◆ QF_stop()

void QF_stop ( void  )

Function invoked by the application layer to stop the QF application and return control to the OS/Kernel.

This function stops the QF application. After calling this function, QF attempts to gracefully stop the application. This graceful shutdown might take some time to complete. The typical use of this function is for terminating the QF application to return back to the operating system or for handling fatal errors that require shutting down (and possibly re-setting) the system.
After calling QF_stop() the application must terminate and cannot continue. In particular, QF_stop() is not intended to be followed by a call to QF_init() to "resurrect" the application.
See also

Definition at line 104 of file qv.c.

◆ QF_run()

int_t QF_run ( void  )

Transfers control to QF to run the application.

QF_run() is typically called from main() after you initialize the QF and start at least one active object with QACTIVE_START().
In QV, the QF_run() function does not return.

Definition at line 117 of file qv.c.

◆ QActive_start_()

void QActive_start_ ( QActive *const  me,
uint_fast8_t  prio,
QEvt const **const  qSto,
uint_fast16_t const  qLen,
void *const  stkSto,
uint_fast16_t const  stkSize,
void const *const  par 

Implementation of the active object start operation.

Starts execution of the AO and registers the AO with the framework. Also takes the top-most initial transition in the AO's state machine. This initial transition is taken in the callee's thread of execution.
[in,out]mepointer (see Object Orientation)
[in]priopriority at which to start the active object
[in]qStopointer to the storage for the ring buffer of the event queue (used only with the built-in QEQueue)
[in]qLenlength of the event queue [events]
[in]stkStopointer to the stack storage (must be NULL in QV)
[in]stkSizestack size [bytes]
[in]parpointer to an extra parameter (might be NULL).
This function should be called via the macro QACTIVE_START().
The following example shows starting an AO when a per-task stack is needed:
#include "qpc.h"
int main() {
static Philo l_philo[N]; /* N Philo active objects */
static QEvt const *l_philQueueSto[N][N]; /* storage for event queues */
static int l_philoStk[N][256]; /* stacks for the Philo active objects */
. . .
for (n = 0; n < N; ++n) {
TableEvt ie; /* initialization event for the Philo SM */
ie.philNum = n;
QACTIVE_START((QActive *)&l_philo[n], /* Philo pointer */
(uint_fast8_t)(n*10 + 1), /* priority */
l_philoQueueSto[n], Q_DIM(l_philoQueueSto[n]), /* queue */
l_philoStk[n], sizeof(l_philoStk[n]), /* per AO stack */
&ie.super); /* initialization event */
. . .
The priority must be in range and the stack storage must not be provided, because the QV kernel does not need per-AO stacks.

Definition at line 220 of file qv.c.

Variable Documentation

◆ QV_readySet_

QPSet QV_readySet_

QV ready-set of AOs.

Definition at line 60 of file qv.c.

QP/C public interface including backwards-compatibility layer.
Define the file name (with __FILE__) for assertions in this file.
Definition: qassert.h:104
#define QACTIVE_START(me_, prio_, qSto_, qLen_, stkSto_, stkLen_, par_)
Polymorphically start an active object.
Definition: qf.h:216
#define Q_DIM(array_)
Helper macro to calculate static dimension of a 1-dim array_.
Definition: qassert.h:337
Active Object base class (based on QHsm implementation)
Definition: qf.h:116
unsigned int uint_fast8_t
fast at-least 8-bit unsigned int
Definition: 16bit/stdint.h:36
Event class.
Definition: qep.h:151