Dining Philosophers Problem (DPP) example for the QP active object framework. Demonstrates: event-driven programming, hierarchical state machines in C++, modeling and graphical state machine design, code generation, preemptive multitasking, software tracing, power saving mode, direct event posting, publish-subscribe. More information available in the [[/users/QL/notebook|Quantum Leaps Notebook pages]]. See also [[http://www.state-machine.com|state-machine.com]].
dpp.h@4:6189d844a1a2, 2012-09-04 (annotated)
- Committer:
- QL
- Date:
- Tue Sep 04 22:41:20 2012 +0000
- Revision:
- 4:6189d844a1a2
- Parent:
- 0:efb9ac8d1a88
updated for QP 4.5.02
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
QL | 0:efb9ac8d1a88 | 1 | ////////////////////////////////////////////////////////////////////////////// |
QL | 4:6189d844a1a2 | 2 | // Model: dpp.qm |
QL | 4:6189d844a1a2 | 3 | // File: ././dpp.h |
QL | 0:efb9ac8d1a88 | 4 | // |
QL | 4:6189d844a1a2 | 5 | // This file has been generated automatically by QP Modeler (QM). |
QL | 4:6189d844a1a2 | 6 | // DO NOT EDIT THIS FILE MANUALLY. |
QL | 0:efb9ac8d1a88 | 7 | // |
QL | 4:6189d844a1a2 | 8 | // Please visit www.state-machine.com/qm for more information. |
QL | 0:efb9ac8d1a88 | 9 | ////////////////////////////////////////////////////////////////////////////// |
QL | 0:efb9ac8d1a88 | 10 | #ifndef dpp_h |
QL | 0:efb9ac8d1a88 | 11 | #define dpp_h |
QL | 0:efb9ac8d1a88 | 12 | |
QL | 4:6189d844a1a2 | 13 | namespace DPP { |
QL | 4:6189d844a1a2 | 14 | |
QL | 0:efb9ac8d1a88 | 15 | enum DPPSignals { |
QL | 4:6189d844a1a2 | 16 | EAT_SIG = QP::Q_USER_SIG, // published by Table to let a philosopher eat |
QL | 4:6189d844a1a2 | 17 | DONE_SIG, // published by Philosopher when done eating |
QL | 4:6189d844a1a2 | 18 | PAUSE_SIG, // published by BSP to pause the application |
QL | 4:6189d844a1a2 | 19 | TERMINATE_SIG, // published by BSP to terminate the application |
QL | 4:6189d844a1a2 | 20 | MAX_PUB_SIG, // the last published signal |
QL | 0:efb9ac8d1a88 | 21 | |
QL | 4:6189d844a1a2 | 22 | HUNGRY_SIG, // posted direclty to Table from hungry Philo |
QL | 4:6189d844a1a2 | 23 | MAX_SIG // the last signal |
QL | 0:efb9ac8d1a88 | 24 | }; |
QL | 0:efb9ac8d1a88 | 25 | |
QL | 4:6189d844a1a2 | 26 | // @(/1/0) ................................................................... |
QL | 4:6189d844a1a2 | 27 | class TableEvt : public QP::QEvt { |
QL | 4:6189d844a1a2 | 28 | public: |
QL | 4:6189d844a1a2 | 29 | uint8_t philoNum; |
QL | 0:efb9ac8d1a88 | 30 | }; |
QL | 0:efb9ac8d1a88 | 31 | |
QL | 4:6189d844a1a2 | 32 | // number of philosophers |
QL | 4:6189d844a1a2 | 33 | #define N_PHILO ((uint8_t)5) |
QL | 0:efb9ac8d1a88 | 34 | |
QL | 4:6189d844a1a2 | 35 | extern QP::QActive * const AO_Philo[N_PHILO]; |
QL | 4:6189d844a1a2 | 36 | extern QP::QActive * const AO_Table; |
QL | 0:efb9ac8d1a88 | 37 | |
QL | 4:6189d844a1a2 | 38 | } // namespace DPP |
QL | 4:6189d844a1a2 | 39 | |
QL | 4:6189d844a1a2 | 40 | #endif // dpp_h |