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

Committer:
QL
Date:
Sat Feb 12 23:22:47 2011 +0000
Revision:
0:efb9ac8d1a88
Child:
4:6189d844a1a2

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
QL 0:efb9ac8d1a88 1 //////////////////////////////////////////////////////////////////////////////
QL 0:efb9ac8d1a88 2 // Product: DPP example
QL 0:efb9ac8d1a88 3 // Last Updated for Version: 4.0.00
QL 0:efb9ac8d1a88 4 // Date of the Last Update: Apr 07, 2008
QL 0:efb9ac8d1a88 5 //
QL 0:efb9ac8d1a88 6 // Q u a n t u m L e a P s
QL 0:efb9ac8d1a88 7 // ---------------------------
QL 0:efb9ac8d1a88 8 // innovating embedded systems
QL 0:efb9ac8d1a88 9 //
QL 0:efb9ac8d1a88 10 // Copyright (C) 2002-2008 Quantum Leaps, LLC. All rights reserved.
QL 0:efb9ac8d1a88 11 //
QL 0:efb9ac8d1a88 12 // This software may be distributed and modified under the terms of the GNU
QL 0:efb9ac8d1a88 13 // General Public License version 2 (GPL) as published by the Free Software
QL 0:efb9ac8d1a88 14 // Foundation and appearing in the file GPL.TXT included in the packaging of
QL 0:efb9ac8d1a88 15 // this file. Please note that GPL Section 2[b] requires that all works based
QL 0:efb9ac8d1a88 16 // on this software must also be made publicly available under the terms of
QL 0:efb9ac8d1a88 17 // the GPL ("Copyleft").
QL 0:efb9ac8d1a88 18 //
QL 0:efb9ac8d1a88 19 // Alternatively, this software may be distributed and modified under the
QL 0:efb9ac8d1a88 20 // terms of Quantum Leaps commercial licenses, which expressly supersede
QL 0:efb9ac8d1a88 21 // the GPL and are specifically designed for licensees interested in
QL 0:efb9ac8d1a88 22 // retaining the proprietary status of their code.
QL 0:efb9ac8d1a88 23 //
QL 0:efb9ac8d1a88 24 // Contact information:
QL 0:efb9ac8d1a88 25 // Quantum Leaps Web site: http://www.quantum-leaps.com
QL 0:efb9ac8d1a88 26 // e-mail: info@quantum-leaps.com
QL 0:efb9ac8d1a88 27 //////////////////////////////////////////////////////////////////////////////
QL 0:efb9ac8d1a88 28 #ifndef dpp_h
QL 0:efb9ac8d1a88 29 #define dpp_h
QL 0:efb9ac8d1a88 30
QL 0:efb9ac8d1a88 31 enum DPPSignals {
QL 0:efb9ac8d1a88 32 EAT_SIG = Q_USER_SIG, // published by Table to let a philosopher eat
QL 0:efb9ac8d1a88 33 DONE_SIG, // published by Philosopher when done eating
QL 0:efb9ac8d1a88 34 TERMINATE_SIG, // published by BSP to terminate the application
QL 0:efb9ac8d1a88 35 MAX_PUB_SIG, // the last published signal
QL 0:efb9ac8d1a88 36
QL 0:efb9ac8d1a88 37 HUNGRY_SIG, // posted from hungry Philosopher to Table
QL 0:efb9ac8d1a88 38 MAX_SIG // the last signal
QL 0:efb9ac8d1a88 39 };
QL 0:efb9ac8d1a88 40
QL 0:efb9ac8d1a88 41 struct TableEvt : public QEvent {
QL 0:efb9ac8d1a88 42 uint8_t philoNum; // philosopher number
QL 0:efb9ac8d1a88 43 };
QL 0:efb9ac8d1a88 44
QL 0:efb9ac8d1a88 45 enum { N_PHILO = 5 }; // number of philosophers
QL 0:efb9ac8d1a88 46
QL 0:efb9ac8d1a88 47 extern QActive * const AO_Philo[N_PHILO]; // "opaque" pointers to Philo AO
QL 0:efb9ac8d1a88 48 extern QActive * const AO_Table; // "opaque" pointer to Table AO
QL 0:efb9ac8d1a88 49
QL 0:efb9ac8d1a88 50 #endif // dpp_h