dpp.qm 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <model version="5.2.5" links="1">
  3. <documentation>Dining Philosopher Problem example</documentation>
  4. <!--${qpc}-->
  5. <framework name="qpc"/>
  6. <!--${Events}-->
  7. <package name="Events" stereotype="0x01">
  8. <!--${Events::TableEvt}-->
  9. <class name="TableEvt" superclass="qpc::QEvt">
  10. <!--${Events::TableEvt::philoNum}-->
  11. <attribute name="philoNum" type="uint8_t" visibility="0x00" properties="0x00"/>
  12. </class>
  13. </package>
  14. <!--${AOs}-->
  15. <package name="AOs" stereotype="0x02">
  16. <!--${AOs::Philo}-->
  17. <class name="Philo" superclass="qpc::QActive">
  18. <!--${AOs::Philo::inst[N_PHILO]}-->
  19. <attribute name="inst[N_PHILO]" type="Philo" visibility="0x00" properties="0x01">
  20. <documentation>The array of static insts of the Philo class (Singleton pattern)</documentation>
  21. </attribute>
  22. <!--${AOs::Philo::timeEvt}-->
  23. <attribute name="timeEvt" type="QTimeEvt" visibility="0x02" properties="0x00"/>
  24. <!--${AOs::Philo::SM}-->
  25. <statechart properties="0x01">
  26. <!--${AOs::Philo::SM::initial}-->
  27. <initial target="../1">
  28. <action>static uint8_t registered = (uint8_t)0; /* starts off with 0, per C-standard */
  29. (void)par; /* unused parameter */
  30. if (registered == (uint8_t)0) {
  31. registered = (uint8_t)1;
  32. QS_OBJ_DICTIONARY(&amp;Philo_inst[0]);
  33. QS_OBJ_DICTIONARY(&amp;Philo_inst[0].timeEvt);
  34. QS_OBJ_DICTIONARY(&amp;Philo_inst[1]);
  35. QS_OBJ_DICTIONARY(&amp;Philo_inst[1].timeEvt);
  36. QS_OBJ_DICTIONARY(&amp;Philo_inst[2]);
  37. QS_OBJ_DICTIONARY(&amp;Philo_inst[2].timeEvt);
  38. QS_OBJ_DICTIONARY(&amp;Philo_inst[3]);
  39. QS_OBJ_DICTIONARY(&amp;Philo_inst[3].timeEvt);
  40. QS_OBJ_DICTIONARY(&amp;Philo_inst[4]);
  41. QS_OBJ_DICTIONARY(&amp;Philo_inst[4].timeEvt);
  42. QS_FUN_DICTIONARY(&amp;Philo_initial);
  43. QS_FUN_DICTIONARY(&amp;Philo_thinking);
  44. QS_FUN_DICTIONARY(&amp;Philo_hungry);
  45. QS_FUN_DICTIONARY(&amp;Philo_eating);
  46. }
  47. QS_SIG_DICTIONARY(HUNGRY_SIG, me); /* signal for each Philos */
  48. QS_SIG_DICTIONARY(TIMEOUT_SIG, me); /* signal for each Philos */
  49. QActive_subscribe(&amp;me-&gt;super, EAT_SIG);
  50. QActive_subscribe(&amp;me-&gt;super, TEST_SIG);</action>
  51. <initial_glyph conn="2,3,5,1,20,5,-3">
  52. <action box="0,-2,6,2"/>
  53. </initial_glyph>
  54. </initial>
  55. <!--${AOs::Philo::SM::thinking}-->
  56. <state name="thinking">
  57. <entry>QTimeEvt_armX(&amp;me-&gt;timeEvt, THINK_TIME, 0U);</entry>
  58. <exit>QTimeEvt_disarm(&amp;me-&gt;timeEvt);</exit>
  59. <!--${AOs::Philo::SM::thinking::TIMEOUT}-->
  60. <tran trig="TIMEOUT" target="../../2">
  61. <tran_glyph conn="2,13,3,1,20,12,-3">
  62. <action box="0,-2,6,2"/>
  63. </tran_glyph>
  64. </tran>
  65. <!--${AOs::Philo::SM::thinking::EAT, DONE}-->
  66. <tran trig="EAT, DONE">
  67. <action>/* EAT or DONE must be for other Philos than this one */
  68. Q_ASSERT(Q_EVT_CAST(TableEvt)-&gt;philoNum != PHILO_ID(me));</action>
  69. <tran_glyph conn="2,17,3,-1,13">
  70. <action box="0,-2,14,2"/>
  71. </tran_glyph>
  72. </tran>
  73. <!--${AOs::Philo::SM::thinking::TEST}-->
  74. <tran trig="TEST">
  75. <tran_glyph conn="2,20,3,-1,13">
  76. <action box="0,-2,11,4"/>
  77. </tran_glyph>
  78. </tran>
  79. <state_glyph node="2,5,17,16">
  80. <entry box="1,2,5,2"/>
  81. <exit box="1,4,6,2"/>
  82. </state_glyph>
  83. </state>
  84. <!--${AOs::Philo::SM::hungry}-->
  85. <state name="hungry">
  86. <entry>TableEvt *pe = Q_NEW(TableEvt, HUNGRY_SIG);
  87. pe-&gt;philoNum = PHILO_ID(me);
  88. QACTIVE_POST(AO_Table, &amp;pe-&gt;super, me);</entry>
  89. <!--${AOs::Philo::SM::hungry::EAT}-->
  90. <tran trig="EAT">
  91. <!--${AOs::Philo::SM::hungry::EAT::[Q_EVT_CAST(TableEvt)->philoNum=~}-->
  92. <choice target="../../../3">
  93. <guard>Q_EVT_CAST(TableEvt)-&gt;philoNum == PHILO_ID(me)</guard>
  94. <choice_glyph conn="15,30,5,1,7,13,-3">
  95. <action box="1,0,19,4"/>
  96. </choice_glyph>
  97. </choice>
  98. <tran_glyph conn="2,30,3,-1,13">
  99. <action box="0,-2,14,2"/>
  100. </tran_glyph>
  101. </tran>
  102. <!--${AOs::Philo::SM::hungry::DONE}-->
  103. <tran trig="DONE">
  104. <action>/* DONE must be for other Philos than this one */
  105. Q_ASSERT(Q_EVT_CAST(TableEvt)-&gt;philoNum != PHILO_ID(me));</action>
  106. <tran_glyph conn="2,36,3,-1,14">
  107. <action box="0,-2,14,2"/>
  108. </tran_glyph>
  109. </tran>
  110. <state_glyph node="2,23,17,16">
  111. <entry box="1,2,5,2"/>
  112. </state_glyph>
  113. </state>
  114. <!--${AOs::Philo::SM::eating}-->
  115. <state name="eating">
  116. <entry>QTimeEvt_armX(&amp;me-&gt;timeEvt, EAT_TIME, 0U);</entry>
  117. <exit>TableEvt *pe = Q_NEW(TableEvt, DONE_SIG);
  118. pe-&gt;philoNum = PHILO_ID(me);
  119. QACTIVE_PUBLISH(&amp;pe-&gt;super, &amp;me-&gt;super);</exit>
  120. <!--${AOs::Philo::SM::eating::TIMEOUT}-->
  121. <tran trig="TIMEOUT" target="../../1">
  122. <tran_glyph conn="2,51,3,1,22,-41,-5">
  123. <action box="0,-2,6,2"/>
  124. </tran_glyph>
  125. </tran>
  126. <!--${AOs::Philo::SM::eating::EAT, DONE}-->
  127. <tran trig="EAT, DONE">
  128. <action>/* EAT or DONE must be for other Philos than this one */
  129. Q_ASSERT(Q_EVT_CAST(TableEvt)-&gt;philoNum != PHILO_ID(me));</action>
  130. <tran_glyph conn="2,55,3,-1,13">
  131. <action box="0,-2,14,2"/>
  132. </tran_glyph>
  133. </tran>
  134. <state_glyph node="2,41,17,18">
  135. <entry box="1,2,5,2"/>
  136. <exit box="1,4,5,2"/>
  137. </state_glyph>
  138. </state>
  139. <state_diagram size="37,61"/>
  140. </statechart>
  141. </class>
  142. <!--${AOs::Table}-->
  143. <class name="Table" superclass="qpc::QActive">
  144. <!--${AOs::Table::inst}-->
  145. <attribute name="inst" type="Table" visibility="0x00" properties="0x01">
  146. <documentation>The only static inst of the Table class (Singleton pattern)</documentation>
  147. </attribute>
  148. <!--${AOs::Table::fork[N_PHILO]}-->
  149. <attribute name="fork[N_PHILO]" type="uint8_t" visibility="0x02" properties="0x00"/>
  150. <!--${AOs::Table::isHungry[N_PHILO]}-->
  151. <attribute name="isHungry[N_PHILO]" type="uint8_t" visibility="0x02" properties="0x00"/>
  152. <!--${AOs::Table::SM}-->
  153. <statechart properties="0x03">
  154. <!--${AOs::Table::SM::initial}-->
  155. <initial target="../1/2">
  156. <action>uint8_t n;
  157. (void)par; /* unused parameter */
  158. QS_OBJ_DICTIONARY(&amp;Table_inst);
  159. QS_SIG_DICTIONARY(DONE_SIG, (void *)0); /* global signals */
  160. QS_SIG_DICTIONARY(EAT_SIG, (void *)0);
  161. QS_SIG_DICTIONARY(PAUSE_SIG, (void *)0);
  162. QS_SIG_DICTIONARY(SERVE_SIG, (void *)0);
  163. QS_SIG_DICTIONARY(TEST_SIG, (void *)0);
  164. QS_SIG_DICTIONARY(HUNGRY_SIG, me); /* signal just for Table */
  165. QActive_subscribe(&amp;me-&gt;super, DONE_SIG);
  166. QActive_subscribe(&amp;me-&gt;super, PAUSE_SIG);
  167. QActive_subscribe(&amp;me-&gt;super, SERVE_SIG);
  168. QActive_subscribe(&amp;me-&gt;super, TEST_SIG);
  169. for (n = 0U; n &lt; N_PHILO; ++n) {
  170. me-&gt;fork[n] = FREE;
  171. me-&gt;isHungry[n] = 0U;
  172. BSP_displayPhilStat(n, &quot;thinking&quot;);
  173. }</action>
  174. <initial_glyph conn="3,3,5,1,44,18,-9">
  175. <action box="0,-2,6,2"/>
  176. </initial_glyph>
  177. </initial>
  178. <!--${AOs::Table::SM::active}-->
  179. <state name="active">
  180. <!--${AOs::Table::SM::active::TEST}-->
  181. <tran trig="TEST">
  182. <tran_glyph conn="2,11,3,-1,14">
  183. <action box="0,-2,11,4"/>
  184. </tran_glyph>
  185. </tran>
  186. <!--${AOs::Table::SM::active::EAT}-->
  187. <tran trig="EAT">
  188. <action>Q_ERROR();</action>
  189. <tran_glyph conn="2,15,3,-1,14">
  190. <action box="0,-2,10,4"/>
  191. </tran_glyph>
  192. </tran>
  193. <!--${AOs::Table::SM::active::serving}-->
  194. <state name="serving">
  195. <entry brief="give pending permissions to eat">uint8_t n;
  196. for (n = 0U; n &lt; N_PHILO; ++n) { /* give permissions to eat... */
  197. if ((me-&gt;isHungry[n] != 0U)
  198. &amp;&amp; (me-&gt;fork[LEFT(n)] == FREE)
  199. &amp;&amp; (me-&gt;fork[n] == FREE))
  200. {
  201. TableEvt *te;
  202. me-&gt;fork[LEFT(n)] = USED;
  203. me-&gt;fork[n] = USED;
  204. te = Q_NEW(TableEvt, EAT_SIG);
  205. te-&gt;philoNum = n;
  206. QACTIVE_PUBLISH(&amp;te-&gt;super, &amp;me-&gt;super);
  207. me-&gt;isHungry[n] = 0U;
  208. BSP_displayPhilStat(n, &quot;eating &quot;);
  209. }
  210. }</entry>
  211. <!--${AOs::Table::SM::active::serving::HUNGRY}-->
  212. <tran trig="HUNGRY">
  213. <action>uint8_t n, m;
  214. n = Q_EVT_CAST(TableEvt)-&gt;philoNum;
  215. /* phil ID must be in range and he must be not hungry */
  216. Q_ASSERT((n &lt; N_PHILO) &amp;&amp; (me-&gt;isHungry[n] == 0U));
  217. BSP_displayPhilStat(n, &quot;hungry &quot;);
  218. m = LEFT(n);</action>
  219. <!--${AOs::Table::SM::active::serving::HUNGRY::[bothfree]}-->
  220. <choice>
  221. <guard brief="both free">(me-&gt;fork[m] == FREE) &amp;&amp; (me-&gt;fork[n] == FREE)</guard>
  222. <action>TableEvt *pe;
  223. me-&gt;fork[m] = USED;
  224. me-&gt;fork[n] = USED;
  225. pe = Q_NEW(TableEvt, EAT_SIG);
  226. pe-&gt;philoNum = n;
  227. QACTIVE_PUBLISH(&amp;pe-&gt;super, &amp;me-&gt;super);
  228. BSP_displayPhilStat(n, &quot;eating &quot;);</action>
  229. <choice_glyph conn="19,26,5,-1,10">
  230. <action box="1,0,10,2"/>
  231. </choice_glyph>
  232. </choice>
  233. <!--${AOs::Table::SM::active::serving::HUNGRY::[else]}-->
  234. <choice>
  235. <guard>else</guard>
  236. <action>me-&gt;isHungry[n] = 1U;</action>
  237. <choice_glyph conn="19,26,4,-1,5,10">
  238. <action box="1,5,6,2"/>
  239. </choice_glyph>
  240. </choice>
  241. <tran_glyph conn="4,26,3,-1,15">
  242. <action box="0,-2,8,2"/>
  243. </tran_glyph>
  244. </tran>
  245. <!--${AOs::Table::SM::active::serving::DONE}-->
  246. <tran trig="DONE">
  247. <action>uint8_t n, m;
  248. TableEvt *pe;
  249. n = Q_EVT_CAST(TableEvt)-&gt;philoNum;
  250. /* phil ID must be in range and he must be not hungry */
  251. Q_ASSERT((n &lt; N_PHILO) &amp;&amp; (me-&gt;isHungry[n] == 0U));
  252. BSP_displayPhilStat(n, &quot;thinking&quot;);
  253. m = LEFT(n);
  254. /* both forks of Phil[n] must be used */
  255. Q_ASSERT((me-&gt;fork[n] == USED) &amp;&amp; (me-&gt;fork[m] == USED));
  256. me-&gt;fork[m] = FREE;
  257. me-&gt;fork[n] = FREE;
  258. m = RIGHT(n); /* check the right neighbor */
  259. if ((me-&gt;isHungry[m] != 0U) &amp;&amp; (me-&gt;fork[m] == FREE)) {
  260. me-&gt;fork[n] = USED;
  261. me-&gt;fork[m] = USED;
  262. me-&gt;isHungry[m] = 0U;
  263. pe = Q_NEW(TableEvt, EAT_SIG);
  264. pe-&gt;philoNum = m;
  265. QACTIVE_PUBLISH(&amp;pe-&gt;super, &amp;me-&gt;super);
  266. BSP_displayPhilStat(m, &quot;eating &quot;);
  267. }
  268. m = LEFT(n); /* check the left neighbor */
  269. n = LEFT(m); /* left fork of the left neighbor */
  270. if ((me-&gt;isHungry[m] != 0U) &amp;&amp; (me-&gt;fork[n] == FREE)) {
  271. me-&gt;fork[m] = USED;
  272. me-&gt;fork[n] = USED;
  273. me-&gt;isHungry[m] = 0U;
  274. pe = Q_NEW(TableEvt, EAT_SIG);
  275. pe-&gt;philoNum = m;
  276. QACTIVE_PUBLISH(&amp;pe-&gt;super, &amp;me-&gt;super);
  277. BSP_displayPhilStat(m, &quot;eating &quot;);
  278. }</action>
  279. <tran_glyph conn="4,34,3,-1,15">
  280. <action box="0,-2,6,2"/>
  281. </tran_glyph>
  282. </tran>
  283. <!--${AOs::Table::SM::active::serving::EAT}-->
  284. <tran trig="EAT">
  285. <action>Q_ERROR();</action>
  286. <tran_glyph conn="4,37,3,-1,15">
  287. <action box="0,-2,12,4"/>
  288. </tran_glyph>
  289. </tran>
  290. <!--${AOs::Table::SM::active::serving::PAUSE}-->
  291. <tran trig="PAUSE" target="../../3">
  292. <tran_glyph conn="4,41,3,1,37,6,-3">
  293. <action box="0,-2,7,2"/>
  294. </tran_glyph>
  295. </tran>
  296. <state_glyph node="4,19,34,24">
  297. <entry box="1,2,27,2"/>
  298. </state_glyph>
  299. </state>
  300. <!--${AOs::Table::SM::active::paused}-->
  301. <state name="paused">
  302. <entry>BSP_displayPaused(1U);</entry>
  303. <exit>BSP_displayPaused(0U);</exit>
  304. <!--${AOs::Table::SM::active::paused::SERVE}-->
  305. <tran trig="SERVE" target="../../2">
  306. <tran_glyph conn="4,57,3,1,39,-20,-5">
  307. <action box="0,-2,7,2"/>
  308. </tran_glyph>
  309. </tran>
  310. <!--${AOs::Table::SM::active::paused::HUNGRY}-->
  311. <tran trig="HUNGRY">
  312. <action>uint8_t n = Q_EVT_CAST(TableEvt)-&gt;philoNum;
  313. /* philo ID must be in range and he must be not hungry */
  314. Q_ASSERT((n &lt; N_PHILO) &amp;&amp; (me-&gt;isHungry[n] == 0U));
  315. me-&gt;isHungry[n] = 1U;
  316. BSP_displayPhilStat(n, &quot;hungry &quot;);</action>
  317. <tran_glyph conn="4,60,3,-1,15">
  318. <action box="0,-2,6,2"/>
  319. </tran_glyph>
  320. </tran>
  321. <!--${AOs::Table::SM::active::paused::DONE}-->
  322. <tran trig="DONE">
  323. <action>uint8_t n, m;
  324. n = Q_EVT_CAST(TableEvt)-&gt;philoNum;
  325. /* phil ID must be in range and he must be not hungry */
  326. Q_ASSERT((n &lt; N_PHILO) &amp;&amp; (me-&gt;isHungry[n] == 0U));
  327. BSP_displayPhilStat(n, &quot;thinking&quot;);
  328. m = LEFT(n);
  329. /* both forks of Phil[n] must be used */
  330. Q_ASSERT((me-&gt;fork[n] == USED) &amp;&amp; (me-&gt;fork[m] == USED));
  331. me-&gt;fork[m] = FREE;
  332. me-&gt;fork[n] = FREE;</action>
  333. <tran_glyph conn="4,63,3,-1,15">
  334. <action box="0,-2,6,2"/>
  335. </tran_glyph>
  336. </tran>
  337. <state_glyph node="4,45,34,20">
  338. <entry box="1,2,18,4"/>
  339. <exit box="1,6,18,4"/>
  340. </state_glyph>
  341. </state>
  342. <state_glyph node="2,5,43,62"/>
  343. </state>
  344. <state_diagram size="49,69"/>
  345. </statechart>
  346. </class>
  347. <!--${AOs::AO_Philo[N_PHILO]}-->
  348. <attribute name="AO_Philo[N_PHILO]" type="QActive * const" visibility="0x00" properties="0x00">
  349. <code>= { /* &quot;opaque&quot; pointers to Philo AO */
  350. &amp;Philo_inst[0].super,
  351. &amp;Philo_inst[1].super,
  352. &amp;Philo_inst[2].super,
  353. &amp;Philo_inst[3].super,
  354. &amp;Philo_inst[4].super
  355. };</code>
  356. </attribute>
  357. <!--${AOs::AO_Table}-->
  358. <attribute name="AO_Table" type="QActive * const" visibility="0x00" properties="0x00">
  359. <code>= &amp;Table_inst.super; /* &quot;opaque&quot; pointer to Table AO */</code>
  360. </attribute>
  361. <!--${AOs::Philo_ctor}-->
  362. <operation name="Philo_ctor" type="void" visibility="0x00" properties="0x00">
  363. <code>uint8_t n;
  364. Philo *me;
  365. for (n = 0U; n &lt; N_PHILO; ++n) {
  366. me = &amp;Philo_inst[n];
  367. QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Philo_initial));
  368. QTimeEvt_ctorX(&amp;me-&gt;timeEvt, &amp;me-&gt;super, TIMEOUT_SIG, 0U);
  369. }</code>
  370. </operation>
  371. <!--${AOs::Table_ctor}-->
  372. <operation name="Table_ctor" type="void" visibility="0x00" properties="0x00">
  373. <code>Table *me = &amp;Table_inst;
  374. uint8_t n;
  375. QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Table_initial));
  376. for (n = 0U; n &lt; N_PHILO; ++n) {
  377. me-&gt;fork[n] = FREE;
  378. me-&gt;isHungry[n] = 0U;
  379. }</code>
  380. </operation>
  381. </package>
  382. <!--${src}-->
  383. <directory name="src">
  384. <!--${src::dpp.h}-->
  385. <file name="dpp.h">
  386. <text>#ifndef DPP_H
  387. #define DPP_H
  388. enum DPPSignals {
  389. EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
  390. DONE_SIG, /* published by Philosopher when done eating */
  391. PAUSE_SIG, /* published by BSP to pause serving forks */
  392. SERVE_SIG, /* published by BSP to serve re-start serving forks */
  393. TEST_SIG, /* published by BSP to test the application */
  394. MAX_PUB_SIG, /* the last published signal */
  395. HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
  396. TIMEOUT_SIG, /* used by Philosophers for time events */
  397. MAX_SIG /* the last signal */
  398. };
  399. $declare(Events::TableEvt)
  400. /* number of philosophers */
  401. #define N_PHILO ((uint8_t)5)
  402. $declare(AOs::Philo_ctor)
  403. $declare(AOs::AO_Philo[N_PHILO])
  404. $declare(AOs::Table_ctor)
  405. $declare(AOs::AO_Table)
  406. #ifdef QXK_H_
  407. void Test1_ctor(void);
  408. extern QXThread * const XT_Test1;
  409. void Test2_ctor(void);
  410. extern QXThread * const XT_Test2;
  411. #endif /* QXK_H_ */
  412. #endif /* DPP_H */
  413. </text>
  414. </file>
  415. <!--${src::philo.c}-->
  416. <file name="philo.c">
  417. <text>#include &quot;qpc.h&quot;
  418. #include &quot;dpp.h&quot;
  419. #include &quot;bsp.h&quot;
  420. Q_DEFINE_THIS_FILE
  421. /* Active object class -----------------------------------------------------*/
  422. $declare${AOs::Philo}
  423. #define THINK_TIME \
  424. (QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
  425. #define EAT_TIME \
  426. (QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
  427. /* helper macro to provide the ID of Philo &quot;me_&quot; */
  428. #define PHILO_ID(me_) ((uint8_t)((me_) - &amp;Philo_inst[0]))
  429. $define${AOs::AO_Philo[N_PHILO]}
  430. $define${AOs::Philo_ctor}
  431. $define${AOs::Philo}</text>
  432. </file>
  433. <!--${src::table.c}-->
  434. <file name="table.c">
  435. <text>#include &quot;qpc.h&quot;
  436. #include &quot;dpp.h&quot;
  437. #include &quot;bsp.h&quot;
  438. Q_DEFINE_THIS_FILE
  439. /* Active object class -----------------------------------------------------*/
  440. $declare${AOs::Table}
  441. #define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
  442. #define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
  443. #define FREE ((uint8_t)0)
  444. #define USED ((uint8_t)1)
  445. $define${AOs::AO_Table}
  446. $define${AOs::Table_ctor}
  447. $define${AOs::Table}</text>
  448. </file>
  449. </directory>
  450. </model>