view final_main/chapter2.tex @ 8:80f76a34c4f7

fix ref
author menikon
date Fri, 07 Feb 2020 21:30:47 +0900
parents 102c40310142
children dca5e4f9fceb
line wrap: on
line source

\chapter{Continuation based C}
%\label{chap:concept}

Continuation based C \cite{cbc} (以下CbC) は基本的な処理単位を CodeGear として定義し, CodeGea 間で遷移するようにプログラムを記述する C 言語と互換性のある当研究室で開発されたプログラミング言語である.図\ref{fig:codegear}はCodeGear間の継続する際の処理の流れを示している.

\begin{figure}[ht]
     \begin{center}
     \includegraphics[width=150mm]{fig/gotoCodeGear.pdf}
     \end{center}
     \caption{CodeGear間の継続}
    \label{fig:codegear}
\end{figure}

現在 CbC は C コンパイラであるGCC\cite{gcc}及びLLVM\cite{llvm}をバックエンドとした clang 上で実装されている.
本研究ではこのプログラミング言語を用いて xv6 の Filesystemを書き換える.
\section{CodeGear}
CodeGear は CbCにおける基本的な処理単位である. 以下のソースコード\ref{cbcexample}は CodeGear の継続の例である.
\lstinputlisting[label=cbcexample,  caption=CodeGearの継続の例]{src/cbc_example.cbc}
CodeGear は\_\_code CodeGear名 (引数) の形で記述される.
CodeGear は返り値を持たない為, 関数内で処理が終了すると呼び出し 元の関数に戻ることがなく別の CodeGear へ遷移する. 
ソースコード\ref{cbcexample}の5行目のgoto cg1(c); や8行目のgoto cg2(c); などがこれにあたる.図\ref{fig:goto}はソースコード\ref{cbcexample}の状態遷移を表している.

\begin{figure}[ht]
     \begin{center}
     \includegraphics[width=100mm]{fig/goto.pdf}
     \end{center}
     \caption{ソースコード\ref{cbcexample} が表しているCodeGearの状態遷移}
    \label{fig:goto}
\end{figure}

また CbC における CodeGear 間の継続にはスタックが使用されず, 呼び出し元の環境などを持たない為軽量継続と呼ぶ.
この CbC における CodeGear 間の継続にスタックが使用されない性質は信頼性の高い OS の開発に適している.

\section{DataGear}