changeset 39:228d350be33e

update tex
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Wed, 06 May 2020 13:34:53 +0900
parents 32453ef823d9
children a91592fafeb1
files paper/anatofuz-sigos.tex
diffstat 1 files changed, 36 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/paper/anatofuz-sigos.tex	Wed May 06 13:33:25 2020 +0900
+++ b/paper/anatofuz-sigos.tex	Wed May 06 13:34:53 2020 +0900
@@ -267,7 +267,7 @@
 これらはOSの立ち上げ時やシステムコールの中で、ファイルシステムの操作に対応した関数や構造体などのAPIを通して操作される。
 システムコールの一連の流れに着目するのではなく、 特定の対象のAPIに着目して継続の分析を検討した。
 
-xv6のファイルシステムに関する定義ファイルは\texttt{fs.c}中に記述されている。
+xv6のファイルシステムに関する関数などのAPIは主に\texttt{fs.c}中に記述されている。
 Code\ref{src:fs_interface}に示す様に、 \texttt{fs.c}中に定義されているAPIを抜き出し、 CbCのInterfaceとして定義した。
 \texttt{\_\_code}から始まるCodeGearの名前が、 それぞれ抽象化されたCodeGearの集合の最初の継続となる。
 
@@ -291,8 +291,42 @@
 
 CbCのCodeGearの粒度はCの関数とアセンブラの中間であるといえるので、 BasicBlockをCodeGearに置き換える事が可能である。
 したがって特定の関数内の処理のBasicBlockを分析し、 BasicBlockに対応したCodeGearへ変換することが可能となる。
-実際にBasicBlock単位で切り分ける前の処理と、切り分けたあとの処理を示す。
+実際にBasicBlock単位で切り分ける前の処理と、切り分けたあとの処理の一部を示す。
+例としてinodeのアロケーションを行うAPIでる\texttt{ialloc}の元のコードをCode\ref{src:ialloc_origin}に示す。
+
+\begin{lstlisting}[frame=lrbt,label=src:ialloc_origin,caption={iallocの元のソースコード}]
+struct inode* ialloc (uint dev, short type)
+{
+    readsb(dev, &sb);
+    for (inum = 1; inum < sb.ninodes; inum++) {
+        bp = bread(dev, IBLOCK(inum));
+        dip = (struct dinode*) bp->data + inum % IPB;
 
+        if (dip->type == 0) {  // a free inode
+            memset(dip, 0, sizeof(*dip));
+            // omission
+            return iget(dev, inum);
+        }
+        brelse(bp);
+    }
+    panic("ialloc: no inodes");
+}
+\end{lstlisting}
+
+ \texttt{ialloc}はループ条件である \texttt{inum < sb.ninodes}が成立しなかった場合は\texttt{panic}へと状態が遷移する。
+ この\texttt{for}文での状態遷移をCodeGearに変換したものをCode\ref{src:allocinode_loopcheck}に示す。
+
+
+\begin{lstlisting}[frame=lrbt,label=src:allocinode_loopcheck,caption={ループ条件を確認するCodeGear}]
+__code allocinode_loopcheck(struct fs_impl* fs_impl, uint inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(...)){
+    if( inum < sb->ninodes){
+        goto allocinode_loop(fs_impl, inum, dev, type, sb, bp, dip, next(...));
+    }
+    char* msg = "failed allocinode...";
+    struct Err* err = createKernelError(&proc->cbc_context);
+    goto err->panic(msg);
+}
+\end{lstlisting}
 
 
 \section{CbCを用いた部分的なxv6の書き換え}