changeset 109:198088f668cd

update
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sat, 06 Feb 2021 14:37:27 +0900
parents 23f9d8c6d014
children 4f34c642e9fb
files paper/chapter/04-interface.tex paper/chapter/05-perl.tex paper/master_paper.pdf paper/src/MCWorker.h paper/src/SingleLinkedQueue.h paper/src/includeContext.h
diffstat 6 files changed, 55 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/paper/chapter/04-interface.tex	Sat Feb 06 14:09:32 2021 +0900
+++ b/paper/chapter/04-interface.tex	Sat Feb 06 14:37:27 2021 +0900
@@ -208,6 +208,15 @@
 なお同名のヘッダファイルが見つかった場合は、 変換をしているCbCファイルと同じディレクトリにあるヘッダファイルが優先される。(ソースコード 13行目)
 \lstinputlisting[label=src:createHeaderName2Info, caption=ヘッダファイルの名前とInterfaceのパース結果の対応リストの作製]{src/createHeaderName2Info.pl}
 
+\section{Interface定義ファイル内でのincludeのサポート}
+Interfaceで定義したAPIの引数として、別のヘッダファイルに含まれる構造体を使いたい場合がある。
+DataGearに変換するのが望ましいが、実装が煩雑になることが予想される場合などで、一度構造体を引数として利用するケースがあった。
+従来はInterfaceの定義ファイルの中身はgenerate\_stub.plがAPIの解析しか使っておらず、ここでC言語の\texttt{\#include}マクロを使っても情報が落とされてしまっていた。
+この為Interfaceで別のヘッダファイルの型を使いたい場合は、手動でcontext.hに\texttt{\#include}文を書く必要があった。
+
+これらのinclude処理を、Perlトランスパイラ側で自動で行うように実装を行った。
+これに伴い、Interface、Implの定義ファイルで使いたいヘッダファイルをinclude文で指定することが可能となった。(ソースコード\ref{src:SingleLinkedQueueInc})
+\lstinputlisting[label=src:SingleLinkedQueueInc, caption=Include文を書けるようになったImplementの宣言]{src/MCWorker.h}
 
 \section{Interfaceの実装のCbCファイルへの構文の導入} \label{sec:newInterfaceInCbC}
 今までのGearsOSではマクロに似た\texttt{\#interface}構文で使用するInterfce名を指定した。
--- a/paper/chapter/05-perl.tex	Sat Feb 06 14:09:32 2021 +0900
+++ b/paper/chapter/05-perl.tex	Sat Feb 06 14:37:27 2021 +0900
@@ -151,6 +151,19 @@
 
 \subsection{Interface定義のincludeファイルの解決}
 
+DataGearの定義を自動でcontext.hに生成することが可能となった。
+ここでDataGearが別のヘッダファイルに定義している構造体などをフィールドで持つケースを扱う。
+別のヘッダファイルで定義している構造体を使う場合、context.hの中でDataGearに対応する構造体の定義をする前までに、includeする必要が発生する。
+
+ヘッダファイルとしてstate\_db.hをincludeする宣言が書かれたWorker Intertfaceの実装のmcWorker(ソースコード\ref{src:mcWorker})がある。
+generate\_context.plでは、DataGearの定義ファイルをGears::InterfaceのパースAPIでパースし、情報を取得していた。
+\lstinputlisting[label=src:mcWorker, caption=mcWorker Implの定義]{src/MCWorker.h}
+
+パースした結果の情報含まれるincludeする必要があるヘッダファイルの一覧を取得し、context.hを生成するタイミングで、 struct Contextの定義の前にincludeするコードを挿入する。(ソースコード\ref{src:includeContext})
+includeの結果では、 3、5、7行目にそれぞれincludeするマクロが生成されている。
+各行の上の行には、 includeの記述があったDataGearのファイルパスが記載される。
+\lstinputlisting[label=src:includeContext, caption=context.h内でのinclude]{src/includeContext.h}
+
 \subsection{context.hのテンプレートファイル}
 
 Perlのモジュールとして\texttt{Gears::Template::Context}を作製した。
Binary file paper/master_paper.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/src/MCWorker.h	Sat Feb 06 14:37:27 2021 +0900
@@ -0,0 +1,13 @@
+#include "state_db.h"
+#include "memory.h"
+#include "TaskIterator.h"
+
+typedef struct MCWorker <> {
+  pthread_mutex_t mutex;
+  pthread_cond_t cond;
+...
+  StateDB parent;
+  StateDB root;
+...
+} MCWorker;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/src/SingleLinkedQueue.h	Sat Feb 06 14:37:27 2021 +0900
@@ -0,0 +1,7 @@
+#include "../../ModelChecking/TaskIterator.h"
+
+typedef struct SingleLinkedQueue <> impl Queue {
+    struct Element* top;
+    struct Element* last;
+} SingleLinkedQueue;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/src/includeContext.h	Sat Feb 06 14:37:27 2021 +0900
@@ -0,0 +1,13 @@
+#include "c/enumData.h"
+// use /home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/ModelChecking/MCWorker.h
+#include "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/ModelChecking/memory.h"
+// use /home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/impl/SingleLinkedQueue.h
+#include "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/impl/../../ModelChecking/TaskIterator.h"
+// use /home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/ModelChecking/MCWorker.h
+#include "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/ModelChecking/TaskIterator.h"
+// use /home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/ModelChecking/MCWorker.h
+#include "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/ModelChecking/state_db.h"
+struct Context {
+    enum Code next;
+    struct Worker* worker;
+....