annotate paper/text/chapter2.tex @ 4:e94e544fce5c

...
author matac42 <matac@cr.ie.u-ryukyu.ac.jp>
date Sat, 15 Jan 2022 16:50:14 +0900
parents 905f551ddf59
children 47c5e331d020
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 \chapter{Continuation based C}
4
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
2 Continuation based C(CbC)\cite{cbcllvm,cbc}とはCの下位言語である.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
3 function callの代わりにgotoによる継続を用いる.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
4 CbCのプログラムはCodeGearと呼ばれる処理の単位で記述し,ノーマルレベルとメタレベルの処理を切り分けることが可能である.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
5
1
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 \section{CodeGearとDataGear}
4
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
7 CbCでは関数の代わりにCodeGearという単位でプログラミングを行う.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
8 CodeGearは\emph{\_\_code}という記述で宣言することができる.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
9 データの単位にはDataGearと呼ばれる変数データを用いる.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
10 DataGearを入力として受け取り,別のDataGearに書き込み出力することができる.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
11 特に入力のDataGearをInput DataGear,出力のDataGearをOutput DataGearと呼ぶ.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
12 gotoで次のCodeGearに遷移することができ,その際Output DataGearを次のCodeGearのInput DataGearとして渡すことができる.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
13
1
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 \section{ノーマルレベルとメタレベル}
4
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
15 図\ref{fig:meta-cgdg}はCodeGearの遷移とMetaCodeGearの関係を表している.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
16 ノーマルレベルで見るとCodeGearがDataGearを受け取り,
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
17 処理後,DataGearを次のCodeGearに渡すという動作をしているように見える.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
18 実際にはデータの整合性の確認や資源管理などのメタレベルの処理が存在し,
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
19 それらの計算はMetaCodeGearで行われる.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
20 その際,MetaCodeGearに渡されるDataGearのことは特にMetaDataGearと呼ばれる.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
21 CodeGearの前に実行されるMetaCodeGearは特にstubCodeGearと呼ばれ,
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
22 メタレベルを含めるとstubCodeGearとCodeGearを交互に実行する形で遷移していく.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
23 \begin{figure}[h]
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
24 \begin{center}
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
25 \includegraphics[width=100mm]{figs/meta-cg-dg.pdf}
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
26 \end{center}
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
27 \caption{CodeGearとMetaCodeGearの関係}
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
28 \label{fig:meta-cgdg}
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
29 \end{figure}
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
30
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
31 \section{継続}
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
32 CodeGearから次のCodeGearに遷移していく一連の動作を継続と呼ぶ.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
33 CbCの継続はfunction callをせずにgotoによるjmpで行われる.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
34 function callによる継続と異なり,jmpによる継続はstackなどの環境を保存しないことから軽量である.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
35 そのことからCbCにおける継続を特に軽量継続と呼ぶ.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
36
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
37 \section{CbCの記述例}
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
38 CbCのプログラム例をソースコード\ref{src:cbc}に示す.まずmain関数においてadd1 CodeGearへgotoを行う.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
39 その際add1へInput DataGearとしてnを渡す.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
40 add1は処理の最後にadd2 CodeGearへgotoを行う.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
41 その際Output DataGear out\_nをadd2のInput DataGearとして渡す.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
42 このようにCbCではCodeGearのOutput DataGearを次のCodeGearのInput DataGearとして渡すことを繰り返すことで処理を進める.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
43
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
44 \lstinputlisting[caption=CbCのプログラム例,label=src:cbc]{src/hello.cbc}
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
45
1
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 \chapter{GearsOS}
4
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
48 GearsOS\cite{gears,gearsos,cr}は 信頼性と拡張性の両立を目的として,開発されている.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
49 Gearという概念があり,実行の単位をCodeGear,データの単位をDataGearと呼ぶ.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
50 軽量継続を基本とし,stackを持たない代わりに全てをContext経由で実行する.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
51 ノーマルレベルとメタレベルの処理を切り分けることができ,同様にGearの概念を持つCbC(Continuation based C)で記述されている.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
52 GearsOSは現在開発途上であり,OSとして動作するために今後実装しなければならない機能がいくつか残っている.
1
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 \section{信頼性の保証}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 \section{stub}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 \section{context}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 \chapter{Christie}
4
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
58 Christieは当研究室で開発を行っているJavaで記述された分散フレームワークである.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
59 CodeGear,DataGear,CodeGearManager,DataGearManagerなどのCbCと似ているが別物のGearという概念を持つ.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
60 CodeGearはクラスやスレッドに相当する.DataGearは変数データに相当し,Javaのアノテーションを用いて記述される.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
61 CodeGearManagerはいわゆるノードに相当し,CodeGear,DataGear,DataGearManagerを管理する.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
62 複数のCodeGearManager同士が配線され,DataGearを送信し合うことで分散処理を実現している.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
63 DataGearManagerはDataGearを管理しているもので変数プールに相当する.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
64 GearsOSではDataGearManagerの仕組みをファイルシステムとして用いたい.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
65 さらに,ChristieにはTopologyを形成するためのTopologyManagerがある.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
66 TopologyManagerはCodeGearManagerを任意の形のTopologyに接続する機能を持っている.
1
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 \section{Gearの概念}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 \section{DataGearManager}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 \section{topology manager}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 \chapter{UnixのFileSystem}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 \section{inode}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 \chapter{GearsFileSystemのdirectory}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 \section{Treeによるdirectory構造}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 \section{Unix Like な interface}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 \subsection{mkdir}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 \subsection{ls}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 \subsection{cd}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 \section{inodeを用いたdirectory entry}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 \section{非破壊的編集によるBackup}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 \chapter{File構造}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 \section{I/O Stream}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 \section{logによるバージョン管理}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 \chapter{WordCount}
4
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
88 WordCount例題\cite{file}はGearsOSのファイルシステムを構築する際に用いてる例題である.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
89 指定したファイルの文字数や行数,ファイルの内の文字列を出力する.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
90 図\ref{fig:WCStates}はWordCount例題の処理の流れを示している.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
91 大きく分けて,指定したファイルをFile構造体としてopenするFileOpenスレッド,
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
92 File構造体を受け取り文字数と行数をcountUpするWordCountスレッドの二つのCodeGearで記述することができる.
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
93 ファイル内の文字列を行ごとにCountUpに送信し,EOFを受け取ったらループを抜けfinishに移行する.
1
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 \section{API}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 \section{GearBox的な処理}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 \chapter{今後の課題}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 \section{分散ファイルシステム}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 \section{GearsAgda}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 \section{shell}
905f551ddf59 add: table of contents
matac42 <matac@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 \section{モデル検査}