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

Revision:
3:81ceb3127876
Parent:
0:efb9ac8d1a88
Child:
4:6189d844a1a2
--- a/table.cpp	Wed Feb 16 17:12:38 2011 +0000
+++ b/table.cpp	Mon Sep 26 02:21:01 2011 +0000
@@ -1,13 +1,13 @@
 //////////////////////////////////////////////////////////////////////////////
 // Product: DPP example
-// Last Updated for Version: 4.0.00
-// Date of the Last Update:  Apr 06, 2008
+// Last Updated for Version: 4.2.00
+// Date of the Last Update:  Jul 15, 2011
 //
 //                    Q u a n t u m     L e a P s
 //                    ---------------------------
 //                    innovating embedded systems
 //
-// Copyright (C) 2002-2008 Quantum Leaps, LLC. All rights reserved.
+// Copyright (C) 2002-2011 Quantum Leaps, LLC. All rights reserved.
 //
 // This software may be distributed and modified under the terms of the GNU
 // General Public License version 2 (GPL) as published by the Free Software
@@ -89,7 +89,6 @@
 
     switch (e->sig) {
         case HUNGRY_SIG: {
-            BSP_busyDelay();
             n = ((TableEvt const *)e)->philoNum;
                          // phil ID must be in range and he must be not hungry
             Q_ASSERT((n < N_PHILO) && (!me->m_isHungry[n]));
@@ -100,7 +99,7 @@
                 me->m_fork[m] = me->m_fork[n] = USED;
                 pe = Q_NEW(TableEvt, EAT_SIG);
                 pe->philoNum = n;
-                QF::publish(pe);
+                QF::PUBLISH(pe, me);
                 BSP_displyPhilStat(n, "eating  ");
             }
             else {
@@ -109,7 +108,6 @@
             return Q_HANDLED();
         }
         case DONE_SIG: {
-            BSP_busyDelay();
             n = ((TableEvt const *)e)->philoNum;
                          // phil ID must be in range and he must be not hungry
             Q_ASSERT((n < N_PHILO) && (!me->m_isHungry[n]));
@@ -126,7 +124,7 @@
                 me->m_isHungry[m] = 0;
                 pe = Q_NEW(TableEvt, EAT_SIG);
                 pe->philoNum = m;
-                QF::publish(pe);
+                QF::PUBLISH(pe, me);
                 BSP_displyPhilStat(m, "eating  ");
             }
             m = LEFT(n);                            // check the left neighbor
@@ -136,7 +134,7 @@
                 me->m_isHungry[m] = 0;
                 pe = Q_NEW(TableEvt, EAT_SIG);
                 pe->philoNum = m;
-                QF::publish(pe);
+                QF::PUBLISH(pe, me);
                 BSP_displyPhilStat(m, "eating  ");
             }
             return Q_HANDLED();