qpcpp/doxygen/snippets/qf_main.cpp
Quantum Leaps e0f9c36c2f 4.5.01
2012-08-14 18:00:48 -04:00

40 lines
1.5 KiB
C++

// 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 SmallEvents {
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[]) {
BSP_init(argc, argv); // initialize the BSP
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]));
// start the active objects...
uint8_t n;
for (n = 0; n < N_PHILO; ++n) {
AO_Philo[n]->start((uint8_t)(n + 1),
l_philoQueueSto[n], Q_DIM(l_philoQueueSto[n]),
(void *)0, 0, (QEvent *)0);
}
AO_Table->start((uint8_t)(N_PHILO + 1),
l_tableQueueSto, Q_DIM(l_tableQueueSto),
(void *)0, 0, (QEvent *)0);
QF::run(); // run the QF application
return 0;
}