changeset 920:8e0e0ba2aec2

...
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Fri, 29 Jan 2021 18:01:05 +0900
parents 765871c90c74
children 14166ed0c58d bddaeef2f774
files src/parallel_execution/examples/DPP/Phils.h src/parallel_execution/examples/DPP/PhilsImpl.cbc
diffstat 2 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/examples/DPP/Phils.h	Fri Jan 29 17:56:35 2021 +0900
+++ b/src/parallel_execution/examples/DPP/Phils.h	Fri Jan 29 18:01:05 2021 +0900
@@ -1,7 +1,7 @@
 typedef struct Phils <> {
   __code putdown_lfork(Impl* phils, __code next(...));
   __code putdown_rfork(Impl* phils, __code next(...));
-  __code thinking(Impl* phils,, __code next(...));
+  __code thinking(Impl* phils, __code next(...));
   __code pickup_rfork(Impl* phils, __code next(...));
   __code pickup_lfork(Impl* phils, __code next(...));
   __code eating(Impl* phils, __code next(...));
--- a/src/parallel_execution/examples/DPP/PhilsImpl.cbc	Fri Jan 29 17:56:35 2021 +0900
+++ b/src/parallel_execution/examples/DPP/PhilsImpl.cbc	Fri Jan 29 18:01:05 2021 +0900
@@ -1,10 +1,10 @@
 #include "../../../context.h"
 #include <stdio.h>
-#interface "Phils.h"
 #interface "Fork.h"
 #interface "Worker.h"
 #interface "AtomicT.h"
 #interface "TaskManager.h"
+#impl "Phils.h" for "PhilsImp.h"
 
 // ----
 // typedef struct PhilsImpl <Self, Isa> impl Phils {
@@ -15,13 +15,13 @@
 // } PhilsImpl;
 // ----
 
-Phils* createPhilsImpl(struct Context *context, int id, AtomicT<int> right, AtomicT<int> left){
+Phils* createPhilsImpl(struct Context *context, int id, AtomicT<int> right, AtomicT<int> left) {
     struct Phils* phils = new Phils();
     struct PhilsImpl* phils_impl = new PhilsImpl();
     phils->phils = (union Data *)phils_impl;
     phils_impl->Leftfork = left;
     phils_impl->Rightfork = right;
-    phils_impl->self = 0;
+    phils_impl->self = id;
     phils->putdown_lfork = C_putdown_lfork_PhilsImpl;
     phils->putdown_rfork = C_putdown_rfork_PhilsImpl;
     phils->eating = C_eating_PhilsImpl;
@@ -31,32 +31,32 @@
     return phils;
 }
 
-__code putdown_rfork(struct PhilsImpl* phils, __code next(...)){
+__code putdown_rfork(struct PhilsImpl* phils, __code next(...)) {
     struct AtomicT<int>* right_fork = phils->Rightfork;
-    goto right_fork->set(0, putdown_lfork);
+    goto right_fork->set(-1, putdown_lfork);
 }
 
-__code putdown_lfork(struct PhilsImpl* phils, __code next(...)){
+__code putdown_lfork(struct PhilsImpl* phils, __code next(...)) {
     struct AtomicT<int>* left_fork = phils->Leftfork;
-    goto left_fork->set(0, thinking);
+    goto left_fork->set(-1, thinking);
 }
 
-__code thinking(struct PhilsImpl* phils, struct Fork* fork, __code next(...)){
+__code thinking(struct PhilsImpl* phils, struct Fork* fork, __code next(...)) {
     printf("%d: thinking\n", phils->self);
     goto pickup_lfork();
 }
 
-__code pickup_rfork(struct PhilsImpl* phils, __code next(...)){
+__code pickup_rfork(struct PhilsImpl* phils, __code next(...)) {
     struct AtomicT<int>* right_fork = phils->Rightfork;
-    goto right_fork->checkAndSet(-1, 0, pickup_lfork, pickup_rfork)
+    goto right_fork->checkAndSet(-1, phils->self, pickup_lfork, pickup_rfork)
 }
 
-__code pickup_lfork(struct PhilsImpl* phils, __code next(...)){
+__code pickup_lfork(struct PhilsImpl* phils, __code next(...)) {
     struct AtomicT<int>* left_fork = phils->Leftfork;
-    goto left_fork->checkAndSet(-1, 0, pickup_rfork, eating);
+    goto left_fork->checkAndSet(-1, phils->self, pickup_rfork, eating);
 }
 
-__code eating(struct PhilsImpl* phils, __code next(...)){
-    printf("%d: eating\n", phils_impl->self);
+__code eating(struct PhilsImpl* phils, __code next(...)) {
+    printf("%d: eating\n", phils->self);
     goto putdown_rfork();
 }