Index: doc/proposals/concurrency/citations.bib
===================================================================
--- doc/proposals/concurrency/citations.bib	(revision aee7e357e05cb415960451a7e9e01d6d2ce6ede1)
+++ doc/proposals/concurrency/citations.bib	(revision 7e1077328aef0bbffbe33b1a3ff3feea08603b66)
@@ -23,36 +23,51 @@
 
 @mastersthesis{Bilson:CFA,
-    keywords    = {Cforall, Overloading, Polymorphism},
-    author  = {Richard C. Bilson},
-    title   = {Implementing Overloading and Polymorphism in Cforall},
-    school = "University of Waterloo",
-    year = "2003"
+    keywords    	= {Cforall, Overloading, Polymorphism},
+    author  	= {Richard C. Bilson},
+    title   	= {Implementing Overloading and Polymorphism in Cforall},
+    school 		= "University of Waterloo",
+    year 		= "2003"
 }
 
 @article{HPP:Study,
-	title = {Parallel Programmer Productivity: A Case Study of Novice Parallel Programmers}
+	keywords 	= {Parallel, Productivity},
+	author 	= {Lorin Hochstein and Jeff Carver and Forrest Shull and Sima Asgari and Victor Basili and Jeffrey K. Hollingsworth and Marvin V. Zelkowitz },
+	title 	= {Parallel Programmer Productivity: A Case Study of Novice Parallel Programmers},
 }
 @article{CFA:Refrat,
     keywords	= {Cforall, refrat},
-    author	= {Glen Ditchfield},
-    title	= {Cforall Reference Manual and Rationale},
-    month	= jan,
-    year	= 2003
+    author		= {Glen Ditchfield},
+    title		= {Cforall Reference Manual and Rationale},
+    month		= jan,
+    year		= 2003
+}
+
+@article{Chicken,
+	keywords	= {Chicken},
+	author	= {Doug Zongker},
+	title		= {Chicken Chicken Chicken: Chicken Chicken},
+	year		= 2006
+}
+
+@article{Myths,
+	author 	= {Peter A. Buhr and Ashif S. Harji},
+	title 	= {Concurrent Urban Legends},
+	year 		= 2005
 }
 
 @article{uCPP:Book,
-    keywords    = {uC++, manual, book},
-    author  = {Peter A. Buhr},
-    title   = {Understanding Control Flow with Concurrent Programming using $\mu${C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}}},
-    month   = aug,
-    year    = 2014
+    keywords    	= {uC++, manual, book},
+    author  	= {Peter A. Buhr},
+    title   	= {Understanding Control Flow with Concurrent Programming using $\mu${C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}}},
+    month   	= aug,
+    year    	= 2014
 }
 
 @techreport{ISO:Ada,
-    type = {International Standard},
-    key = {ISO/IEC 8652:1995},
-    year = {1995},
-    title = {Ada},
-    volume = {1995},
-    institution = {International Organization for Standardization}
+    type 		= {International Standard},
+    key 		= {ISO/IEC 8652:1995},
+    year 		= {1995},
+    title 		= {Ada},
+    volume 		= {1995},
+    institution 	= {International Organization for Standardization}
 }
Index: doc/proposals/concurrency/concurrency.tex
===================================================================
--- doc/proposals/concurrency/concurrency.tex	(revision aee7e357e05cb415960451a7e9e01d6d2ce6ede1)
+++ doc/proposals/concurrency/concurrency.tex	(revision 7e1077328aef0bbffbe33b1a3ff3feea08603b66)
@@ -1,10 +1,10 @@
 % requires tex packages: texlive-base texlive-latex-base tex-common texlive-humanities texlive-latex-extra texlive-fonts-recommended
 
-% inline code �...� (copyright symbol) emacs: C-q M-)
-% red highlighting �...� (registered trademark symbol) emacs: C-q M-.
-% blue highlighting �...� (sharp s symbol) emacs: C-q M-_
-% green highlighting �...� (cent symbol) emacs: C-q M-"
-% LaTex escape �...� (section symbol) emacs: C-q M-'
-% keyword escape �...� (pilcrow symbol) emacs: C-q M-^
+% inline code ©...© (copyright symbol) emacs: C-q M-)
+% red highlighting ®...® (registered trademark symbol) emacs: C-q M-.
+% blue highlighting ß...ß (sharp s symbol) emacs: C-q M-_
+% green highlighting ¢...¢ (cent symbol) emacs: C-q M-"
+% LaTex escape §...§ (section symbol) emacs: C-q M-'
+% keyword escape ¶...¶ (pilcrow symbol) emacs: C-q M-^
 % math escape $...$ (dollar symbol)
 
@@ -24,5 +24,6 @@
 \usepackage{graphicx}
 \usepackage{tabularx}
-\usepackage{varioref}									% extended references
+\usepackage{varioref}								% extended references
+\usepackage{inconsolata}
 \usepackage{listings}									% format program code
 \usepackage[flushmargin]{footmisc}						% support label/reference in footnote
@@ -54,4 +55,5 @@
 \newcommand{\uC}{$\mu$\CC}
 \newcommand{\cit}{\textsuperscript{[Citation Needed]}\xspace}
