annotate poster_slide/index.md @ 155:6f940582768f

...
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 16 Feb 2021 15:21:11 +0900
parents 995b97ca8410
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
146
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 marp: true
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 title: GearsOSのメタ計算
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 paginate: true
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 # GearsOSのメタ計算
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 - 清水 隆博
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 - 琉球大学理工学研究科
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 - 198584B
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 - 河野研
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 - [修論本体](http://www.cr.ie.u-ryukyu.ac.jp/hg/Papers/2021/anatofuz-master/raw-file/tip/paper/master_paper.pdf)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 - [修論審査スライド](http://www.cr.ie.u-ryukyu.ac.jp/hg/Papers/2021/anatofuz-master/raw-file/tip/slide/index.html)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
147
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
17 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
18 # ノーマル、メタレベルの計算とGearsOS
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
19 - ノーマル/メタレベルを一貫して記述できる言語にContinuation Based Cがある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
20 - CbCを用いてGearsOSを開発している
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
21 - GearsOSではメタ計算の生成にトランスパイラを使っている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
22 - トランスパイラとはコードからコードを生成する処理系のこと
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
23 - 生成しなければならないメタ計算の量が多いため、自動的に生成する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
24 - CMakeとPerlでビルド時にノーマルレベルのコードをメタレベルに変換する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
25 - ノーマルレベルで書いた記述がそのままコンパイルされる訳ではない
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
26
148
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
27 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
28 # ノーマルレベル/メタレベルのCodeGear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
29
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
30 - ノーマルレベルのCodeGearから見ると、直接別のCodeGearに継続している
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
31 - 実際はCodeGearの実行の前後にメタレベルの計算をするCodeGearが実行される
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
32 - メタレベルの計算をするCodeGearをMetaCodeGearと呼ぶ
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
33
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
34 ![h:220 w:800](./metacg.svg)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
35
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
36 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
37 # GearsOSのシステム構成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
38 - MetaDataGearであるContext, TaskManager, Workerによって構成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
39
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
40 ![](./gears_structure.svg)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
41
147
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
42
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
43 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
44 # GearsOSのビルドシステム
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
45 - CMakeとPerlを使ってビルドする
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
46 - CMakeはMakefileやbuild.ninjaを生成する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
47 - Perlは2種類のスクリプトが自動的に呼ばれる
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
48 - Perlによってコード変換・ファイル生成が行われた後にコンパイルが走る
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
49 - Perlの実行前はノーマルレベルだけのコード、実行後はメタが入る
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
50
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
51 ![w:632 h:10cm](./geasflow1.svg)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 146
diff changeset
52
146
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 # Context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 - 従来のOSのプロセスに相当するMetaDataGear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 - GearsOSでのプログラム実行に必要な情報を持っている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 - DataGearの型定義
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 - CodeGearの名前とStubCodeGearへの対応
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 - goto時に引数を書き込むDataGearごとの場所
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 - DataGearを管理するヒープ情報
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 # Context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 - GearsOSでcontextを触るのはメタ計算部分だけ
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 - ノーマルレベルではcontextに触れない
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 - 従来は手書きでcontext.hの中で定義
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 - Context自体は構造体で定義されている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 ![w:532 h:10cm](./context.svg)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 # メタレベルでのDataGearの管理
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 - メタレベルではDataGearを纏めて管理する必要がある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 - すべてのDataGearはCの共用体を使って定義される
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 - `union Data`型
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 - `union Data`はすべてのDataGearにキャストすることが可能
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 - Contextには`union Data`としてDataGearを保存する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 - メタレベルの計算では必ずこの`union Data`が利用される
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 union Data {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 struct Stack {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 ...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 } Stack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 struct SingleLinkedStack {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 ...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 } SingleLinkedStack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 struct Context Context;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 ...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 # union Dataの定義
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 - union Data型はcontext.hに定義されている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 - 計算で使うすべてのDataGearの構造体の定義を列挙する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 - 従来は手書きですべて記述
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 - Intefaceの定義を書き、CbCを書き、context.hに追記...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 - 手書きで生成していたので、いくつかの問題があった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 - 整理しないと計算に使わないDataGearの定義が残る
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 - Interfaceの定義ファイルと食い違うケースがある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 - DataGearの数が増えると手書きするのが煩雑
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 - すべてのメタレベルの計算の元となる重要なデータ
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 - 手書きの場合ミスが発生する可能性が高い
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 # メタレベルに変換されたGearsOSの実装
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 - ノーマルレベルのCodeGearの継続は、contextとCodeGearの番号のみ指定する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 - 次の継続を番号で指定する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 - 次の継続への引数も値をcontextに書き込むように変更される
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 - CodeGearの継続は直接行かず、MetaCodeGearを経由して継続する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 - 呼び出したいCodeGearはMetaCodeGearが番号から取り出す
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 - アドレスを直接使うのはメタ計算のみ
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 - 各CodeGearはContextのみ持ち歩き、入力はStubCodeGearから与えられる
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 # CodeGear、DataGearの番号
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 - Perlで変換するとCodeGear/DataGear番号の形に抽象化される
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 - 番号から具体的なCodeGear/DataGearを取り出すのはメタレベル
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 - `goto meta`でcontextからCodeGearの取り出し
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 - StubCodeGearでcotnextからDataGearの取り出し
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 # CodeGearの番号
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 - ビルドするCbCファイルをPerlで解析し、`__code`を数え上げる
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 - 連番でenumを生成する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 - Contextの中にCodeGearの配列がある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 - StubCodeGearへの参照が含まれている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 enum Code {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 C_checkAndSetAtomicReference,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 C_clearSingleLinkedStack,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 C_clearSynchronizedQueue,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 C_createTask,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 C_decrementTaskCountTaskManagerImpl,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 C_exit_code,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 C_get2SingleLinkedStack,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 ...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 };
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 # DataGearの番号
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 - union Dataで定義されている構造体一覧からPerlで生成される
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 - context.hの内容に依存する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 enum DataType {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 D_Code,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 D_Atomic,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 D_AtomicReference,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 D_CPUWorker,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 D_Context,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 D_Element,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 ...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 };
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 # StubCodeGear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 - DataGearにアクセスするにはContextから番号を指定して行う
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 - メタレベルのCodeGearは引数はContextのみになっている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 - CodeGearの引数に指定していたものは、ContextからMetaCodeGearで取り出す必要がある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 - StubCodeGearはCodeGearの直前に実行されて、DataGearをContextから取得する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 ![w:540 h:400](./contextContinuation.svg)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 # GearsOSの新機能
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 - **自由なMetaCodeGearの作製、継続の入れ替え機能**
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 - Perlトランスパイラの変換ルーチンのデバッグ機能の追加
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 - トランスパイラそのもののデバッグが困難であった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 - ジェネリクスのサポート
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 # メタ計算の切り替えAPI
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 - 通常だとCodeGearの実行後、`goto meta`に継続するようにPerlで変換される
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 - 継続するMetaCodeGearを自由に選択したい
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 __code thinkingPhilsImpl(struct Context *context,struct PhilsImpl* phils,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 struct Fork* fork, enum Code next) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 printf("%d: thinking\n", phils->self);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 goto meta(context, C_pickup_lforkPhilsImpl);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 - 例えばモデル検査用のMetaCodeGear(`mcMeta`)にgotoさせたい
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 __code thinkingPhilsImpl(struct Context *context,struct PhilsImpl* phils,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 struct Fork* fork, enum Code next) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 printf("%d: thinking\n", phils->self);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 goto mcMeta(context, C_pickup_lforkPhilsImpl);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 # mta.pm
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 - CodeGearが継続するMetaCodeGearを自由に選択できるPerlモジュールを導入した
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 - APIに沿ってPerlモジュールを書くことで特定のCodeGearの継続先を変更可能
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 - Perlトランスパイラがコード変換時に自動ロードして実行する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 ![w:932 h:10cm](./metapm.svg)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 # meta.pm
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 - `replaceMeta`関数に置換対象と生成する`goto`の組をリストで登録
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 - `qr//`に正規表現リテラルで置換対象のCodeGearの名前を指定
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 - `=>`の先に対応するgoto文の生成関数を指定する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 - この例では`PhilsImpl`が名前についているCodeGearが一括で`goto mcMeta`になる
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 ```perl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 package meta;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 sub replaceMeta {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 return (
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 [qr/PhilsImpl/ => \&generateMcMeta],
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 );
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 sub generateMcMeta {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 my ($context, $next) = @_;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 return "goto mcMeta($context, $next);";
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 # 今後の課題
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 - Perlトランスパイラのリファクタリング・GearsOSのビルド方法の見直し
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 - 機能が充実したが複雑度が全体的に増してしまった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 - PerlトランスパイラのGearsOS本体への組み込み
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 - Perlトランスパイラが行っている処理はリンカ、ローダーに近い
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 - OSが機能としてサポートしていてほしい
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 - GearsOS自身で記述したい
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 - xv6への組み込み
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 - GearsOSを既存のUNIXの置き換えとして実行したい
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 - ノーマルレベルの記述の純粋関数化、別の言語での定義
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 - CbC/Cベースの記述ではノーマルレベルの記述に限界がある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 - Perlトランスパイラの機能をさらに拡張すると、PerlでCbCコンパイラを実装することに近くなってしまう
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 # まとめ
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 - Perlトランスパイラのフレームワークの機能を充実させた
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 - Interfaceシステムを改良した
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 - 型定義ファイルの導入を行った
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 - 定義方法に一貫性が出た
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 - Perlトランスパイラで警告を発生させるようになった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 - 従来手書きしていたメタな定義をビルド時に自動的に生成するようにした
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 - 煩雑な処理や手で実装することによるバグの混入を回避
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 - MetaCodeGearの制御をユーザー側で行えるようにした
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 - モデル検査をメタ計算として自在に組み込むことが可能となった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265