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]].

Dependencies:   mbed qp

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dpp.h Source File

dpp.h

00001 //////////////////////////////////////////////////////////////////////////////
00002 // Model: dpp.qm
00003 // File:  ././dpp.h
00004 //
00005 // This file has been generated automatically by QP Modeler (QM).
00006 // DO NOT EDIT THIS FILE MANUALLY.
00007 //
00008 // Please visit www.state-machine.com/qm for more information.
00009 //////////////////////////////////////////////////////////////////////////////
00010 #ifndef dpp_h
00011 #define dpp_h
00012 
00013 namespace DPP {
00014 
00015 enum DPPSignals {
00016     EAT_SIG = QP::Q_USER_SIG, // published by Table to let a philosopher eat
00017     DONE_SIG,                 // published by Philosopher when done eating
00018     PAUSE_SIG,                // published by BSP to pause the application
00019     TERMINATE_SIG,            // published by BSP to terminate the application
00020     MAX_PUB_SIG,              // the last published signal
00021 
00022     HUNGRY_SIG,               // posted direclty to Table from hungry Philo
00023     MAX_SIG                   // the last signal
00024 };
00025 
00026 // @(/1/0) ...................................................................
00027 class TableEvt : public QP::QEvt {
00028 public:
00029     uint8_t philoNum;
00030 };
00031 
00032 // number of philosophers
00033 #define N_PHILO ((uint8_t)5)
00034 
00035 extern QP::QActive * const AO_Philo[N_PHILO];
00036 extern QP::QActive * const AO_Table;
00037 
00038 }                             // namespace DPP
00039 
00040 #endif                        // dpp_h