#include "qf_pkg.h"
Go to the source code of this file.
Functions | |
| void | QF_psInit (QSubscrList *subscrSto, QSignal maxSignal) |
| Publish-subscribe initialization. | |
Variables | |
| QSubscrList * | QF_subscrList_ |
| QSignal | QF_maxSignal_ |
Definition in file qf_psini.c.
| void QF_psInit | ( | QSubscrList * | subscrSto, | |
| QSignal | maxSignal | |||
| ) |
Publish-subscribe initialization.
This function initializes the publish-subscribe facilities of QF and must be called exactly once before any subscriptions/publications occur in the application. The arguments are as follows: subscrSto is a pointer to the array of subscriber-lists. maxSignal is the dimension of this array and at the same time the maximum signal that can be published or subscribed.
The array of subscriber-lists is indexed by signals and provides mapping between the signals and subscriber-lists. The subscriber-lists are bitmasks of type QSubscrList, each bit in the bitmask corresponding to the unique priority of an active object. The size of the QSubscrList bitmask depends on the value of the QF_MAX_ACTIVE macro.
/* allocate storage for active objects, event queues, event pools, * subscriber lists, and stacks. */ static QEvent const *l_tableQueueSto[N_PHILO]; static QEvent const *l_philoQueueSto[N_PHILO][N_PHILO]; static QSubscrList l_subscrSto[MAX_PUB_SIG]; static union SmallEvent { void *min_size; TableEvt te; /* other event types to go into this pool */ } l_smlPoolSto[2*N_PHILO]; /* storage for the small event pool */ /*..........................................................................*/ int main(int argc, char *argv[]) { uint8_t n; Philo_ctor(); /* instantiate all Philosopher active objects */ Table_ctor(); /* instantiate the Table active object */ BSP_init(argc, argv); /* initialize the Board Support Package */ QF_init(); /* initialize the framework and the underlying RT kernel */ QF_psInit(l_subscrSto, Q_DIM(l_subscrSto)); /* init publish-subscribe */ /* initialize event pools... */ QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0])); for (n = 0; n < N_PHILO; ++n) { /* start the active objects... */ QActive_start(AO_Philo[n], (uint8_t)(n + 1), l_philoQueueSto[n], Q_DIM(l_philoQueueSto[n]), (void *)0, 0, (QEvent *)0); } QActive_start(AO_Table, (uint8_t)(N_PHILO + 1), l_tableQueueSto, Q_DIM(l_tableQueueSto), (void *)0, 0, (QEvent *)0); QF_run(); /* run the QF application */ return 0; }
Definition at line 42 of file qf_psini.c.
References QF_maxSignal_.
the maximum published signal
Definition at line 39 of file qf_psini.c.
Referenced by QActive_subscribe(), QActive_unsubscribe(), QActive_unsubscribeAll(), QF_psInit(), and QF_publish().
the subscriber list array
Definition at line 38 of file qf_psini.c.
Referenced by QActive_subscribe(), QActive_unsubscribe(), QActive_unsubscribeAll(), and QF_publish().
1.5.4