+\newcommand{\code}[1]{\lstinline{#1}}
 
 
@@ -77,18 +79,18 @@
 \section{Introduction}
 This proposal provides a minimal core concurrency API that is both simple, efficient and can be reused to build "higher level" features. The simplest possible core is a thread and a lock but this low level approach is hard to master. An easier approach for users is be to support higher level construct as the basis of the concurrency in \CFA.
-Indeed, for higly productive parallel programming high-level approaches are much more popular. Examples are task based parallelism, message passing, implicit threading.
-
-There are actually to problems that need to be solved in the design of the concurrency for a language. Which concurrency tools are available to the users and which parallelism tools are available. While these two concepts are often seen together, they are in fact distinct concepts that require different sorts of tools. Concurrency tools need to handle mutual exclusion and synchronization while parallelism tools are more about performance, cost and ressource utilisation.
+Indeed, for higly productive parallel programming high-level approaches are much more popular\cite{HPP:Study}. Examples are task based parallelism, message passing, implicit threading.
+
+There are actually two problems that need to be solved in the design of the concurrency for a language. Which concurrency tools are available to the users and which parallelism tools are available. While these two concepts are often seen together, they are in fact distinct concepts that require different sorts of tools\cite{Myths}. Concurrency tools need to handle mutual exclusion and synchronization while parallelism tools are more about performance, cost and ressource utilisation.
 
 \section{Concurrency}
-Several tool can be used to solve concurrency challenges. Since these challenges always appear with the use of mutable shared state, some languages and libraries simply disallow mutable shared states completely (Erlang, Haskel, Akka (Scala))\cit. In the paradigms, interaction between concurrent objects rely on message passing or other paradigms that often closely relate to networking concepts. However, in imperative or OO languages these approaches entail a clear distinction between concurrent and non concurrent paradigms. Which in turns mean that programmers need to learn two sets of designs patterns in order to be effective at their jobs. Approaches based on shared memory are more closely related to non-concurrent paradigms since they often rely
-
-Finally, an approach that is gaining in popularity is transactionnal memory\cit. However, the performance and feature set is currently too restrictive to be possible to add such a paradigm to a language like C or \CC\cit.
+Several tool can be used to solve concurrency challenges. Since these challenges always appear with the use of mutable shared state, some languages and libraries simply disallow mutable shared state completely (Erlang, Haskel, Akka (Scala))\cit. In the paradigms, interaction between concurrent objects rely on message passing or other paradigms that often closely relate to networking concepts. However, in imperative or OO languages these approaches entail a clear distinction between concurrent and non concurrent paradigms. Which in turns mean that programmers need to learn two sets of designs patterns in order to be effective at their jobs. Approaches based on shared memory are more closely related to non-concurrent paradigms since they often rely on non-concurrent constructs like routine calls and objects. At a lower level these can be implemented as locks and atomic operations. However for productivity reasons it is desireable to have a higher-level construct to be the core concurrency paradigm\cite{HPP:Study}. This paper proposes Monitors\cit as the core concurrency construct.
+
+Finally, an approach that is worth mentionning because it is gaining in popularity is transactionnal memory\cit. However, the performance and feature set is currently too restrictive to be possible to add such a paradigm to a language like C or \CC\cit, which is why it was rejected as the core paradigm for concurrency in \CFA.
 
 \section{Monitors}
-A monitor is a set of routines that ensure mutual exclusion when accessing shared state. This concept is generally associated with Object-Oriented Languages like Java\cit or \uC\cit but does not strictly require OOP semantics. The only requirements is to be able to declare a handle to a shared object and a set of routines that act on it :
-\begin{lstlisting}
-	typedef \*some monitor type*\ monitor;
-	int f(monitor& m);
+A monitor is a set of routines that ensure mutual exclusion when accessing shared state. This concept is generally associated with Object-Oriented Languages like Java\cit or \uC\cite{uCPP:Book} but does not strictly require OOP semantics. The only requirements is to be able to declare a handle to a shared object and a set of routines that act on it :
+\begin{lstlisting}
+	typedef /*some monitor type*/ monitor;
+	int f(monitor & m);
 
 	int main() {
@@ -98,34 +100,46 @@
 \end{lstlisting}
 
-\subsection{Call semantics}
+\subsection{Call semantics} \label{call}
 The above example of monitors already displays some of their intrinsic caracteristics. Indeed, it is necessary to use pass-by-reference over pass-by-value for monitor routines. This semantics is important because since at their core, monitors are simply implicit mutual exclusion objects (locks) and copying semantics of these is ill defined. Therefore, monitors are implicitly non-copyable.
 
-Another aspect to consider is when a monitor acquires its mutual exclusion. Indeed, a monitor may need to be passed to helper routines that do not acquire the monitor mutual exclusion on entry. Examples of this can be both external helper routines (\texttt{swap}, \texttt{sort}, etc.) or internal helper routines like the following example :
-
-\begin{lstlisting}
-
-\end{lstlisting}
-
-Having both \texttt{mutex} and \texttt{nomutex} keywords could be argued to be redundant based on the meaning of a routine having neither of these keywords. If there were a meaning to routine \texttt{h} then one could argue that it should be to default to \texttt{mutex} to be safe by default. On the other hand, making one of these keywords mandatory would provide the same semantics but without the ambiguity of supporting routine \texttt{h}. Mandatory keywords would also have the added benefice of being more clearly self-documented. In any case, the option of having routine \texttt{h} mean \texttt{nomutex} should be rejected since it is unsafe by default and may easily cause subtle errors.
-
-Furthermore, it is important to establish when mutex/nomutex may be used depending on type parameters.
-\begin{lstlisting}
-	int f01(monitor& mutex m);
-	int f02(const monitor& mutex m);
-	int f03(monitor* mutex m);
-	int f04(monitor* mutex * m);
-	int f05(monitor** mutex m);
+Another aspect to consider is when a monitor acquires its mutual exclusion. Indeed, a monitor may need to be passed to helper routines that do not acquire the monitor mutual exclusion on entry. Examples of this can be both generic helper routines (\code{swap}, \code{sort}, etc.) or specific helper routines like the following example :
+
+\begin{lstlisting}
+	mutex struct counter_t { /*...*/ };
+
+	void ?{}(counter_t & mutex this);
+	int ++?(counter_t & mutex this);
+	void ?{}(int * this, counter_t & mutex cnt);
+
+	bool is_zero(counter_t & nomutex this) {
+		int val = this;
+		return val == 0;
+	}
+\end{lstlisting}
+*semantics of the declaration of \code{mutex struct counter_t} will be discussed in details in \ref{data}
+
+This is an example of a monitor used as safe(ish) counter for concurrency. This API, which offers the prefix increment operator and a conversion operator to \code{int}, guarantees that reading the value (by converting it to \code{int}) and incrementing it are mutually exclusive. Note that the \code{is_zero} routine uses the \code{nomutex} keyword. Indeed, since reading the value is already atomic, there is no point in maintaining the mutual exclusion once the value is copied locally (in the variable \code{val} ).
+
+Having both \code{mutex} and \code{nomutex} keywords could be argued to be redundant based on the meaning of a routine having neither of these keywords. If there were a meaning to routine \code{void foo(counter_t & this)} then one could argue that it should be to default to the safest option : \code{mutex}. On the other hand, the option of having routine \code{void foo(counter_t & this)} mean \code{nomutex} is unsafe by default and may easily cause subtle errors. It can be argued that this is the more "normal" behavior, \code{nomutex} effectively stating explicitly that "this routine has nothing special". An other alternative is to make one of these keywords mandatory, which would provide the same semantics but without the ambiguity of supporting routine \code{void foo(counter_t & this)}. Mandatory keywords would also have the added benefice of being more clearly self-documented but at the cost of extra typing. In the end, which solution should be picked is still up for debate. For the reminder of this proposal, the explicit approach will be used for the sake of clarity.
+
+Regardless of which keyword is kept, it is important to establish when mutex/nomutex may be used depending on type parameters.
+\begin{lstlisting}
+	int f01(monitor & mutex m);
+	int f02(const monitor & mutex m);
+	int f03(monitor * mutex m);
+	int f04(monitor * mutex * m);
+	int f05(monitor ** mutex m);
 	int f06(monitor[10] mutex m);
 	int f07(monitor[] mutex m);
-	int f08(vector(monitor)& mutex m);
-	int f09(list(monitor)& mutex m);
-	int f10([monitor*, int]& mutex m);
-	int f11(graph(monitor*)& mutex m);
-\end{lstlisting}
-
-For the first routines it seems to make sense to support the mutex keyword for such small variations. The difference between pointers and reference (\texttt{f01} vs \texttt{f03}) or const and non-const (\texttt{f01} vs \texttt{f02}) has no significance to mutual exclusion. It may not always make sense to acquire the monitor when extra dereferences (\texttt{f04}, \texttt{f05}) are added but it is still technically feasible and the present of the explicit mutex keywork does make it very clear of the user's intentions. Passing in a known-sized array(\texttt{f06}) is also technically feasible but is close to the limits. Indeed, the size of the array is not actually enforced by the compiler and if replaced by a variable-sized array (\texttt{f07}) or a higher-level container (\texttt{f08}, \texttt{f09}) it becomes much more complex to properly acquire all the locks needed for such a complex critical section. This implicit acquisition also poses the question of what qualifies as a container. If the mutex keyword is supported on monitors stored inside of other types it can quickly become complex and unclear which monitor should be acquired and when. The extreme example of this is \texttt{f11} which takes a possibly cyclic graph of pointers to monitors. With such a routine signature the intuition of which monitors will be acquired on entry is lost. Where to draw the lines is up for debate but it seems reasonnable to consider \texttt{f03} as accepted and \texttt{f06} as rejected.
-
-\subsection{Data semantics}
-Once the call semantics are established, the next step is to establish data semantics. Indeed, until now a monitor is used simply as a generic handle but in most cases monitors contian shared data. This data should be intrinsic to the monitor declaration to prevent any accidental use of data without its appripriate protection. For example :
+	int f08(vector(monitor) & mutex m);
+	int f09(list(monitor) & mutex m);
+	int f10([monitor*, int] & mutex m);
+	int f11(graph(monitor*) & mutex m);
+\end{lstlisting}
+
+For the first few routines it seems to make sense to support the mutex keyword for such small variations. The difference between pointers and reference (\code{f01} vs \code{f03}) or const and non-const (\code{f01} vs \code{f02}) has no significance to mutual exclusion. It may not always make sense to acquire the monitor when extra dereferences (\code{f04}, \code{f05}) are added but it is still technically feasible and the present of the explicit mutex keywork does make it very clear of the user's intentions. Passing in a known-sized array(\code{f06}) is also technically feasible but is close to the limits. Indeed, the size of the array is not actually enforced by the compiler and if replaced by a variable-sized array (\code{f07}) or a higher-level container (\code{f08}, \code{f09}) it becomes much more complex to properly acquire all the locks needed for such a complex critical section. This implicit acquisition also poses the question of what qualifies as a container. If the mutex keyword is supported on monitors stored inside of other types it can quickly become complex and unclear which monitor should be acquired and when. The extreme example of this is \code{f11} which takes a possibly cyclic graph of pointers to monitors. With such a routine signature the intuition of which monitors will be acquired on entry is lost\cite{Chicken}. Where to draw the lines is up for debate but it seems reasonnable to consider \code{f03} as accepted and \code{f06} as rejected.
+
+\subsection{Data semantics} \label{data}
+Once the call semantics are established, the next step is to establish data semantics. Indeed, until now a monitor is used simply as a generic handle but in most cases monitors contian shared data. This data should be intrinsic to the monitor declaration to prevent any accidental use of data without its appripriate protection. For example here is a more fleshed-out version of the counter showed in \ref{call}:
 \begin{lstlisting}
 	mutex struct counter_t {
@@ -133,13 +147,13 @@
 	};
 
-	void ?{}(counter_t& mutex this) {
+	void ?{}(counter_t & mutex this) {
 		this.cnt = 0;
 	}
 
-	int ++?(counter_t& mutex this) {
+	int ++?(counter_t & mutex this) {
 		return ++this->value;
 	}
 
-	void ?{}(int* this, counter_t& mutex cnt) {
+	void ?{}(int * this, counter_t & mutex cnt) {
 		*this = (int)cnt;
 	}
@@ -148,5 +162,5 @@
 Thread 1 & Thread 2 \\
 \begin{lstlisting}
-	void main(counter_t& mutex c) {
+	void main(counter_t & mutex c) {
 		for(;;) {
 			int count = c;
@@ -154,6 +168,6 @@
 		}
 	}
-\end{lstlisting}&\begin{lstlisting}
-	void main(counter_t& mutex c) {
+\end{lstlisting} &\begin{lstlisting}
+	void main(counter_t & mutex c) {
 		for(;;) {
 			++c;
@@ -166,9 +180,9 @@
 
 
-This simple counter monitor offers an example of monitor usage. Notice how the counter is used without any explicit synchronisation and yet is perfectly safe reglardless of how many threads use it simultaneously. \\
+This simple counter offers an example of monitor usage. Notice how the counter is used without any explicit synchronisation and yet supports thread-safe semantics for both reading and writting. \\
 
 These simple mutual exclusion semantics also naturally expand to multi-monitor calls.
 \begin{lstlisting}
-	int f(MonitorA& mutex a, MonitorB& mutex b);
+	int f(MonitorA & mutex a, MonitorB & mutex b);
 
 	MonitorA a;
@@ -176,24 +190,29 @@
 	f(a,b);
 \end{lstlisting}
-This code acquires both locks before entering the critical section. In practice, writing multi-locking routines that can lead to deadlocks can be very tricky. Having language level support for such feature is therefore a significant asset for \CFA. However, as the this proposal shows, this does have significant repercussions relating to scheduling. The ability to acquire multiple monitors at the same time does incur a significant pitfall even without looking into scheduling. For example :
-\begin{lstlisting}
-	void foo(A& mutex a, B& mutex a) {
-		//...
-	}
-
-	void bar(A& mutex a, B& mutex a)
+
+This code acquires both locks before entering the critical section. In practice, writing multi-locking routines that can lead to deadlocks can be very tricky. Having language level support for such feature is therefore a significant asset for \CFA. However, as the this proposal shows, this does have significant repercussions relating to scheduling (see \ref{insched} and \ref{extsched}). The ability to acquire multiple monitors at the same time does incur a significant pitfall even without looking into scheduling. For example :
+\begin{lstlisting}
+	void foo(A & mutex a, B & mutex a) {
+		//...
+	}
+
+	void bar(A & mutex a, B & nomutex a)
 		//...
 		foo(a, b);
 		//...
 	}
-\end{lstlisting}
-
-
-% Here, there is a language design choice that has to be made. It is impossible to protect the user from both barging and deadlocks and therefore this code has the potential to deadlock if some other threads try to acquire the locks in a different order (keep in mind that the lock ordering may be invisible or non-deterministic). The alternative is to allow the algorithm to release the lock on monitor \texttt{a}. This would effectively prevent the deadlock but could also mean that mutual exclusion may be dropped in the midle of routine \texttt{bar}.
-%
-% Indeed, there are two options for acquiring multiple locks while preventing deadlocks. The first option is to prescribe some arbitrary order of locking. If used consistently in the application this solution is both deadlock-free and barging-free. However, it also relies on the user to consistently follow the ordering when manually specifying the order. If the lock ordering is based on lock creation order or heap address ordering, it may be impossible for users to statically predict the correct lock acquiring order which means that deadlocks are a very real possibility. On the other hand, if the locking algorithm tries to dynamically find the correct lock ordering then it must release all locks after each wrong ordering attempts. This does not cause any significant issue in the context where a users tries to acquire multiple locks at once since the thread is not already in a critical section. However, if the thread was already holding a lock then releasing all locks on failed attempts may mean violating the mutual exclusion of the critical section. Notice that this is only an issue when nested mutex routines are used, in any other case monitors will behave consistently between both algorithms. Since releasing a lock in the middle of a critical section effectively violates mutual exclusion, it seems reasonnable to reject algorithms that dynamically guess the order of lock acquiring since users need to be very comfortable with multi-lock semantics before they can expect nested monitor calls to end-up releasing locks.
-
-
-\subsubsection{Internal scheduling}
+
+	void baz(A & nomutex a, B & mutex a)
+		//...
+		foo(a, b);
+		//...
+	}
+\end{lstlisting}
+
+TODO: dig further into monitor order aquiring
+
+Thoughs : calls to \code{baz} and \code{bar} are definitely incompatible because they explicitly acquire locks in reverse order and therefore are explicitly asking for a deadlock. The best that can be done in this situatuin is to detect the deadlock. The case of implicit ordering is less clear because in the case of monitors the runtime system \textit{may} be smart enough to figure out that someone is waiting with explicit ordering... maybe.
+
+\subsubsection{Internal scheduling} \label{insched}
 Monitors should also be able to schedule what threads access it as a mean of synchronization. Internal scheduling is one of the simple examples of such a feature. It allows users to declare condition variables and wait for them to be signaled. Here is a simple example of such a technique :
 
@@ -203,5 +222,5 @@
 	}
 
-	void foo(A& mutex a) {
+	void foo(A & mutex a) {
 		//...
 		wait(a.e);
@@ -209,15 +228,17 @@
 	}
 
-	void bar(A& mutex a) {
+	void bar(A & mutex a) {
 		signal(a.e);
 	}
 \end{lstlisting}
 
-Here routine \texttt{foo} waits on the \texttt{signal} from \texttt{bar} before making further progress, effectively ensuring a basic ordering. This can easily be extended to multi-monitor calls by offering the same guarantee.
-
-\begin{tabular}{ c c }
+Here routine \code{foo} waits on the \code{signal} from \code{bar} before making further progress, effectively ensuring a basic ordering. This can easily be extended to multi-monitor calls by offering the same guarantee.
+
+\begin{center}
+\begin{tabular}{ c @{\hskip 0.65in} c }
 Thread 1 & Thread 2 \\
 \begin{lstlisting}
-void foo(monitor& mutex a, monitor& mutex b) {
+void foo(monitor & mutex a,
+         monitor & mutex b) {
 	//...
 	wait(a.e);
@@ -226,6 +247,7 @@
 
 foo(a, b);
-\end{lstlisting}&\begin{lstlisting}
-void bar(monitor& mutex a, monitor& mutex b) {
+\end{lstlisting} &\begin{lstlisting}
+void bar(monitor & mutex a,
+         monitor & mutex b) {
 	signal(a.e);
 }
@@ -236,14 +258,15 @@
 \end{lstlisting}
 \end{tabular}
-\\
+\end{center}
 
 A direct extension of the single monitor semantics would be to release all locks when waiting and transferring ownership of all locks when signalling. However, for the purpose of synchronization it may be usefull to only release some of the locks but keep others. On the technical side, partially releasing lock is feasible but from the user perspective a choice must be made for the syntax of this feature. It is possible to do without any extra syntax by relying on order of acquisition :
 
+\begin{center}
 \begin{tabular}{|c|c|c|}
 Context 1 & Context 2 & Context 3 \\
 \hline
 \begin{lstlisting}
-void foo(monitor& mutex a,
-         monitor& mutex b) {
+void foo(monitor & mutex a,
+         monitor & mutex b) {
 	wait(a.e);
 }
@@ -255,24 +278,24 @@
 
 foo(a,b);
-\end{lstlisting}&\begin{lstlisting}
-void bar(monitor& mutex a,
-         monitor& nomutex b) {
+\end{lstlisting} &\begin{lstlisting}
+void bar(monitor & mutex a,
+         monitor & nomutex b) {
 	foo(a,b);
 }
 
-void foo(monitor& mutex a,
-         monitor& mutex b) {
+void foo(monitor & mutex a,
+         monitor & mutex b) {
 	wait(a.e);
 }
 
 bar(a, b);
-\end{lstlisting}&\begin{lstlisting}
-void bar(monitor& mutex a,
-         monitor& nomutex b) {
+\end{lstlisting} &\begin{lstlisting}
+void bar(monitor & mutex a,
+         monitor & nomutex b) {
 	foo(a,b);
 }
 
-void baz(monitor& nomutex a,
-         monitor& mutex b) {
+void baz(monitor & nomutex a,
+         monitor & mutex b) {
 	wait(a.e);
 }
@@ -281,15 +304,15 @@
 \end{lstlisting}
 \end{tabular}
-\\
-
-This can be interpreted in two different ways.
+\end{center}
+
+This can be interpreted in two different ways :
 \begin{enumerate}
-	\item \texttt{wait} atomically releases the monitors \underline{theoretically} acquired by the inner-most mutex routine.
-	\item \texttt{wait} atomically releases the monitors \underline{actually} acquired by the inner-most mutex routine.
+	\item \code{wait} atomically releases the monitors \underline{theoretically} acquired by the inner-most mutex routine.
+	\item \code{wait} atomically releases the monitors \underline{actually} acquired by the inner-most mutex routine.
 \end{enumerate}
-While the difference between these two is subtle, it has a significant impact. In the first case it means that the calls to \texttt{foo} would behave the same in Context 1 and 2. This semantic would also mean that the call to \texttt{wait} in routine \texttt{baz} would only release \texttt{monitor b}. While this may seem intuitive with these examples, it does have one significant implication, it creates a strong distinction between acquiring multiple monitors in sequence and acquiring the same monitors simulatenously.
+While the difference between these two is subtle, it has a significant impact. In the first case it means that the calls to \code{foo} would behave the same in Context 1 and 2. This semantic would also mean that the call to \code{wait} in routine \code{baz} would only release \code{monitor b}. While this may seem intuitive with these examples, it does have one significant implication, it creates a strong distinction between acquiring multiple monitors in sequence and acquiring the same monitors simulatenously.
 
 \begin{center}
-\begin{tabular}{c c c}
+\begin{tabular}{c @{\hskip 0.35in} c @{\hskip 0.35in} c}
 \begin{lstlisting}
 enterMonitor(a);
@@ -298,5 +321,5 @@
 leaveMonitor(b);
 leaveMonitor(a);
-\end{lstlisting}& != &\begin{lstlisting}
+\end{lstlisting} & != &\begin{lstlisting}
 enterMonitor(a);
 enterMonitor(a, b);
@@ -308,5 +331,5 @@
 \end{center}
 
-This is not intuitive because even if both methods will display the same monitors state both inside and outside the critical section respectively, the behavior is different. Furthermore, the actual acquiring order will be exaclty the same since acquiring a monitor from inside its mutual exclusion is a no-op. This means that even if the data and the actual control flow are the same using both methods, the behavior of the \texttt{wait} will be different. The alternative is option 2, that is releasing \underline{actually} acquired monitors. This solves the issue of having the two acquiring method differ at the cost of making routine \texttt{foo} behave differently depending on from which context it is called (Context 1 or 2). Indeed in Context 2, routine \texttt{foo} will actually behave like routine \texttt{baz} rather than having the same behavior than in context 1. The fact that both implicit approaches can be unintuitive depending on the perspective may be a sign that the explicit approach is superior.
+This is not intuitive because even if both methods will display the same monitors state both inside and outside the critical section respectively, the behavior is different. Furthermore, the actual acquiring order will be exaclty the same since acquiring a monitor from inside its mutual exclusion is a no-op. This means that even if the data and the actual control flow are the same using both methods, the behavior of the \code{wait} will be different. The alternative is option 2, that is releasing \underline{actually} acquired monitors. This solves the issue of having the two acquiring method differ at the cost of making routine \code{foo} behave differently depending on from which context it is called (Context 1 or 2). Indeed in Context 2, routine \code{foo} will actually behave like routine \code{baz} rather than having the same behavior than in context 1. The fact that both implicit approaches can be unintuitive depending on the perspective may be a sign that the explicit approach is superior.
 \\
 
@@ -314,4 +337,5 @@
 \\
 
+\begin{center}
 \begin{tabular}{|c|c|c|}
 Case 1 & Case 2 & Case 3 \\
@@ -319,10 +343,10 @@
 \hline
 \begin{lstlisting}
-void foo(monitor& mutex a,
-         monitor& mutex b,
-	   condition& c)
+void foo(monitor & mutex a,
+         monitor & mutex b,
+	   condition & c)
 {
 	// Releases monitors
-	// branded on construction
+	// branded in ctor
 	wait(c);
 }
@@ -338,8 +362,8 @@
 //Will release a and b
 foo(a,b,c2);
-\end{lstlisting}&\begin{lstlisting}
-void foo(monitor& mutex a,
-         monitor& mutex b,
-	   condition& c)
+\end{lstlisting} &\begin{lstlisting}
+void foo(monitor & mutex a,
+         monitor & mutex b,
+	   condition & c)
 {
 	// Releases monitor a
@@ -358,8 +382,8 @@
 
 
-\end{lstlisting}&\begin{lstlisting}
-void foo(monitor& mutex a,
-         monitor& mutex b,
-	   condition& c)
+\end{lstlisting} &\begin{lstlisting}
+void foo(monitor & mutex a,
+         monitor & mutex b,
+	   condition & c)
 {
 	// Releases monitor a
@@ -380,19 +404,19 @@
 \end{lstlisting}
 \end{tabular}
-
+\end{center}
 (Note : Case 2 and 3 use tuple semantics to pass a variable length list of elements.)
 \\
 
-All these cases have there pros and cons. Case 1 is more distinct because it means programmers need to be carefull about where the condition was initialized as well as where it is used. On the other hand, it is very clear and explicit which monitor will be released and which monitor will stay acquired. This is similar to Case 2, which releases only the monitors explictly listed. However, in Case 2, calling the \texttt{wait} routine instead of the \texttt{waitRelease} routine will release all the acquired monitor. The Case 3 is an improvement on that since it releases all the monitors except those specified. The result is that the \texttt{wait} routine can be written as follows :
-\begin{lstlisting}
-void wait(condition& cond) {
+All these cases have there pros and cons. Case 1 is more distinct because it means programmers need to be carefull about where the condition was initialized as well as where it is used. On the other hand, it is very clear and explicit which monitor will be released and which monitor will stay acquired. This is similar to Case 2, which releases only the monitors explictly listed. However, in Case 2, calling the \code{wait} routine instead of the \code{waitRelease} routine will release all the acquired monitor. The Case 3 is an improvement on that since it releases all the monitors except those specified. The result is that the \code{wait} routine can be written as follows :
+\begin{lstlisting}
+void wait(condition & cond) {
 	waitHold(cond, []);
 }
 \end{lstlisting}
-This alternative offers nice and consistent behavior between \texttt{wait} and \texttt{waitHold}. However, one large pitfall is that mutual exclusion can now be violated by calls to library code. Indeed, even if the following example seems benign there is one significant problem :
+This alternative offers nice and consistent behavior between \code{wait} and \code{waitHold}. However, one large pitfall is that mutual exclusion can now be violated by calls to library code. Indeed, even if the following example seems benign there is one significant problem :
 \begin{lstlisting}
 extern void doStuff();
 
-void foo(monitor& mutex m) {
+void foo(monitor & mutex m) {
 	//...
 	doStuff(); //warning can release monitor m
@@ -400,21 +424,24 @@
 }
 \end{lstlisting}
-Indeed, if Case 2 or 3 are chosen it any code can violate the mutual exclusion of calling code by issuing calls to \texttt{wait} or \texttt{waitHold} in a nested monitor context. Case 2 can be salvaged by removing the \texttt{wait} routine from the API but Case 3 cannot prevent users from calling \texttt{waitHold(someCondition, [])}. For this reason the syntax proposed in Case 3 is rejected. Note that syntaxes proposed in case 1 and 2 are not exclusive. Indeed, by supporting two types of condition as follows both cases can be supported :
+
+Indeed, if Case 2 or 3 are chosen it any code can violate the mutual exclusion of calling code by issuing calls to \code{wait} or \code{waitHold} in a nested monitor context. Case 2 can be salvaged by removing the \code{wait} routine from the API but Case 3 cannot prevent users from calling \code{waitHold(someCondition, [])}. For this reason the syntax proposed in Case 3 is rejected. Note that syntaxes proposed in case 1 and 2 are not exclusive. Indeed, by supporting two types of condition as follows both cases can be supported :
 \begin{lstlisting}
 struct condition { /*...*/ };
 
-void wait(condition& cond, [...] monitorsToRelease); // Second argument is a variable length tuple.
-void signal(condition& cond);
+// Second argument is a variable length tuple.
+void wait(condition & cond, [...] monitorsToRelease);
+void signal(condition & cond);
 
 struct conditionN { /*...*/ };
 
 void ?{}(conditionN* this, /*list of N monitors to release*/);
-void wait(conditionN& cond);
-void signal(conditionN& cond);
-\end{lstlisting}
-
-Regardless of the option chosen for wait semantics, signal must be symmetrical. In all cases, signal only needs a single parameter, the condition variable that needs to be signalled. But \texttt{signal} needs to be called from the same monitor(s) than the call to \texttt{wait}. Otherwise, mutual exclusion cannot be properly transferred back to the waiting monitor.
-
-\subsection{External scheduling}
+void wait(conditionN & cond);
+void signal(conditionN & cond);
+\end{lstlisting}
+
+Regardless of the option chosen for wait semantics, signal must be symmetrical. In all cases, signal only needs a single parameter, the condition variable that needs to be signalled. But \code{signal} needs to be called from the same monitor(s) than the call to \code{wait}. Otherwise, mutual exclusion cannot be properly transferred back to the waiting monitor.
+
+\subsection{External scheduling} \label{extsched}
+\textbf{\large{Work in progress...}}
 As one might expect, the alternative to Internal scheduling is to use external scheduling instead. The goal of external scheduling is to be able to have the same scheduling power as internal scheduling without the requirement that any thread can acquire the monitor lock. This method is somewhat more robust to deadlocks since one of the threads keeps a relatively tight control on scheduling. External scheduling can generally be done either in terms of control flow (see \uC) or in terms of data (see Go). Of course, both of these paradigms have their own strenghts and weaknesses but for this project control flow semantics where chosen to stay consistent with the reset of the languages semantics. Two challenges specific to \CFA arise when trying to add external scheduling which is loose object definitions and multi-monitor routines.
 
@@ -435,27 +462,27 @@
 	mutex struct A {};
 
-	void f(A& mutex a) { accept(g); }
-	void g(A& mutex a);
-\end{lstlisting}
-
-While this is the direct translation of the \uC code, at the time of compiling routine \texttt{f} the \CFA does not already have a declaration of \texttt{g} while the \uC compiler does. This means that either the compiler has to dynamically find which routines are "acceptable" or the language needs a way of statically listing "acceptable" routines. Since \CFA has no existing concept that resemble dynamic routine definitions or pattern matching, the static approach seems the more consistent with the current language paradigms. This approach leads to the \uC example being translated to :
-\begin{lstlisting}
-	accept( void g(mutex struct A& mutex a) )
+	void f(A & mutex a) { accept(g); }
+	void g(A & mutex a);
+\end{lstlisting}
+
+While this is the direct translation of the \uC code, at the time of compiling routine \code{f} the \CFA does not already have a declaration of \code{g} while the \uC compiler does. This means that either the compiler has to dynamically find which routines are "acceptable" or the language needs a way of statically listing "acceptable" routines. Since \CFA has no existing concept that resemble dynamic routine definitions or pattern matching, the static approach seems the more consistent with the current language paradigms. This approach leads to the \uC example being translated to :
+\begin{lstlisting}
+	accept( void g(mutex struct A & mutex a) )
 	mutex struct A {};
 
-	void f(A& mutex a) { accept(g); }
-	void g(A& mutex a);
-\end{lstlisting}
-
-This syntax is the most consistent with the language since it somewhat mimics the \texttt{forall} declarations. However, the fact that it comes before the struct declaration does means the type needs to be forward declared (done inline in the example). Here are a few alternatives to this syntax : \\
+	void f(A & mutex a) { accept(g); }
+	void g(A & mutex a);
+\end{lstlisting}
+
+This syntax is the most consistent with the language since it somewhat mimics the \code{forall} declarations. However, the fact that it comes before the struct declaration does means the type needs to be forward declared (done inline in the example). Here are a few alternatives to this syntax : \\
 \begin{tabular}[t]{l l}
 Alternative 1 & Alternative 2 \\
 \begin{lstlisting}
 mutex struct A
-accept( void g(A& mutex a) )
+accept( void g(A & mutex a) )
 {};
-\end{lstlisting}&\begin{lstlisting}
+\end{lstlisting} &\begin{lstlisting}
 mutex struct A {}
-accept( void g(A& mutex a) );
+accept( void g(A & mutex a) );
 
 \end{lstlisting} \\
@@ -463,11 +490,11 @@
 \begin{lstlisting}
 mutex struct A {
-	accept( void g(A& mutex a) )
+	accept( void g(A & mutex a) )
 };
 
-\end{lstlisting}&\begin{lstlisting}
+\end{lstlisting} &\begin{lstlisting}
 mutex struct A {
 	accept :
-		void g(A& mutex a) );
+		void g(A & mutex a) );
 };
 \end{lstlisting}
@@ -481,10 +508,10 @@
 External scheduling, like internal scheduling, becomes orders of magnitude more complex when we start introducing multi-monitor syntax. Even in the simplest possible case some new semantics need to be established :
 \begin{lstlisting}
-	accept( void f(mutex struct A& mutex this))
+	accept( void f(mutex struct A & mutex this))
 	mutex struct A {};
 
 	mutex struct B {};
 
-	void g(A& mutex a, B& mutex b) {
+	void g(A & mutex a, B & mutex b) {
 		accept(f); //ambiguous, which monitor
 	}
@@ -494,34 +521,35 @@
 
 \begin{lstlisting}
-	accept( void f(mutex struct A& mutex this))
+	accept( void f(mutex struct A & mutex this))
 	mutex struct A {};
 
 	mutex struct B {};
 
-	void g(A& mutex a, B& mutex b) {
+	void g(A & mutex a, B & mutex b) {
 		accept( f, b );
 	}
 \end{lstlisting}
 
-This is unambiguous. The both locks will be acquired and kept, when routine \texttt{f} is called the lock for monitor \texttt{a} will be temporarily transferred from \texttt{g} to \texttt{f} (while \texttt{g} still holds lock \texttt{b}). This behavior can be extended to multi-monitor accept statment as follows.
-
-\begin{lstlisting}
-	accept( void f(mutex struct A& mutex, mutex struct A& mutex))
+This is unambiguous. The both locks will be acquired and kept, when routine \code{f} is called the lock for monitor \code{a} will be temporarily transferred from \code{g} to \code{f} (while \code{g} still holds lock \code{b}). This behavior can be extended to multi-monitor accept statment as follows.
+
+\begin{lstlisting}
+	accept( void f(mutex struct A & mutex, mutex struct A & mutex))
 	mutex struct A {};
 
 	mutex struct B {};
 
-	void g(A& mutex a, B& mutex b) {
+	void g(A & mutex a, B & mutex b) {
 		accept( f, b, a );
 	}
 \end{lstlisting}
 
-Note that the set of monitors passed to the \texttt{accept} statement must be entirely contained in the set of monitor already acquired in the routine. \texttt{accept} used in any other context is Undefined Behaviour.
+Note that the set of monitors passed to the \code{accept} statement must be entirely contained in the set of monitor already acquired in the routine. \code{accept} used in any other context is Undefined Behaviour.
 
 \subsection{Implementation Details}
+\textbf{\large{Work in progress...}}
 \subsubsection{Interaction with polymorphism}
 At first glance, interaction between monitors and \CFA's concept of polymorphism seem complexe to support. However, it can be reasoned that entry-point locking can solve most of the issues that could be present with polymorphism.
 
-First of all, interaction between \texttt{otype} polymorphism and monitors is impossible since monitors do not support copying. Therefore the main question is how to support \texttt{dtype} polymorphism. We must remember that monitors' main purpose is to ensure mutual exclusion when accessing shared data. This implies that mutual exclusion is only required for routines that do in fact access shared data. However, since \texttt{dtype} polymorphism always handle incomplete types (by definition) no \texttt{dtype} polymorphic routine can access shared data since the data would require knowledge about the type. Therefore the only concern when combining \texttt{dtype} polymorphism and monitors is to protect access to routines. With callsite-locking, this would require significant amount of work since any \texttt{dtype} routine could have to obtain some lock before calling a routine. However, with entry-point-locking calling a monitor routine becomes exactly the same as calling it from anywhere else.
+First of all, interaction between \code{otype} polymorphism and monitors is impossible since monitors do not support copying. Therefore the main question is how to support \code{dtype} polymorphism. We must remember that monitors' main purpose is to ensure mutual exclusion when accessing shared data. This implies that mutual exclusion is only required for routines that do in fact access shared data. However, since \code{dtype} polymorphism always handle incomplete types (by definition) no \code{dtype} polymorphic routine can access shared data since the data would require knowledge about the type. Therefore the only concern when combining \code{dtype} polymorphism and monitors is to protect access to routines. With callsite-locking, this would require significant amount of work since any \code{dtype} routine could have to obtain some lock before calling a routine. However, with entry-point-locking calling a monitor routine becomes exactly the same as calling it from anywhere else.
 
 \subsubsection{External scheduling queues}
@@ -532,5 +560,4 @@
 \section{Tasks}
 
-
 \section{Naming}
 
