diff gearsos.tex @ 5:910e143c28e7

modify style
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Tue, 09 Feb 2016 17:10:44 +0900
parents 52eec0b77576
children 12d1c2f53258
line wrap: on
line diff
--- a/gearsos.tex	Tue Feb 09 04:21:34 2016 +0900
+++ b/gearsos.tex	Tue Feb 09 17:10:44 2016 +0900
@@ -69,13 +69,14 @@
 \lstinputlisting[label=context, caption=Context]{src/context.h}
 \lstinputlisting[label=initcontext, caption=initContext]{src/initContext.c}
 
-Context はヒープサイズを示す heap\_limit, ヒープの初期位置を示す heap\_start, ヒープの現在位置を示す heap を持っている。
+Context はヒープサイズを示す heapLimit, ヒープの初期位置を示す heapStart, ヒープの現在位置を示す heap を持っている。
 必要な Data Gear のサイズに応じて heap の位置を動かすことで Allocation を実現する。
 
 allocate を行うには allocate に必要な Data Gear に情報を書き込む必要がある。
-この Data Gear は Context 生成時に生成する必要がある。
+この Data Gear は Context 生成時に生成する必要があり、ソースコード:\ref{context} 14行目の Allocate がそれに当たる。
+UniqueData で定義した Data Gear は Context と同時に生成される。
 
-Temporal Data Gear にある Data Gear は基本的には破棄可能なものなので heap\_limit を超えたら heap を heap\_start の位置に戻し、ヒープ領域を再利用する(図:\ref{fig:allocation})。
+Temporal Data Gear にある Data Gear は基本的には破棄可能なものなので heapLimit を超えたら heap を heapStart の位置に戻し、ヒープ領域を再利用する(図:\ref{fig:allocation})。
 必要な Data Gear は Persistent Data Tree に書き出すことで他の Worker からアクセスすることが可能になる。
 
 \begin{figure}[!ht]
@@ -86,7 +87,7 @@
   \label{fig:allocation}
 \end{figure}
 
-実際に allocate を行うコードはソースコード:\ref{allocate} の通りである。
+実際に allocate を行う Code Gear はソースコード:\ref{allocate} の通りである。
 
 Context 生成時に実行可能な Code Gear と名前が対応付けられる。
 その対応付けられた Code Gear が Context の code に格納される。
@@ -97,6 +98,27 @@
 
 \lstinputlisting[label=allocate, caption=allocate]{src/allocate.c}
 
-\section{List}
+\newpage
+
 \section{Synchronized Queue}
+Gears OS における Synchronized Queue は TaskQueue として利用される。
+メインとなる Context と Worker 用の Context で共有され、Woker が TaskQueue から Task を取得し実行することで並列処理を実現する。
+
+Gears OS での Queue を Queue を表す Data Gear と Queue の構成要素である Element によって表現する。
+Queue を表す Data Gear には先頭の Element を指す first, 末尾の Element を指す last, Element の個数を示す count が格納される。
+Element を表す Data Gear には Task を示す task, 次の Element を示す next が格納される。
+
+ソースコード:\ref{queue} は Context の定義(ソースコード:\ref{context})に追加する Queue と Element の定義である。
+
+\lstinputlisting[label=queue, caption=queue]{src/queue.h}
+
+新たに Queue に対する操作を行う Code Gear の名前を追加し、UniqueData には Queue の情報が入る Queue(ソースコード:\ref{queue} 9行目) と Enqueue に必要な情報を書き込む Element(ソースコード:\ref{queue} 10行目) を定義している。
+
+通常の Enqueue, Dequeue を行う Code Gear はソースコード:\ref{enqueue} と ソースコード:\ref{dequeue} の通りである。
+
+\lstinputlisting[label=enqueue, caption=Enqueue]{src/enqueue.c}
+\lstinputlisting[label=dequeue, caption=Dequeue]{src/dequeue.c}
+
+ソースコード:\ref{enqueue} とソースコード:\ref{dequeue} はシングルスレッドでは正常に動作するが、並列実行すると期待した値にならない。
+
 \section{Red-Black Tree}