changeset 107:84359208ad70

update
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sat, 06 Feb 2021 13:47:49 +0900
parents 0512c7f88417
children 23f9d8c6d014
files paper/chapter/04-interface.tex paper/master_paper.pdf paper/src/ParGoto.cbc paper/src/ParGoto2.cbc paper/src/ParGoto3.cbc
diffstat 5 files changed, 71 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/paper/chapter/04-interface.tex	Sat Feb 06 13:23:39 2021 +0900
+++ b/paper/chapter/04-interface.tex	Sat Feb 06 13:47:49 2021 +0900
@@ -489,5 +489,18 @@
 従来のpar gotoではInterface経由の呼び出しは想定していなかった。
 par gotoで継続したいCodeGearはInterfaceのAPIとしてではなく、 Interfaceを入力として受け取るCodeGearとして実装する必要があった。
 しかし食事する哲学者の問題(Dining Philosophers Problem、 DPP)の検証などでは、特定のInterfaceが並列で動いている必要がある。
-例えばDPPの例題の場合は、哲学者(Philosopher)のInterfaceは並列で処理される必要がある。
+DPPの例題の場合は、哲学者(Philosopher)のInterfaceは並列で処理される必要がある。
+GearsOSで実装したDPPの例題で、par gotoを実行している箇所をソースコード\ref{src:pargotoPhil}に示す。
+
+\lstinputlisting[label=src:pargotoPhil, caption=5つのPhilosopherInterfaceからのpar goto]{src/ParGoto.cbc}
 
+この記述はPerlトランスパイラによって、ソースコード\ref{src:pargotoPhil2}のメタ記述に変換される。
+\lstinputlisting[label=src:pargotoPhil2, caption=5つのPhilosopherInterfaceからのpar gotoのPerl変換後]{src/ParGoto2.cbc}
+PhilsInterfaceは大本のcontextで作製しているため、par gotoで作製したContextにInterfaceの情報が保存されていなかった。
+処理を実行するとInterfaceの値をStubCodeGearで取り出す際に、初期化をしていない値をとってしまい、 セグメンテーション違反が発生する。
+この問題は、Gearefマクロを利用して作製したpar goto用のContextの引数用の保存場所に、それぞれ実装のポインタを書き込むことで解決する。
+
+ソースコード\ref{src:pargotoPhil3}では、par goto作製したContextであるcontext{\textgreater}taskに、 Gearefマクロを用いて引数としてPhilsのインスタンスを代入している。(ソースコード3、 15行目)
+またthinkingの引数はCodeGearが必要であったので、これもnextに設定している。(ソースコード4、 16行目)
+この処理は、generate\_stub.plで、 par goto時にInterface呼び出しをしている際のパターンを新たに実装し、Interfaceのパースの結果から得られた引数に書き込む様なルーチンで実現している。
+\lstinputlisting[label=src:pargotoPhil3, caption=改善されたInterface経由でのpar goto]{src/ParGoto3.cbc}
\ No newline at end of file
Binary file paper/master_paper.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/src/ParGoto.cbc	Sat Feb 06 13:47:49 2021 +0900
@@ -0,0 +1,14 @@
+Phils* phils0 = createPhilsImpl(context,0,fork0,fork1);
+Phils* phils1 = createPhilsImpl(context,1,fork1,fork2);
+Phils* phils2 = createPhilsImpl(context,2,fork2,fork3);
+Phils* phils3 = createPhilsImpl(context,3,fork3,fork4);
+Phils* phils4 = createPhilsImpl(context,4,fork4,fork0);
+
+par goto phils0->thinking(exit_code);
+par goto phils1->thinking(exit_code);
+par goto phils2->thinking(exit_code);
+par goto phils3->thinking(exit_code);
+par goto phils4->thinking(exit_code);
+
+goto code2();
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/src/ParGoto2.cbc	Sat Feb 06 13:47:49 2021 +0900
@@ -0,0 +1,25 @@
+Phils* phils0 = createPhilsImpl(context,0,fork0,fork1);
+Phils* phils1 = createPhilsImpl(context,1,fork1,fork2);
+Phils* phils2 = createPhilsImpl(context,2,fork2,fork3);
+Phils* phils3 = createPhilsImpl(context,3,fork3,fork4);
+Phils* phils4 = createPhilsImpl(context,4,fork4,fork0);
+
+struct Element* element;
+                context->task = NEW(struct Context);
+                initContext(context->task);
+                context->task->next = phils0->thinking;
+                context->task->idgCount = 0;
+                context->task->idg = context->task->dataNum;
+                context->task->maxIdg = context->task->idg + 0;
+                context->task->odg = context->task->maxIdg;
+                context->task->maxOdg = context->task->odg + 0;
+GET_META(phils0)->wait = createSynchronizedQueue(context);
+                element = &ALLOCATE(context, Element)->Element;
+                element->data = (union Data*)context->task;
+                element->next = context->taskList;
+                context->taskList = element;
+                context->task = NEW(struct Context);
+                initContext(context->task);
+                context->task->next = phils1->thinking;
+
+...
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/src/ParGoto3.cbc	Sat Feb 06 13:47:49 2021 +0900
@@ -0,0 +1,18 @@
+                context->task->maxOdg = context->task->odg + 0;
+GET_META(phils0)->wait = createSynchronizedQueue(context);
+Gearef(context->task, Phils)->phils = (union Data*) phils0;
+Gearef(context->task, Phils)->next = C_exit_code;
+                element = &ALLOCATE(context, Element)->Element;
+                element->data = (union Data*)context->task;
+                element->next = context->taskList;
+                context->taskList = element;
+                context->task = NEW(struct Context);
+                initContext(context->task);
+                context->task->next = phils1->thinking;
+...
+                context->task->maxOdg = context->task->odg + 0;
+GET_META(phils1)->wait = createSynchronizedQueue(context);
+Gearef(context->task, Phils)->phils = (union Data*) phils1;
+Gearef(context->task, Phils)->next = C_exit_code;
+                    element = &ALLOCATE(context, Element)->Element;
+