Index: doc/bibliography/pl.bib
===================================================================
--- doc/bibliography/pl.bib	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/bibliography/pl.bib	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -1183,14 +1183,4 @@
 	that is ``compiled''.
     },
-    comment	= {
-        Imagine the program, including the subroutines, spread out over a
-	table, with the compiler dropping Jello on the parts as they are
-	compiled.  At first little drops appear in seemingly random places.
-	These get bigger and combine with other drops to form growing
-	globs.  When two globs meet, ripples will go out through each as
-	they adjust to each other's presence, although the parts of the
-	globs that formed first are less affected by the ripples.  When
-	compilation is complete, there is one congealed mass.
-    }
 }
 
@@ -1388,7 +1378,6 @@
 	Process-valued expressions and process variables.  Processes have
 	execution priority: Create {\em process-type-name}(args) [with
-	priority(p)], 
-	and the priority can be changed on the fly.  Complicated guard/
-	screen structure on accept: accept {\em transaction}(param names)
+	priority(p)], and the priority can be changed on the fly.  Complicated
+	guard/screen structure on accept: accept {\em transaction}(param names)
 	[suchthat (exp)] [by (exp)] [compoundstatement].  Accepts cannot
 	appear in functions!  Can specify timeouts on transaction calls.
@@ -1833,12 +1822,11 @@
 }
 
-@article{Moore75,
-    keywords	= {approximation methods, integrated circuits},
-    contributer	= {pabuhr@plg},
-    author	= {Gordon E. Moore},
-    title	= {Progress in Digital Integrated Electronics},
-    journal	= {Technical Digest, International Electron Devices Meeting, IEEE},
-    year	= 1975,
-    pages	= {11-13},
+@misc{CS343,
+    keywords	= {uC++ teaching},
+    contributer	= {pabuhr@plg},
+    key		= {Peter Buhr},
+    title	= {CS343},
+    year	= 2017,
+    howpublished= {\href{https://www.student.cs.uwaterloo.ca/~cs343}{https://\-www.student.cs.uwaterloo.ca/\-~cs343}},
 }
 
@@ -2568,4 +2556,17 @@
     year	= 1979,
     pages	= {24-32}
+}
+
+@inproceedings{XaaS,
+    keywords	= {Everything as a Service, Anything as a Service, Cloud computing, SOA},
+    contributer	= {pabuhr@plg},
+    author	= {Duan, Yucong and Fu, Guohua and Zhou, Nianjun and Sun, Xiaobing and Narendra, Nanjangud C. and Hu, Bo},
+    title	= {Everything As a Service (XaaS) on the Cloud: Origins, Current and Future Trends},
+    booktitle	= {Proceedings of the 2015 IEEE 8th International Conference on Cloud Computing},
+    series	= {CLOUD'15},
+    year	= {2015},
+    pages	= {621--628},
+    publisher	= {IEEE Computer Society},
+    address	= {Washington, DC, USA},
 }
 
@@ -2779,6 +2780,9 @@
     title	= {Extending Modula-2 to Build Large, Integrated Systems},
     journal	= {IEEE Software},
-    month	= nov, year = 1986,
-    volume	= 3, number = 6, pages = {46-57},
+    month	= nov,
+    year	= 1986,
+    volume	= 3,
+    number	= 6,
+    pages	= {46-57},
     comment	= {
     	Exceptions can have a parameter.  Procedures can declare the
@@ -4893,12 +4897,12 @@
 }
 
-@techreport{OpenMP,
+@manual{OpenMP,
     keywords	= {concurrency, openmp, spmd},
     contributer	= {pabuhr@plg},
-    author	= {OpenMP Architecture Review Board},
-    title	= {OpenMP Application Program Interface, Version 4.0},
-    month	= jul,
-    year	= 2013,
-    note	= {\href{http://www.openmp.org/mp-documents/OpenMP4.0.0.pdf}{http://\-www.openmp.org/\-mp-documents/\-OpenMP4.0.0.pdf}},
+    key		= {OpenMP},
+    title	= {OpenMP Application Program Interface, Version 4.5},
+    month	= nov,
+    year	= 2015,
+    note	= {\href{https://www.openmp.org/wp-content/uploads/openmp-4.5.pdf}{https://\-www.openmp.org/\-wp-content/\-uploads/\-openmp-4.5.pdf}},
 }
 
@@ -5753,10 +5757,19 @@
 }
 
+@article{Moore75,
+    keywords	= {approximation methods, integrated circuits},
+    contributer	= {pabuhr@plg},
+    author	= {Gordon E. Moore},
+    title	= {Progress in Digital Integrated Electronics},
+    journal	= {Technical Digest, International Electron Devices Meeting, IEEE},
+    year	= 1975,
+    pages	= {11-13},
+}
+
 @article{promises,
     keywords	= {futures, Argus, call streams, rpc},
     contributer	= {gjditchfield@plg},
     author	= {Barbara Liskov and Liuba Shrira},
-    title	= {Promises: Linguistic Support for Efficient Asynchronous
-	  Procedure Calls in Distributed Systems},
+    title	= {Promises: Linguistic Support for Efficient Asynchronous Procedure Calls in Distributed Systems},
     journal	= sigplan,
     year	= 1988,
Index: doc/papers/OOPSLA17/Makefile
===================================================================
--- doc/papers/OOPSLA17/Makefile	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/papers/OOPSLA17/Makefile	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -33,4 +33,5 @@
 
 DOCUMENT = generic_types.pdf
+BASE = ${basename ${DOCUMENT}}
 
 # Directives #
@@ -41,15 +42,16 @@
 
 clean :
-	@rm -frv ${DOCUMENT} ${basename ${DOCUMENT}}.ps ${Build}
+	@rm -frv ${DOCUMENT} ${BASE}.ps ${Build}
 
 # File Dependencies #
 
-${DOCUMENT} : ${basename ${DOCUMENT}}.ps
+${DOCUMENT} : ${BASE}.ps
 	ps2pdf $<
 
-${basename ${DOCUMENT}}.ps : ${basename ${DOCUMENT}}.dvi
+${BASE}.ps : ${BASE}.dvi
 	dvips ${Build}/$< -o $@
 
-${basename ${DOCUMENT}}.dvi : Makefile ${Build} ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ../../bibliography/pl.bib
+${BASE}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
+		../../bibliography/pl.bib | ${Build}
 	# Must have *.aux file containing citations for bibtex
 	if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi
@@ -63,5 +65,5 @@
 ## Define the default recipes.
 
-${Build}:
+${Build} :
 	mkdir -p ${Build}
 
@@ -69,11 +71,11 @@
 	gnuplot -e Build="'${Build}/'" evaluation/timing.gp
 
-%.tex : %.fig
+%.tex : %.fig | ${Build}
 	fig2dev -L eepic $< > ${Build}/$@
 
-%.ps : %.fig
+%.ps : %.fig | ${Build}
 	fig2dev -L ps $< > ${Build}/$@
 
-%.pstex : %.fig
+%.pstex : %.fig | ${Build}
 	fig2dev -L pstex $< > ${Build}/$@
 	fig2dev -L pstex_t -p ${Build}/$@ $< > ${Build}/$@_t
Index: doc/papers/concurrency/Makefile
===================================================================
--- doc/papers/concurrency/Makefile	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/papers/concurrency/Makefile	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -15,16 +15,15 @@
 SOURCES = ${addsuffix .tex, \
 Paper \
-style/style \
-style/cfa-format \
 }
 
 FIGURES = ${addsuffix .tex, \
-monitor \
-ext_monitor \
 int_monitor \
 dependency \
+RunTimeStructure \
 }
 
 PICTURES = ${addsuffix .pstex, \
+monitor \
+ext_monitor \
 system \
 monitor_structs \
@@ -59,12 +58,12 @@
 	dvips ${Build}/$< -o $@
 
-${BASE}.dvi : Makefile ${Build} ${BASE}.out.ps WileyNJD-AMA.bst ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
-		annex/local.bib ../../bibliography/pl.bib
+${BASE}.dvi : Makefile ${BASE}.out.ps WileyNJD-AMA.bst ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
+		annex/local.bib ../../bibliography/pl.bib | ${Build}
 	# Must have *.aux file containing citations for bibtex
 	if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi
-	${BibTeX} ${Build}/${basename $@}
+	-${BibTeX} ${Build}/${basename $@}
 	# Some citations reference others so run again to resolve these citations
 	${LaTeX} ${basename $@}.tex
-	${BibTeX} ${Build}/${basename $@}
+	-${BibTeX} ${Build}/${basename $@}
 	# Run again to finish citations
 	${LaTeX} ${basename $@}.tex
@@ -72,20 +71,20 @@
 ## Define the default recipes.
 
-${Build}:
+${Build} :
 	mkdir -p ${Build}
 
-${BASE}.out.ps: ${Build}
+${BASE}.out.ps : | ${Build}
 	ln -fs ${Build}/Paper.out.ps .
 
-WileyNJD-AMA.bst:
+WileyNJD-AMA.bst :
 	ln -fs ../AMA/AMA-stix/ama/WileyNJD-AMA.bst .
 
-%.tex : %.fig ${Build}
+%.tex : %.fig | ${Build}
 	fig2dev -L eepic $< > ${Build}/$@
 
-%.ps : %.fig ${Build}
+%.ps : %.fig | ${Build}
 	fig2dev -L ps $< > ${Build}/$@
 
-%.pstex : %.fig ${Build}
+%.pstex : %.fig | ${Build}
 	fig2dev -L pstex $< > ${Build}/$@
 	fig2dev -L pstex_t -p ${Build}/$@ $< > ${Build}/$@_t
Index: doc/papers/concurrency/Paper.tex
===================================================================
--- doc/papers/concurrency/Paper.tex	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/papers/concurrency/Paper.tex	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -21,6 +21,6 @@
 \renewcommand{\thesubfigure}{(\Alph{subfigure})}
 \captionsetup{justification=raggedright,singlelinecheck=false}
-\usepackage{siunitx}
-\sisetup{binary-units=true}
+\usepackage{dcolumn}						% align decimal points in tables
+\usepackage{capt-of}
 
 \hypersetup{breaklinks=true}
@@ -235,10 +235,10 @@
 \CFA is a modern, polymorphic, \emph{non-object-oriented} extension of the C programming language.
 This paper discusses the design of the concurrency and parallelism features in \CFA, and the concurrent runtime-system.
-These features are created from scratch as ISO C lacks concurrency, relying largely on the pthreads library.
+These features are created from scratch as ISO C lacks concurrency, relying largely on the pthreads library for concurrency.
 Coroutines and lightweight (user) threads are introduced into the language.
 In addition, monitors are added as a high-level mechanism for mutual exclusion and synchronization.
 A unique contribution is allowing multiple monitors to be safely acquired simultaneously.
 All features respect the expectations of C programmers, while being fully integrate with the \CFA polymorphic type-system and other language features.
-Finally, experimental results are presented to compare the performance of the new features with similar mechanisms in other concurrent programming-languages.
+Finally, experimental results show comparable performance of the new features with similar mechanisms in other concurrent programming-languages.
 }%
 
@@ -257,22 +257,20 @@
 While the simplest concurrency system is a thread and a lock, this low-level approach is hard to master.
 An easier approach for programmers is to support higher-level constructs as the basis of concurrency.
-Indeed, for highly productive concurrent programming, high-level approaches are much more popular~\cite{Hochstein05}.
-Examples of high-level approaches are task (work) based~\cite{TBB}, implicit threading~\cite{OpenMP}, monitors~\cite{Java}, channels~\cite{CSP,Go}, and message passing~\cite{Erlang,MPI}.
+Indeed, for highly-productive concurrent-programming, high-level approaches are much more popular~\cite{Hochstein05}.
+Examples of high-level approaches are jobs (thread pool)~\cite{TBB}, implicit threading~\cite{OpenMP}, monitors~\cite{Java}, channels~\cite{CSP,Go}, and message passing~\cite{Erlang,MPI}.
 
 The following terminology is used.
 A \newterm{thread} is a fundamental unit of execution that runs a sequence of code and requires a stack to maintain state.
-Multiple simultaneous threads give rise to \newterm{concurrency}, which requires locking to ensure safe communication and access to shared data.
-% Correspondingly, concurrency is defined as the concepts and challenges that occur when multiple independent (sharing memory, timing dependencies, \etc) concurrent threads are introduced.
+Multiple simultaneous threads give rise to \newterm{concurrency}, which requires locking to ensure access to shared data and safe communication.
 \newterm{Locking}, and by extension \newterm{locks}, are defined as a mechanism to prevent progress of threads to provide safety.
 \newterm{Parallelism} is running multiple threads simultaneously.
 Parallelism implies \emph{actual} simultaneous execution, where concurrency only requires \emph{apparent} simultaneous execution.
 As such, parallelism only affects performance, which is observed through differences in space and/or time at runtime.
-
 Hence, there are two problems to be solved: concurrency and parallelism.
 While these two concepts are often combined, they are distinct, requiring different tools~\cite[\S~2]{Buhr05a}.
-Concurrency tools handle synchronization and mutual exclusion, while parallelism tools handle performance, cost and resource utilization.
+Concurrency tools handle mutual exclusion and synchronization, while parallelism tools handle performance, cost, and resource utilization.
 
 The proposed concurrency API is implemented in a dialect of C, called \CFA.
-The paper discusses how the language features are added to the \CFA translator with respect to parsing, semantic, and type checking, and the corresponding high-performance runtime-library to implement the concurrency features.
+The paper discusses how the language features are added to the \CFA translator with respect to parsing, semantics, and type checking, and the corresponding high-performance runtime-library to implement the concurrent features.
 
 
@@ -282,10 +280,10 @@
 Extended versions and explanation of the following code examples are available at the \CFA website~\cite{Cforall} or in Moss~\etal~\cite{Moss18}.
 
-\CFA is an extension of ISO-C, and hence, supports all C paradigms.
+\CFA is a non-object-oriented extension of ISO-C, and hence, supports all C paradigms.
 %It is a non-object-oriented system-language, meaning most of the major abstractions have either no runtime overhead or can be opted out easily.
-Like C, the basics of \CFA revolve around structures and routines.
+Like C, the building blocks of \CFA are structures and routines.
 Virtually all of the code generated by the \CFA translator respects C memory layouts and calling conventions.
-While \CFA is not an object-oriented language, lacking the concept of a receiver (\eg @this@) and nominal inheritance-relationships, C does have a notion of objects: ``region of data storage in the execution environment, the contents of which can represent values''~\cite[3.15]{C11}.
-While some \CFA features are common in object-oriented programming-languages, they are an independent capability allowing \CFA to adopt them while retaining a procedural paradigm.
+While \CFA is not object oriented, lacking the concept of a receiver (\eg @this@) and nominal inheritance-relationships, C does have a notion of objects: ``region of data storage in the execution environment, the contents of which can represent values''~\cite[3.15]{C11}.
+While some \CFA features are common in object-oriented programming, they are independent capabilities allowing \CFA to adopt them while maintaining a procedural paradigm.
 
 
@@ -296,5 +294,5 @@
 int x = 1, y = 2, z = 3;
 int * p1 = &x, ** p2 = &p1,  *** p3 = &p2,	$\C{// pointers to x}$
-	`&` r1 = x,  `&&` r2 = r1,  `&&&` r3 = r2;	$\C{// references to x}$
+    `&` r1 = x,   `&&` r2 = r1,   `&&&` r3 = r2;	$\C{// references to x}$
 int * p4 = &z, `&` r4 = z;
 
@@ -411,8 +409,7 @@
 \end{cquote}
 Overloading is important for \CFA concurrency since the runtime system relies on creating different types to represent concurrency objects.
-Therefore, overloading is necessary to prevent the need for long prefixes and other naming conventions to prevent name clashes.
-As seen in Section~\ref{basics}, routine @main@ is heavily overloaded.
-
-Variable overloading is useful in the parallel semantics of the @with@ statement for fields with the same name:
+Therefore, overloading eliminates long prefixes and other naming conventions to prevent name clashes.
+As seen in Section~\ref{s:Concurrency}, routine @main@ is heavily overloaded.
+For example, variable overloading is useful in the parallel semantics of the @with@ statement for fields with the same name:
 \begin{cfa}
 struct S { int `i`; int j; double m; } s;
@@ -428,5 +425,5 @@
 }
 \end{cfa}
-For parallel semantics, both @s.i@ and @t.i@ are visible the same type, so only @i@ is ambiguous without qualification.
+For parallel semantics, both @s.i@ and @t.i@ are visible with the same type, so only @i@ is ambiguous without qualification.
 
 
@@ -439,7 +436,7 @@
 \begin{tabular}{@{}ll@{\hspace{\parindentlnth}}|@{\hspace{\parindentlnth}}l@{}}
 \begin{cfa}
-int ++? (int op);
-int ?++ (int op);
-int `?+?` (int op1, int op2);
+int ++?(int op);
+int ?++(int op);
+int `?+?`(int op1, int op2);
 int ?<=?(int op1, int op2);
 int ?=? (int & op1, int op2);
@@ -470,8 +467,43 @@
 
 
+\subsection{Constructors / Destructors}
+
+Object lifetime is a challenge in non-managed programming languages.
+\CFA responds with \CC-like constructors and destructors:
+\begin{cfa}
+struct VLA { int len, * data; };			$\C{// variable length array of integers}$
+void ?{}( VLA & vla ) with ( vla ) { len = 10;  data = alloc( len ); }  $\C{// default constructor}$
+void ?{}( VLA & vla, int size, char fill ) with ( vla ) { len = size;  data = alloc( len, fill ); } // initialization
+void ?{}( VLA & vla, VLA other ) { vla.len = other.len;  vla.data = other.data; } $\C{// copy, shallow}$
+void ^?{}( VLA & vla ) with ( vla ) { free( data ); } $\C{// destructor}$
+{
+	VLA  x,            y = { 20, 0x01 },     z = y;	$\C{// z points to y}$
+	// $\LstCommentStyle{\color{red}\ \ \ x\{\};\ \ \ \ \ \ \ \ \ y\{ 20, 0x01 \};\ \ \ \ \ \ \ \ \ \ z\{ z, y \};\ \ \ \ \ \ \ implicit calls}$
+	^x{};									$\C{// deallocate x}$
+	x{};									$\C{// reallocate x}$
+	z{ 5, 0xff };							$\C{// reallocate z, not pointing to y}$
+	^y{};									$\C{// deallocate y}$
+	y{ x };									$\C{// reallocate y, points to x}$
+	x{};									$\C{// reallocate x, not pointing to y}$
+}	//  $\LstCommentStyle{\color{red}\^{}z\{\};\ \ \^{}y\{\};\ \ \^{}x\{\};\ \ \ implicit calls}$
+\end{cfa}
+Like \CC, construction is implicit on allocation (stack/heap) and destruction is implicit on deallocation.
+The object and all their fields are constructed/destructed.
+\CFA also provides @new@ and @delete@, which behave like @malloc@ and @free@, in addition to constructing and destructing objects:
+\begin{cfa}
+{
+	... struct S s = {10}; ...				$\C{// allocation, call constructor}$
+}											$\C{// deallocation, call destructor}$
+struct S * s = new();						$\C{// allocation, call constructor}$
+...
+delete( s );								$\C{// deallocation, call destructor}$
+\end{cfa}
+\CFA concurrency uses object lifetime as a means of mutual exclusion and/or synchronization.
+
+
 \subsection{Parametric Polymorphism}
 \label{s:ParametricPolymorphism}
 
-The signature feature of \CFA is parametric-polymorphic routines~\cite{} with routines generalized using a @forall@ clause (giving the language its name), which allow separately compiled routines to support generic usage over multiple types.
+The signature feature of \CFA is parametric-polymorphic routines~\cite{Cforall} with routines generalized using a @forall@ clause (giving the language its name), which allow separately compiled routines to support generic usage over multiple types.
 For example, the following sum routine works for any type that supports construction from 0 and addition:
 \begin{cfa}
@@ -486,4 +518,5 @@
 int i = sum( sa, 5 );						$\C{// use S's 0 construction and +}$
 \end{cfa}
+The builtin type @zero_t@ (and @one_t@) overload constant 0 (and 1) for a new types, where both 0 and 1 have special meaning in C.
 
 \CFA provides \newterm{traits} to name a group of type assertions, where the trait name allows specifying the same set of assertions in multiple locations, preventing repetition mistakes at each routine declaration:
@@ -501,8 +534,8 @@
 
 Assertions can be @otype@ or @dtype@.
-@otype@ refers to a ``complete'' object, \ie an object has a size, default constructor, copy constructor, destructor and an assignment operator.
-@dtype@ only guarantees an object has a size and alignment.
-
-Using the return type for discrimination, it is possible to write a type-safe @alloc@ based on the C @malloc@:
+@otype@ refers to a \emph{complete} object, \ie an object has a size, alignment, default constructor, copy constructor, destructor and an assignment operator.
+@dtype@ refers to an \emph{incomplete} object, \ie, an object only has a size and alignment.
+
+Using the return type for overload discrimination, it is possible to write a type-safe @alloc@ based on the C @malloc@:
 \begin{cfa}
 forall( dtype T | sized(T) ) T * alloc( void ) { return (T *)malloc( sizeof(T) ); }
@@ -514,50 +547,15 @@
 
 
-\subsection{Constructors / Destructors}
-
-Object lifetime is a challenge in non-managed programming languages.
-\CFA responds with \CC-like constructors and destructors:
-\begin{cfa}
-struct VLA { int len, * data; };			$\C{// variable length array of integers}$
-void ?{}( VLA & vla ) with ( vla ) { len = 10;  data = alloc( len ); }  $\C{// default constructor}$
-void ?{}( VLA & vla, int size, char fill ) with ( vla ) { len = size;  data = alloc( len, fill ); } // initialization
-void ?{}( VLA & vla, VLA other ) { vla.len = other.len;  vla.data = other.data; } $\C{// copy, shallow}$
-void ^?{}( VLA & vla ) with ( vla ) { free( data ); } $\C{// destructor}$
-{
-	VLA  x,            y = { 20, 0x01 },     z = y;	$\C{// z points to y}$
-	//    x{};         y{ 20, 0x01 };          z{ z, y }; 
-	^x{};									$\C{// deallocate x}$
-	x{};									$\C{// reallocate x}$
-	z{ 5, 0xff };							$\C{// reallocate z, not pointing to y}$
-	^y{};									$\C{// deallocate y}$
-	y{ x };									$\C{// reallocate y, points to x}$
-	x{};									$\C{// reallocate x, not pointing to y}$
-	//  ^z{};  ^y{};  ^x{};
-}
-\end{cfa}
-Like \CC, construction is implicit on allocation (stack/heap) and destruction is implicit on deallocation.
-The object and all their fields are constructed/destructed.
-\CFA also provides @new@ and @delete@, which behave like @malloc@ and @free@, in addition to constructing and destructing objects:
-\begin{cfa}
-{	struct S s = {10};						$\C{// allocation, call constructor}$
-	...
-}											$\C{// deallocation, call destructor}$
-struct S * s = new();						$\C{// allocation, call constructor}$
-...
-delete( s );								$\C{// deallocation, call destructor}$
-\end{cfa}
-\CFA concurrency uses object lifetime as a means of synchronization and/or mutual exclusion.
-
-
-\section{Concurrency Basics}\label{basics}
+\section{Concurrency}
+\label{s:Concurrency}
 
 At its core, concurrency is based on multiple call-stacks and scheduling threads executing on these stacks.
 Multiple call stacks (or contexts) and a single thread of execution, called \newterm{coroutining}~\cite{Conway63,Marlin80}, does \emph{not} imply concurrency~\cite[\S~2]{Buhr05a}.
-In coroutining, the single thread is self-scheduling across the stacks, so execution is deterministic, \ie given fixed inputs, the execution path to the outputs is fixed and predictable.
+In coroutining, the single thread is self-scheduling across the stacks, so execution is deterministic, \ie the execution path from input to output is fixed and predictable.
 A \newterm{stackless} coroutine executes on the caller's stack~\cite{Python} but this approach is restrictive, \eg preventing modularization and supporting only iterator/generator-style programming;
 a \newterm{stackfull} coroutine executes on its own stack, allowing full generality.
-Only stackfull coroutines are a stepping-stone to concurrency.
-
-The transition to concurrency, even for execution with a single thread and multiple stacks, occurs when coroutines also context switch to a scheduling oracle, introducing non-determinism from the coroutine perspective~\cite[\S~3]{Buhr05a}.
+Only stackfull coroutines are a stepping stone to concurrency.
+
+The transition to concurrency, even for execution with a single thread and multiple stacks, occurs when coroutines also context switch to a \newterm{scheduling oracle}, introducing non-determinism from the coroutine perspective~\cite[\S~3]{Buhr05a}.
 Therefore, a minimal concurrency system is possible using coroutines (see Section \ref{coroutine}) in conjunction with a scheduler to decide where to context switch next.
 The resulting execution system now follows a cooperative threading-model, called \newterm{non-preemptive scheduling}.
@@ -591,5 +589,5 @@
 \subsection{Coroutines: A Stepping Stone}\label{coroutine}
 
-While the focus of this discussion is concurrency and parallelism, it is important to address coroutines, which are a significant building block of a concurrency system.
+While the focus of this discussion is concurrency and parallelism, it is important to address coroutines, which are a significant building block of a concurrency system (but not concurrent among themselves).
 Coroutines are generalized routines allowing execution to be temporarily suspend and later resumed.
 Hence, unlike a normal routine, a coroutine may not terminate when it returns to its caller, allowing it to be restarted with the values and execution location present at the point of suspension.
@@ -598,5 +596,5 @@
 Therefore, the core \CFA coroutine-API for has two fundamental features: independent call-stacks and @suspend@/@resume@ operations.
 
-For example, a problem made easier with coroutines is unbounded generators, \eg generating an infinite sequence of Fibonacci numbers, where Figure~\ref{f:C-fibonacci} shows conventional approaches for writing a Fibonacci generator in C.
+For example, a problem made easier with coroutines is unbounded generators, \eg generating an infinite sequence of Fibonacci numbers
 \begin{displaymath}
 \mathsf{fib}(n) = \left \{
@@ -608,12 +606,7 @@
 \right.
 \end{displaymath}
-Figure~\ref{f:GlobalVariables} illustrates the following problems:
-unique unencapsulated global variables necessary to retain state between calls;
-only one Fibonacci generator;
-execution state must be explicitly retained via explicit state variables.
-Figure~\ref{f:ExternalState} addresses these issues:
-unencapsulated program global variables become encapsulated structure variables;
-unique global variables are replaced by multiple Fibonacci objects;
-explicit execution state is removed by precomputing the first two Fibonacci numbers and returning $\mathsf{fib}(n-2)$.
+where Figure~\ref{f:C-fibonacci} shows conventional approaches for writing a Fibonacci generator in C.
+Figure~\ref{f:GlobalVariables} illustrates the following problems: unique unencapsulated global variables necessary to retain state between calls, only one Fibonacci generator, and execution state must be explicitly retained via explicit state variables.
+Figure~\ref{f:ExternalState} addresses these issues: unencapsulated program global variables become encapsulated structure variables, unique global variables are replaced by multiple Fibonacci objects, and explicit execution state is removed by precomputing the first two Fibonacci numbers and returning $\mathsf{fib}(n-2)$.
 
 \begin{figure}
@@ -723,18 +716,14 @@
 \subfloat[1 State, internal variables]{\label{f:Coroutine1State}\usebox\myboxB}
 \caption{\CFA Coroutine Fibonacci Implementations}
-\label{f:fibonacci-cfa}
+\label{f:cfa-fibonacci}
 \end{figure}
 
 Using a coroutine, it is possible to express the Fibonacci formula directly without any of the C problems.
-Figure~\ref{f:Coroutine3States} creates a @coroutine@ type:
-\begin{cfa}
-`coroutine` Fib { int fn; };
-\end{cfa}
-which provides communication, @fn@, for the \newterm{coroutine main}, @main@, which runs on the coroutine stack, and possibly multiple interface routines @next@.
+Figure~\ref{f:Coroutine3States} creates a @coroutine@ type, @`coroutine` Fib { int fn; }@, which provides communication, @fn@, for the \newterm{coroutine main}, @main@, which runs on the coroutine stack, and possibly multiple interface routines, \eg @next@.
 Like the structure in Figure~\ref{f:ExternalState}, the coroutine type allows multiple instances, where instances of this type are passed to the (overloaded) coroutine main.
-The coroutine main's stack holds the state for the next generation, @f1@ and @f2@, and the code has the three suspend points, representing the three states in the Fibonacci formula, to context switch back to the caller's resume.
+The coroutine main's stack holds the state for the next generation, @f1@ and @f2@, and the code has the three suspend points, representing the three states in the Fibonacci formula, to context switch back to the caller's @resume@.
 The interface routine @next@, takes a Fibonacci instance and context switches to it using @resume@;
 on restart, the Fibonacci field, @fn@, contains the next value in the sequence, which is returned.
-The first @resume@ is special because it cocalls the coroutine at its coroutine main and allocates the stack;
+The first @resume@ is special because it allocates the coroutine stack and cocalls its coroutine main on that stack;
 when the coroutine main returns, its stack is deallocated.
 Hence, @Fib@ is an object at creation, transitions to a coroutine on its first resume, and transitions back to an object when the coroutine main finishes.
@@ -758,6 +747,7 @@
 \end{quote}
 The example takes advantage of resuming a coroutine in the constructor to prime the loops so the first character sent for formatting appears inside the nested loops.
-The destruction provides a newline if formatted text ends with a full line.
+The destruction provides a newline, if formatted text ends with a full line.
 Figure~\ref{f:CFmt} shows the C equivalent formatter, where the loops of the coroutine are flatten (linearized) and rechecked on each call because execution location is not retained between calls.
+(Linearized code is the bane of device drivers.)
 
 \begin{figure}
@@ -843,7 +833,7 @@
 \end{figure}
 
-The previous examples are \newterm{asymmetric (semi) coroutine}s because one coroutine always calls a resuming routine for another coroutine, and the resumed coroutine always suspends back to its last resumer, similar to call/return for normal routines
-However, there is no stack growth because @resume@/@suspend@ context switch to existing stack-frames rather than create new ones.
-\newterm{Symmetric (full) coroutine}s have a coroutine call a resuming routine for another coroutine, which eventually forms a resuming-call cycle.
+The previous examples are \newterm{asymmetric (semi) coroutine}s because one coroutine always calls a resuming routine for another coroutine, and the resumed coroutine always suspends back to its last resumer, similar to call/return for normal routines.
+However, @resume@ and @suspend@ context switch among existing stack-frames, rather than create new ones so there is no stack growth.
+\newterm{Symmetric (full) coroutine}s have a coroutine call to a resuming routine for another coroutine, and its coroutine main has a call to another resuming routine, which eventually forms a resuming-call cycle.
 (The trivial cycle is a coroutine resuming itself.)
 This control flow is similar to recursion for normal routines, but again there is no stack growth from the context switch.
@@ -927,5 +917,5 @@
 Figure~\ref{f:ProdCons} shows a producer/consumer symmetric-coroutine performing bi-directional communication.
 Since the solution involves a full-coroutining cycle, the program main creates one coroutine in isolation, passes this coroutine to its partner, and closes the cycle at the call to @start@.
-The @start@ routine communicates both the number of elements to be produced and the consumer into the producer's coroutine structure.
+The @start@ routine communicates both the number of elements to be produced and the consumer into the producer's coroutine-structure.
 Then the @resume@ to @prod@ creates @prod@'s stack with a frame for @prod@'s coroutine main at the top, and context switches to it.
 @prod@'s coroutine main starts, creates local variables that are retained between coroutine activations, and executes $N$ iterations, each generating two random values, calling the consumer to deliver the values, and printing the status returned from the consumer.
@@ -933,6 +923,6 @@
 The producer call to @delivery@ transfers values into the consumer's communication variables, resumes the consumer, and returns the consumer status.
 For the first resume, @cons@'s stack is initialized, creating local variables retained between subsequent activations of the coroutine.
-The consumer iterates until the @done@ flag is set, prints, increments status, and calls back to the producer via @payment@, and on return from @payment@, prints the receipt from the producer and increments @money@ (inflation).
-The call from the consumer to the @payment@ introduces the cycle between producer and consumer.
+The consumer iterates until the @done@ flag is set, prints the values delivered by the producer, increments status, and calls back to the producer via @payment@, and on return from @payment@, prints the receipt from the producer and increments @money@ (inflation).
+The call from the consumer to @payment@ introduces the cycle between producer and consumer.
 When @payment@ is called, the consumer copies values into the producer's communication variable and a resume is executed.
 The context switch restarts the producer at the point where it was last context switched, so it continues in @delivery@ after the resume.
@@ -959,10 +949,10 @@
 
 Object-oriented inheritance provides extra fields and code in a restricted context, but it requires programmers to explicitly perform the inheritance:
-\begin{cfa}
-struct mycoroutine $\textbf{\textsf{inherits}}$ baseCoroutine { ... }
+\begin{cfa}[morekeywords={class,inherits}]
+class mycoroutine inherits baseCoroutine { ... }
 \end{cfa}
 and the programming language (and possibly its tool set, \eg debugger) may need to understand @baseCoroutine@ because of the stack.
-Furthermore, the execution of constructs/destructors is in the wrong order for certain operations, \eg for threads;
-\eg, if the thread is implicitly started, it must start \emph{after} all constructors, because the thread relies on a completely initialized object, but the inherited constructor runs \emph{before} the derived.
+Furthermore, the execution of constructs/destructors is in the wrong order for certain operations.
+For example, for threads if the thread is implicitly started, it must start \emph{after} all constructors, because the thread relies on a completely initialized object, but the inherited constructor runs \emph{before} the derived.
 
 An alternatively is composition:
@@ -984,5 +974,5 @@
 symmetric_coroutine<>::yield_type
 \end{cfa}
-Similarly, the canonical threading paradigm is often based on routine pointers, \eg @pthread@~\cite{pthreads}, \Csharp~\cite{Csharp}, Go~\cite{Go}, and Scala~\cite{Scala}.
+Similarly, the canonical threading paradigm is often based on routine pointers, \eg @pthreads@~\cite{Butenhof97}, \Csharp~\cite{Csharp}, Go~\cite{Go}, and Scala~\cite{Scala}.
 However, the generic thread-handle (identifier) is limited (few operations), unless it is wrapped in a custom type.
 \begin{cfa}
@@ -1001,5 +991,5 @@
 Note, the type @coroutine_t@ must be an abstract handle to the coroutine, because the coroutine descriptor and its stack are non-copyable.
 Copying the coroutine descriptor results in copies being out of date with the current state of the stack.
-Correspondingly, copying the stack results is copies being out of date with coroutine descriptor, and pointers in the stack being out of date to data on the stack.
+Correspondingly, copying the stack results is copies being out of date with the coroutine descriptor, and pointers in the stack being out of date to data on the stack.
 (There is no mechanism in C to find all stack-specific pointers and update them as part of a copy.)
 
@@ -1015,5 +1005,5 @@
 Furthermore, implementing coroutines without language supports also displays the power of a programming language.
 While this is ultimately the option used for idiomatic \CFA code, coroutines and threads can still be constructed without using the language support.
-The reserved keyword eases use for the common cases.
+The reserved keyword simply eases use for the common cases.
 
 Part of the mechanism to generalize coroutines is using a \CFA trait, which defines a coroutine as anything satisfying the trait @is_coroutine@, and this trait is used to restrict coroutine-manipulation routines:
@@ -1030,5 +1020,5 @@
 The @main@ routine has no return value or additional parameters because the coroutine type allows an arbitrary number of interface routines with corresponding arbitrary typed input/output values versus fixed ones.
 The generic routines @suspend@ and @resume@ can be redefined, but any object passed to them is a coroutine since it must satisfy the @is_coroutine@ trait to compile.
-The advantage of this approach is that users can easily create different types of coroutines, for example, changing the memory layout of a coroutine is trivial when implementing the @get_coroutine@ routine, and possibly redefining @suspend@ and @resume@.
+The advantage of this approach is that users can easily create different types of coroutines, \eg changing the memory layout of a coroutine is trivial when implementing the @get_coroutine@ routine, and possibly redefining @suspend@ and @resume@.
 The \CFA keyword @coroutine@ implicitly implements the getter and forward declarations required for implementing the coroutine main:
 \begin{cquote}
@@ -1094,9 +1084,9 @@
 \end{tabular}
 \end{cquote}
-(The qualifier @mutex@ for the destructor parameter is discussed in Section~\ref{s:Monitors}.)
+(The qualifier @mutex@ for the destructor parameter is discussed in Section~\ref{s:Monitor}.)
 Like a coroutine, the statically-typed @main@ routine is the starting point (first stack frame) of a user thread.
 The difference is that a coroutine borrows a thread from its caller, so the first thread resuming a coroutine creates an instance of @main@;
 whereas, a user thread receives its own thread from the runtime system, which starts in @main@ as some point after the thread constructor is run.\footnote{
-The \lstinline@main@ routine is already a special routine in C (where the program begins), so it is a natural extension of the semantics to use overloading to declare mains for different coroutines/threads (the normal main being the main of the initial thread).}
+The \lstinline@main@ routine is already a special routine in C, \ie where the program's initial thread begins, so it is a natural extension of this semantics to use overloading to declare \lstinline@main@s for user coroutines and threads.}
 No return value or additional parameters are necessary for this routine because the task type allows an arbitrary number of interface routines with corresponding arbitrary typed input/output values.
 
@@ -1175,5 +1165,5 @@
 The program uses heap-based threads because each thread needs different constructor values.
 (Python provides a simple iteration mechanism to initialize array elements to different values allowing stack allocation.)
-The allocation/deallocation pattern appears unusual because allocated objects are immediately deleted without any intervening code.
+The allocation/deallocation pattern appears unusual because allocated objects are immediately deallocated without any intervening code.
 However, for threads, the deletion provides implicit synchronization, which is the intervening code.
 While the subtotals are added in linear order rather than completion order, which slight inhibits concurrency, the computation is restricted by the critical-path thread (\ie the thread that takes the longest), and so any inhibited concurrency is very small as totalling the subtotals is trivial.
@@ -1189,7 +1179,5 @@
 void main( Adder & adder ) with( adder ) {
     subtotal = 0;
-    for ( int c = 0; c < cols; c += 1 ) {
-		subtotal += row[c];
-    }
+    for ( int c = 0; c < cols; c += 1 ) { subtotal += row[c]; }
 }
 int main() {
@@ -1216,13 +1204,13 @@
 
 Uncontrolled non-deterministic execution is meaningless.
-To reestablish meaningful execution requires mechanisms to reintroduce determinism (\ie restrict non-determinism), called mutual exclusion and synchronization, where mutual exclusion is an access-control mechanism on data shared by threads, and synchronization is a timing relationship among threads~\cite[\S~4]{Buhr05a}.
+To reestablish meaningful execution requires mechanisms to reintroduce determinism, \ie restrict non-determinism, called mutual exclusion and synchronization, where mutual exclusion is an access-control mechanism on data shared by threads, and synchronization is a timing relationship among threads~\cite[\S~4]{Buhr05a}.
 Since many deterministic challenges appear with the use of mutable shared state, some languages/libraries disallow it, \eg Erlang~\cite{Erlang}, Haskell~\cite{Haskell}, Akka~\cite{Akka} (Scala).
-In these paradigms, interaction among concurrent objects is performed by stateless message-passing~\cite{Thoth,Harmony,V-Kernel} or other paradigms closely relate to networking concepts (\eg channels~\cite{CSP,Go}).
-However, in call/return-based languages, these approaches force a clear distinction (\ie introduce a new programming paradigm) between regular and concurrent computation (\ie routine call versus message passing).
+In these paradigms, interaction among concurrent objects is performed by stateless message-passing~\cite{Thoth,Harmony,V-Kernel} or other paradigms closely relate to networking concepts, \eg channels~\cite{CSP,Go}.
+However, in call/return-based languages, these approaches force a clear distinction, \ie introduce a new programming paradigm between regular and concurrent computation, \eg routine call versus message passing.
 Hence, a programmer must learn and manipulate two sets of design patterns.
 While this distinction can be hidden away in library code, effective use of the library still has to take both paradigms into account.
 In contrast, approaches based on statefull models more closely resemble the standard call/return programming-model, resulting in a single programming paradigm.
 
-At the lowest level, concurrent control is implemented by atomic operations, upon which different kinds of locks mechanism are constructed, \eg semaphores~\cite{Dijkstra68b}, barriers, and path expressions~\cite{Campbell74}.
+At the lowest level, concurrent control is implemented by atomic operations, upon which different kinds of locking mechanisms are constructed, \eg semaphores~\cite{Dijkstra68b}, barriers, and path expressions~\cite{Campbell74}.
 However, for productivity it is always desirable to use the highest-level construct that provides the necessary efficiency~\cite{Hochstein05}.
 A newer approach for restricting non-determinism is transactional memory~\cite{Herlihy93}.
@@ -1244,6 +1232,6 @@
 However, many solutions exist for mutual exclusion, which vary in terms of performance, flexibility and ease of use.
 Methods range from low-level locks, which are fast and flexible but require significant attention for correctness, to higher-level concurrency techniques, which sacrifice some performance to improve ease of use.
-Ease of use comes by either guaranteeing some problems cannot occur (\eg deadlock free), or by offering a more explicit coupling between shared data and critical section.
-For example, the \CC @std::atomic<T>@ offers an easy way to express mutual-exclusion on a restricted set of operations (\eg reading/writing) for numerical types.
+Ease of use comes by either guaranteeing some problems cannot occur, \eg deadlock free, or by offering a more explicit coupling between shared data and critical section.
+For example, the \CC @std::atomic<T>@ offers an easy way to express mutual-exclusion on a restricted set of operations, \eg reading/writing, for numerical types.
 However, a significant challenge with locks is composability because it takes careful organization for multiple locks to be used while preventing deadlock.
 Easing composability is another feature higher-level mutual-exclusion mechanisms can offer.
@@ -1254,5 +1242,5 @@
 Synchronization enforces relative ordering of execution, and synchronization tools provide numerous mechanisms to establish these timing relationships.
 Low-level synchronization primitives offer good performance and flexibility at the cost of ease of use;
-higher-level mechanisms often simplify usage by adding better coupling between synchronization and data (\eg message passing), or offering a simpler solution to otherwise involved challenges, \eg barrier lock.
+higher-level mechanisms often simplify usage by adding better coupling between synchronization and data, \eg message passing, or offering a simpler solution to otherwise involved challenges, \eg barrier lock.
 Often synchronization is used to order access to a critical section, \eg ensuring a reader thread is the next kind of thread to enter a critical section.
 If a writer thread is scheduled for next access, but another reader thread acquires the critical section first, that reader has \newterm{barged}.
@@ -1265,6 +1253,6 @@
 
 
-\section{Monitors}
-\label{s:Monitors}
+\section{Monitor}
+\label{s:Monitor}
 
 A \textbf{monitor} is a set of routines that ensure mutual exclusion when accessing shared state.
@@ -1272,5 +1260,5 @@
 The strong association with the call/return paradigm eases programmability, readability and maintainability, at a slight cost in flexibility and efficiency.
 
-Note, like coroutines/threads, both locks and monitors require an abstract handle to reference them, because at their core, both mechanisms are manipulating non-copyable shared state.
+Note, like coroutines/threads, both locks and monitors require an abstract handle to reference them, because at their core, both mechanisms are manipulating non-copyable shared-state.
 Copying a lock is insecure because it is possible to copy an open lock and then use the open copy when the original lock is closed to simultaneously access the shared data.
 Copying a monitor is secure because both the lock and shared data are copies, but copying the shared data is meaningless because it no longer represents a unique entity.
@@ -1326,8 +1314,8 @@
 \end{cfa}
 
-Mandatory monitor qualifiers have the benefit of being self-documented, but requiring both @mutex@ and \lstinline[morekeywords=nomutex]@nomutex@ for all monitor parameter is redundant.
+Mandatory monitor qualifiers have the benefit of being self-documenting, but requiring both @mutex@ and \lstinline[morekeywords=nomutex]@nomutex@ for all monitor parameter is redundant.
 Instead, one of qualifier semantics can be the default, and the other required.
-For example, assume the safe @mutex@ option for a monitor parameter because assuming \lstinline[morekeywords=nomutex]@nomutex@ may cause subtle errors.
-On the other hand, assuming \lstinline[morekeywords=nomutex]@nomutex@ is the \emph{normal} parameter behaviour, stating explicitly ``this parameter is not special''.
+For example, assume the safe @mutex@ qualifier for all monitor parameters because assuming \lstinline[morekeywords=nomutex]@nomutex@ may cause subtle errors.
+On the other hand, assuming \lstinline[morekeywords=nomutex]@nomutex@ is the \emph{normal} parameter behaviour, stating explicitly \emph{this parameter is not special}.
 Providing a default qualifier implies knowing whether a parameter is a monitor.
 Since \CFA relies heavily on traits as an abstraction mechanism, the distinction between a type that is a monitor and a type that looks like a monitor can become blurred.
@@ -1375,9 +1363,9 @@
 \end{cfa}
 (While object-oriented monitors can be extended with a mutex qualifier for multiple-monitor members, no prior example of this feature could be found.)
-In practice, writing multi-locking routines that do not deadlocks is tricky.
+In practice, writing multi-locking routines that do not deadlock is tricky.
 Having language support for such a feature is therefore a significant asset for \CFA.
 
 The capability to acquire multiple locks before entering a critical section is called \newterm{bulk acquire}.
-In previous example, \CFA guarantees the order of acquisition is consistent across calls to different routines using the same monitors as arguments.
+In the previous example, \CFA guarantees the order of acquisition is consistent across calls to different routines using the same monitors as arguments.
 This consistent ordering means acquiring multiple monitors is safe from deadlock.
 However, users can force the acquiring order.
@@ -1395,5 +1383,5 @@
 In the calls to @bar@ and @baz@, the monitors are acquired in opposite order.
 
-However, such use leads to lock acquiring order problems resulting in deadlock~\cite{Lister77}, where detecting it requires dynamically tracking of monitor calls, and dealing with it requires implement rollback semantics~\cite{Dice10}.
+However, such use leads to lock acquiring order problems resulting in deadlock~\cite{Lister77}, where detecting it requires dynamic tracking of monitor calls, and dealing with it requires rollback semantics~\cite{Dice10}.
 In \CFA, safety is guaranteed by using bulk acquire of all monitors to shared objects, whereas other monitor systems provide no aid.
 While \CFA provides only a partial solution, the \CFA partial solution handles many useful cases.
@@ -1406,5 +1394,5 @@
 }
 \end{cfa}
-This example shows a trivial solution to the bank-account transfer problem~\cite{BankTransfer}.
+This example shows a trivial solution to the bank-account transfer problem.
 Without multi- and bulk acquire, the solution to this problem requires careful engineering.
 
@@ -1415,6 +1403,5 @@
 Like Java, \CFA offers an alternative @mutex@ statement to reduce refactoring and naming.
 \begin{cquote}
-\begin{tabular}{@{}c|@{\hspace{\parindentlnth}}c@{}}
-routine call & @mutex@ statement \\
+\begin{tabular}{@{}l@{\hspace{3\parindentlnth}}l@{}}
 \begin{cfa}
 monitor M {};
@@ -1436,10 +1423,12 @@
 
 \end{cfa}
+\\
+\multicolumn{1}{c}{\textbf{routine call}} & \multicolumn{1}{c}{\lstinline@mutex@ \textbf{statement}}
 \end{tabular}
 \end{cquote}
 
 
-\section{Internal Scheduling}
-\label{s:InternalScheduling}
+\section{Scheduling}
+\label{s:Scheduling}
 
 While monitor mutual-exclusion provides safe access to shared data, the monitor data may indicate that a thread accessing it cannot proceed.
@@ -1450,8 +1439,9 @@
 \newterm{Internal scheduling} is characterized by each thread entering the monitor and making an individual decision about proceeding or blocking, while \newterm{external scheduling} is characterized by an entering thread making a decision about proceeding for itself and on behalf of other threads attempting entry.
 
-Figure~\ref{f:BBInt} shows a \CFA bounded-buffer with internal scheduling, where producers/consumers enter the monitor, see the buffer is full/empty, and block on an appropriate condition lock, @full@/@empty@.
+Figure~\ref{f:BBInt} shows a \CFA generic bounded-buffer with internal scheduling, where producers/consumers enter the monitor, see the buffer is full/empty, and block on an appropriate condition lock, @full@/@empty@.
 The @wait@ routine atomically blocks the calling thread and implicitly releases the monitor lock(s) for all monitors in the routine's parameter list.
 The appropriate condition lock is signalled to unblock an opposite kind of thread after an element is inserted/removed from the buffer.
 Signalling is unconditional, because signalling an empty condition lock does nothing.
+
 Signalling semantics cannot have the signaller and signalled thread in the monitor simultaneously, which means:
 \begin{enumerate}
@@ -1463,8 +1453,8 @@
 The signalling thread blocks but is marked for urgrent unblocking at the next scheduling point and the signalled thread continues.
 \end{enumerate}
-The first approach is too restrictive, as it precludes solving a reasonable class of problems (\eg dating service).
+The first approach is too restrictive, as it precludes solving a reasonable class of problems, \eg dating service (see Figure~\ref{f:DatingService}).
 \CFA supports the next two semantics as both are useful.
 Finally, while it is common to store a @condition@ as a field of the monitor, in \CFA, a @condition@ variable can be created/stored independently.
-Furthermore, a condition variable is tied to a \emph{group} of monitors on first use (called \newterm{branding}), which means that using internal scheduling with distinct sets of monitors requires one condition variable per set of monitors.
+Furthermore, a condition variable is tied to a \emph{group} of monitors on first use, called \newterm{branding}, which means that using internal scheduling with distinct sets of monitors requires one condition variable per set of monitors.
 
 \begin{figure}
@@ -1535,29 +1525,30 @@
 \end{figure}
 
-Figure~\ref{f:BBExt} shows a \CFA bounded-buffer with external scheduling, where producers/consumers detecting a full/empty buffer block and prevent more producers/consumers from entering the monitor until the buffer has a free/empty slot.
+Figure~\ref{f:BBExt} shows a \CFA generic bounded-buffer with external scheduling, where producers/consumers detecting a full/empty buffer block and prevent more producers/consumers from entering the monitor until the buffer has a free/empty slot.
 External scheduling is controlled by the @waitfor@ statement, which atomically blocks the calling thread, releases the monitor lock, and restricts the routine calls that can next acquire mutual exclusion.
 If the buffer is full, only calls to @remove@ can acquire the buffer, and if the buffer is empty, only calls to @insert@ can acquire the buffer.
-Threads making calls to routines that are currently excluded block outside (external) of the monitor on a calling queue, versus blocking on condition queues inside (internal) of the monitor.
+Threads making calls to routines that are currently excluded, block outside (external) of the monitor on a calling queue, versus blocking on condition queues inside (internal) of the monitor.
+% External scheduling is more constrained and explicit, which helps programmers reduce the non-deterministic nature of concurrency.
+External scheduling allows users to wait for events from other threads without concern of unrelated events occurring.
+The mechnaism can be done in terms of control flow, \eg Ada @accept@ or \uC @_Accept@, or in terms of data, \eg Go channels.
+While both mechanisms have strengths and weaknesses, this project uses a control-flow mechanism to stay consistent with other language semantics.
+Two challenges specific to \CFA for external scheduling are loose object-definitions (see Section~\ref{s:LooseObjectDefinitions}) and multiple-monitor routines (see Section~\ref{s:Multi-MonitorScheduling}).
 
 For internal scheduling, non-blocking signalling (as in the producer/consumer example) is used when the signaller is providing the cooperation for a waiting thread;
 the signaller enters the monitor and changes state, detects a waiting threads that can use the state, performs a non-blocking signal on the condition queue for the waiting thread, and exits the monitor to run concurrently.
-The waiter unblocks next, takes the state, and exits the monitor.
+The waiter unblocks next from the urgent queue, uses/takes the state, and exits the monitor.
 Blocking signalling is the reverse, where the waiter is providing the cooperation for the signalling thread;
 the signaller enters the monitor, detects a waiting thread providing the necessary state, performs a blocking signal to place it on the urgent queue and unblock the waiter.
-The waiter changes state and exits the monitor, and the signaller unblocks next from the urgent queue to take the state.
-
-Figure~\ref{f:DatingService} shows a dating service demonstrating the two forms of signalling: non-blocking and blocking.
+The waiter changes state and exits the monitor, and the signaller unblocks next from the urgent queue to use/take the state.
+
+Figure~\ref{f:DatingService} shows a dating service demonstrating non-blocking and blocking signalling.
 The dating service matches girl and boy threads with matching compatibility codes so they can exchange phone numbers.
 A thread blocks until an appropriate partner arrives.
-The complexity is exchanging phone number in the monitor, 
-While the non-barging monitor prevents a caller from stealing a phone number, the monitor mutual-exclusion property 
-
-The dating service is an example of a monitor that cannot be written using external scheduling because:
-
-The example in table \ref{tbl:datingservice} highlights the difference in behaviour.
-As mentioned, @signal@ only transfers ownership once the current critical section exits; this behaviour requires additional synchronization when a two-way handshake is needed.
-To avoid this explicit synchronization, the @condition@ type offers the @signal_block@ routine, which handles the two-way handshake as shown in the example.
-This feature removes the need for a second condition variables and simplifies programming.
-Like every other monitor semantic, @signal_block@ uses barging prevention, which means mutual-exclusion is baton-passed both on the front end and the back end of the call to @signal_block@, meaning no other thread can acquire the monitor either before or after the call.
+The complexity is exchanging phone numbers in the monitor because of the mutual-exclusion property.
+For signal scheduling, the @exchange@ condition is necessary to block the thread finding the match, while the matcher unblocks to take the oppose number, post its phone number, and unblock the partner. 
+For signal-block scheduling, the implicit urgent-queue replaces the explict @exchange@-condition and @signal_block@ puts the finding thread on the urgent condition and unblocks the matcher.
+
+The dating service is an example of a monitor that cannot be written using external scheduling because it requires knowledge of calling parameters to make scheduling decisions, and parameters of waiting threads are unavailable;
+as well, an arriving thread may not find a partner and must wait, which requires a condition variable, and condition variables imply internal scheduling.
 
 \begin{figure}
@@ -1576,9 +1567,9 @@
 		wait( Girls[ccode] );
 		GirlPhNo = phNo;
-		exchange.signal();
+		`exchange.signal();`
 	} else {
 		GirlPhNo = phNo;
-		signal( Boys[ccode] );
-		exchange.wait();
+		`signal( Boys[ccode] );`
+		`exchange.wait();`
 	} // if
 	return BoyPhNo;
@@ -1606,5 +1597,5 @@
 	} else {
 		GirlPhNo = phNo; // make phone number available
-		signal_block( Boys[ccode] ); // restart boy
+		`signal_block( Boys[ccode] );` // restart boy
 
 	} // if
@@ -1655,11 +1646,19 @@
 }
 \end{cfa}
-must have acquired monitor locks that are greater than or equal to the number of locks for the waiting thread signalled from the front of the condition queue.
-In general, the signaller does not know the order of waiting threads, so in general, it must acquire the maximum number of mutex locks for the worst-case waiting thread.
+must have acquired monitor locks that are greater than or equal to the number of locks for the waiting thread signalled from the condition queue.
 
 Similarly, for @waitfor( rtn )@, the default semantics is to atomically block the acceptor and release all acquired mutex types in the parameter list, \ie @waitfor( rtn, m1, m2 )@.
 To override the implicit multi-monitor wait, specific mutex parameter(s) can be specified, \eg @waitfor( rtn, m1 )@.
-Waitfor statically verifies the released monitors are the same as the acquired mutex-parameters of the given routine or routine pointer.
+@waitfor@ statically verifies the released monitors are the same as the acquired mutex-parameters of the given routine or routine pointer.
 To statically verify the released monitors match with the accepted routine's mutex parameters, the routine (pointer) prototype must be accessible.
+
+When an overloaded routine appears in an @waitfor@ statement, calls to any routine with that name are accepted.
+The rationale is that members with the same name should perform a similar function, and therefore, all should be eligible to accept a call.
+As always, overloaded routines can be disambiguated using a cast:
+\begin{cfa}
+void rtn( M & mutex m );
+`int` rtn( M & mutex m );
+waitfor( (`int` (*)( M & mutex ))rtn, m1, m2 );
+\end{cfa}
 
 Given the ability to release a subset of acquired monitors can result in a \newterm{nested monitor}~\cite{Lister77} deadlock.
@@ -1667,8 +1666,8 @@
 void foo( M & mutex m1, M & mutex m2 ) {
 	... wait( `e, m1` ); ...				$\C{// release m1, keeping m2 acquired )}$
-void baz( M & mutex m1, M & mutex m2 ) {	$\C{// must acquire m1 and m2 )}$
+void bar( M & mutex m1, M & mutex m2 ) {	$\C{// must acquire m1 and m2 )}$
 	... signal( `e` ); ...
 \end{cfa}
-The @wait@ only releases @m1@ so the signalling thread cannot acquire both @m1@ and @m2@ to  enter @baz@ to get to the @signal@.
+The @wait@ only releases @m1@ so the signalling thread cannot acquire both @m1@ and @m2@ to  enter @bar@ to get to the @signal@.
 While deadlock issues can occur with multiple/nesting acquisition, this issue results from the fact that locks, and by extension monitors, are not perfectly composable.
 
@@ -1682,4 +1681,5 @@
 For example, there are no loops in either bounded buffer solution in Figure~\ref{f:GenericBoundedBuffer}.
 Supporting barging prevention as well as extending internal scheduling to multiple monitors is the main source of complexity in the design and implementation of \CFA concurrency.
+Furthermore, \CFA concurrency has no superious wakeup~\cite[\S~9]{Buhr05a}, which eliminates an implict form of barging.
 
 
@@ -1755,766 +1755,351 @@
 However, Figure~\ref{f:OtherWaitingThread} shows this solution is complex depending on other waiters, resulting is choices when the signaller finishes the inner mutex-statement.
 The singaller can retain @m2@ until completion of the outer mutex statement and pass the locks to waiter W1, or it can pass @m2@ to waiter W2 after completing the inner mutex-statement, while continuing to hold @m1@.
-In the latter case, waiter W2 must eventually pass @m2@ to waiter W1, which is complex because W2 may have waited before W1 so it is unaware of W1.
+In the latter case, waiter W2 must eventually pass @m2@ to waiter W1, which is complex because W1 may have waited before W2, so W2 is unaware of it.
 Furthermore, there is an execution sequence where the signaller always finds waiter W2, and hence, waiter W1 starves.
 
 While a number of approaches were examined~\cite[\S~4.3]{Delisle18}, the solution chosen for \CFA is a novel techique called \newterm{partial signalling}.
-Signalled threads are moved to an urgent queue and the waiter at the front defines the set of monitors necessary for it to unblock.
+Signalled threads are moved to the urgent queue and the waiter at the front defines the set of monitors necessary for it to unblock.
 Partial signalling transfers ownership of monitors to the front waiter.
 When the signaller thread exits or waits in the monitor the front waiter is unblocked if all its monitors are released.
 This solution has the benefit that complexity is encapsulated into only two actions: passing monitors to the next owner when they should be released and conditionally waking threads if all conditions are met.
 
-\begin{comment}
-Figure~\ref{f:dependency} shows a slightly different example where a third thread is waiting on monitor @A@, using a different condition variable.
-Because the third thread is signalled when secretly holding @B@, the goal  becomes unreachable.
-Depending on the order of signals (listing \ref{f:dependency} line \ref{line:signal-ab} and \ref{line:signal-a}) two cases can happen:
-
-\paragraph{Case 1: thread $\alpha$ goes first.} In this case, the problem is that monitor @A@ needs to be passed to thread $\beta$ when thread $\alpha$ is done with it.
-\paragraph{Case 2: thread $\beta$ goes first.} In this case, the problem is that monitor @B@ needs to be retained and passed to thread $\alpha$ along with monitor @A@, which can be done directly or possibly using thread $\beta$ as an intermediate.
-\\
-
-Note that ordering is not determined by a race condition but by whether signalled threads are enqueued in FIFO or FILO order.
-However, regardless of the answer, users can move line \ref{line:signal-a} before line \ref{line:signal-ab} and get the reverse effect for listing \ref{f:dependency}.
-
-In both cases, the threads need to be able to distinguish, on a per monitor basis, which ones need to be released and which ones need to be transferred, which means knowing when to release a group becomes complex and inefficient (see next section) and therefore effectively precludes this approach.
-
-
-\subsubsection{Dependency graphs}
-
-\begin{figure}
-\begin{multicols}{3}
-Thread $\alpha$
-\begin{cfa}[numbers=left, firstnumber=1]
-acquire A
-	acquire A & B
-		wait A & B
-	release A & B
-release A
-\end{cfa}
-\columnbreak
-Thread $\gamma$
-\begin{cfa}[numbers=left, firstnumber=6, escapechar=|]
-acquire A
-	acquire A & B
-		|\label{line:signal-ab}|signal A & B
-	|\label{line:release-ab}|release A & B
-	|\label{line:signal-a}|signal A
-|\label{line:release-a}|release A
-\end{cfa}
-\columnbreak
-Thread $\beta$
-\begin{cfa}[numbers=left, firstnumber=12, escapechar=|]
-acquire A
-	wait A
-|\label{line:release-aa}|release A
-\end{cfa}
-\end{multicols}
-\begin{cfa}[caption={Pseudo-code for the three thread example.},label={f:dependency}]
-\end{cfa}
-\begin{center}
-\input{dependency}
-\end{center}
-\caption{Dependency graph of the statements in listing \ref{f:dependency}}
-\label{fig:dependency}
-\end{figure}
-
-In listing \ref{f:int-bulk-cfa}, there is a solution that satisfies both barging prevention and mutual exclusion.
-If ownership of both monitors is transferred to the waiter when the signaller releases @A & B@ and then the waiter transfers back ownership of @A@ back to the signaller when it releases it, then the problem is solved (@B@ is no longer in use at this point).
-Dynamically finding the correct order is therefore the second possible solution.
-The problem is effectively resolving a dependency graph of ownership requirements.
-Here even the simplest of code snippets requires two transfers and has a super-linear complexity.
-This complexity can be seen in listing \ref{f:explosion}, which is just a direct extension to three monitors, requires at least three ownership transfer and has multiple solutions.
-Furthermore, the presence of multiple solutions for ownership transfer can cause deadlock problems if a specific solution is not consistently picked; In the same way that multiple lock acquiring order can cause deadlocks.
-\begin{figure}
-\begin{multicols}{2}
-\begin{cfa}
-acquire A
-	acquire B
-		acquire C
-			wait A & B & C
-		release C
-	release B
-release A
-\end{cfa}
-
-\columnbreak
-
-\begin{cfa}
-acquire A
-	acquire B
-		acquire C
-			signal A & B & C
-		release C
-	release B
-release A
-\end{cfa}
-\end{multicols}
-\begin{cfa}[caption={Extension to three monitors of listing \ref{f:int-bulk-cfa}},label={f:explosion}]
-\end{cfa}
-\end{figure}
-
-Given the three threads example in listing \ref{f:dependency}, figure \ref{fig:dependency} shows the corresponding dependency graph that results, where every node is a statement of one of the three threads, and the arrows the dependency of that statement (\eg $\alpha1$ must happen before $\alpha2$).
-The extra challenge is that this dependency graph is effectively post-mortem, but the runtime system needs to be able to build and solve these graphs as the dependencies unfold.
-Resolving dependency graphs being a complex and expensive endeavour, this solution is not the preferred one.
-
-\subsubsection{Partial Signalling} \label{partial-sig}
-\end{comment}
-
-
-\section{External scheduling} \label{extsched}
-
-An alternative to internal scheduling is external scheduling (see Table~\ref{tbl:sched}).
-
-\begin{comment}
-\begin{table}
-\begin{tabular}{|c|c|c|}
-Internal Scheduling & External Scheduling & Go\\
-\hline
-\begin{uC++}[tabsize=3]
-_Monitor Semaphore {
-	condition c;
-	bool inUse;
-public:
-	void P() {
-		if(inUse)
-			wait(c);
-		inUse = true;
-	}
-	void V() {
-		inUse = false;
-		signal(c);
-	}
-}
-\end{uC++}&\begin{uC++}[tabsize=3]
-_Monitor Semaphore {
-
-	bool inUse;
-public:
-	void P() {
-		if(inUse)
-			_Accept(V);
-		inUse = true;
-	}
-	void V() {
-		inUse = false;
-
-	}
-}
-\end{uC++}&\begin{Go}[tabsize=3]
-type MySem struct {
-	inUse bool
-	c     chan bool
-}
-
-// acquire
-func (s MySem) P() {
-	if s.inUse {
-		select {
-		case <-s.c:
-		}
-	}
-	s.inUse = true
-}
-
-// release
-func (s MySem) V() {
-	s.inUse = false
-
-	// This actually deadlocks
-	// when single thread
-	s.c <- false
-}
-\end{Go}
-\end{tabular}
-\caption{Different forms of scheduling.}
-\label{tbl:sched}
-\end{table}
-\end{comment}
-
-This method is more constrained and explicit, which helps users reduce the non-deterministic nature of concurrency.
-Indeed, as the following examples demonstrate, external scheduling allows users to wait for events from other threads without the concern of unrelated events occurring.
-External scheduling can generally be done either in terms of control flow (\eg Ada with @accept@, \uC with @_Accept@) or in terms of data (\eg Go with channels).
-Of course, both of these paradigms have their own strengths and weaknesses, but for this project, control-flow semantics was chosen to stay consistent with the rest of the languages semantics.
-Two challenges specific to \CFA arise when trying to add external scheduling with loose object definitions and multiple-monitor routines.
-The previous example shows a simple use @_Accept@ versus @wait@/@signal@ and its advantages.
-Note that while other languages often use @accept@/@select@ as the core external scheduling keyword, \CFA uses @waitfor@ to prevent name collisions with existing socket \textbf{api}s.
-
-For the @P@ member above using internal scheduling, the call to @wait@ only guarantees that @V@ is the last routine to access the monitor, allowing a third routine, say @isInUse()@, acquire mutual exclusion several times while routine @P@ is waiting.
-On the other hand, external scheduling guarantees that while routine @P@ is waiting, no other routine than @V@ can acquire the monitor.
-
-% ======================================================================
-% ======================================================================
+
 \subsection{Loose Object Definitions}
-% ======================================================================
-% ======================================================================
-In \uC, a monitor class declaration includes an exhaustive list of monitor operations.
-Since \CFA is not object oriented, monitors become both more difficult to implement and less clear for a user:
-
-\begin{cfa}
-monitor A {};
-
-void f(A & mutex a);
-void g(A & mutex a) {
-	waitfor(f); // Obvious which f() to wait for
-}
-
-void f(A & mutex a, int); // New different F added in scope
-void h(A & mutex a) {
-	waitfor(f); // Less obvious which f() to wait for
-}
-\end{cfa}
-
-Furthermore, external scheduling is an example where implementation constraints become visible from the interface.
-Here is the cfa-code for the entering phase of a monitor:
-\begin{center}
-\begin{tabular}{l}
-\begin{cfa}
-	if monitor is free
-		enter
-	elif already own the monitor
-		continue
-	elif monitor accepts me
-		enter
-	else
-		block
-\end{cfa}
-\end{tabular}
-\end{center}
+\label{s:LooseObjectDefinitions}
+
+In an object-oriented programming-language, a class includes an exhaustive list of operations.
+However, new members can be added via static inheritance or dynaic members, \eg JavaScript~\cite{JavaScript}.
+Similarly, monitor routines can be added at any time in \CFA, making it less clear for programmers and more difficult to implement.
+\begin{cfa}
+monitor M {};
+void `f`( M & mutex m );
+void g( M & mutex m ) { waitfor( `f` ); }	$\C{// clear which f}$
+void `f`( M & mutex m, int );				$\C{// different f}$
+void h( M & mutex m ) { waitfor( `f` ); }	$\C{// unclear which f}$
+\end{cfa}
+Hence, the cfa-code for the entering a monitor looks like:
+\begin{cfa}
+if ( $\textrm{\textit{monitor is free}}$ ) $\LstCommentStyle{// \color{red}enter}$
+else if ( $\textrm{\textit{already own monitor}}$ ) $\LstCommentStyle{// \color{red}continue}$
+else if ( $\textrm{\textit{monitor accepts me}}$ ) $\LstCommentStyle{// \color{red}enter}$
+else $\LstCommentStyle{// \color{red}block}$
+\end{cfa}
 For the first two conditions, it is easy to implement a check that can evaluate the condition in a few instructions.
-However, a fast check for @monitor accepts me@ is much harder to implement depending on the constraints put on the monitors.
-Indeed, monitors are often expressed as an entry queue and some acceptor queue as in Figure~\ref{fig:ClassicalMonitor}.
+However, a fast check for \emph{monitor accepts me} is much harder to implement depending on the constraints put on the monitors.
+Figure~\ref{fig:ClassicalMonitor} shows monitors are often expressed as an entry (calling) queue, some acceptor queues, and an urgent stack/queue.
 
 \begin{figure}
 \centering
-\subfloat[Classical Monitor] {
+\subfloat[Classical monitor] {
 \label{fig:ClassicalMonitor}
-{\resizebox{0.45\textwidth}{!}{\input{monitor}}}
+{\resizebox{0.45\textwidth}{!}{\input{monitor.pstex_t}}}
 }% subfloat
-\qquad
-\subfloat[bulk acquire Monitor] {
+\quad
+\subfloat[Bulk acquire monitor] {
 \label{fig:BulkMonitor}
-{\resizebox{0.45\textwidth}{!}{\input{ext_monitor}}}
+{\resizebox{0.45\textwidth}{!}{\input{ext_monitor.pstex_t}}}
 }% subfloat
-\caption{External Scheduling Monitor}
+\caption{Monitor Implementation}
+\label{f:MonitorImplementation}
 \end{figure}
 
-There are other alternatives to these pictures, but in the case of the left picture, implementing a fast accept check is relatively easy.
-Restricted to a fixed number of mutex members, N, the accept check reduces to updating a bitmask when the acceptor queue changes, a check that executes in a single instruction even with a fairly large number (\eg 128) of mutex members.
-This approach requires a unique dense ordering of routines with an upper-bound and that ordering must be consistent across translation units.
-For OO languages these constraints are common, since objects only offer adding member routines consistently across translation units via inheritance.
-However, in \CFA users can extend objects with mutex routines that are only visible in certain translation unit.
-This means that establishing a program-wide dense-ordering among mutex routines can only be done in the program linking phase, and still could have issues when using dynamically shared objects.
-
-The alternative is to alter the implementation as in Figure~\ref{fig:BulkMonitor}.
-Here, the mutex routine called is associated with a thread on the entry queue while a list of acceptable routines is kept separate.
-Generating a mask dynamically means that the storage for the mask information can vary between calls to @waitfor@, allowing for more flexibility and extensions.
-Storing an array of accepted routine pointers replaces the single instruction bitmask comparison with dereferencing a pointer followed by a linear search.
-Furthermore, supporting nested external scheduling (\eg listing \ref{f:nest-ext}) may now require additional searches for the @waitfor@ statement to check if a routine is already queued.
+For a fixed (small) number of mutex routines (\eg 128), the accept check reduces to a bitmask of allowed callers, which can be checked with a single instruction.
+This approach requires a unique dense ordering of routines with a small upper-bound and the ordering must be consistent across translation units.
+For object-oriented languages these constraints are common, but \CFA mutex routines can be added in any scope and are only visible in certain translation unit, precluding program-wide dense-ordering among mutex routines.
+
+Figure~\ref{fig:BulkMonitor} shows the \CFA monitor implementation.
+The mutex routine called is associated with each thread on the entry queue, while a list of acceptable routines is kept separately.
+The accepted list is a variable-sized array of accepted routine pointers, so the single instruction bitmask comparison is replaced by dereferencing a pointer followed by a (usually short) linear search.
+
+
+\subsection{Multi-Monitor Scheduling}
+\label{s:Multi-MonitorScheduling}
+
+External scheduling, like internal scheduling, becomes significantly more complex for multi-monitor semantics.
+Even in the simplest case, new semantics needs to be established.
+\begin{cfa}
+monitor M {};
+void f( M & mutex m1 );
+void g( M & mutex m1, M & mutex m2 ) {
+	waitfor( f ); 							$\C{\color{red}// pass m1 or m2 to f?}$
+}
+\end{cfa}
+The solution is for the programmer to disambiguate:
+\begin{cfa}
+	waitfor( f, m2 );						$\C{\color{red}// wait for call to f with argument m2}$
+\end{cfa}
+Routine @g@ has acquired both locks, so when routine @f@ is called, the lock for monitor @m2@ is passed from @g@ to @f@, while @g@ still holds lock @m1@.
+This behaviour can be extended to the multi-monitor @waitfor@ statement.
+\begin{cfa}
+monitor M {};
+void f( M & mutex m1, M & mutex m2 );
+void g( M & mutex m1, M & mutex m2 ) {
+	waitfor( f, m1, m2 );					$\C{\color{red}// wait for call to f with arguments m1 and m2}$
+}
+\end{cfa}
+Again, the set of monitors passed to the @waitfor@ statement must be entirely contained in the set of monitors already acquired by the accepting routine.
+
+Note, for internal and external scheduling with multiple monitors, a signalling or accepting thread must match exactly, \ie partial matching results in waiting.
+\begin{cquote}
+\lstDeleteShortInline@%
+\begin{tabular}{@{}l@{\hspace{\parindentlnth}}|@{\hspace{\parindentlnth}}l@{}}
+\begin{cfa}
+monitor M1 {} m11, m12;
+monitor M2 {} m2;
+condition c;
+void f( M1 & mutex m1, M2 & mutex m2 ) {
+	signal( c );
+}
+void g( M1 & mutex m1, M2 & mutex m2 ) {
+	wait( c );
+}
+g( `m11`, m2 ); // block on accept
+f( `m12`, m2 ); // cannot fulfil
+\end{cfa}
+&
+\begin{cfa}
+monitor M1 {} m11, m12;
+monitor M2 {} m2;
+
+void f( M1 & mutex m1, M2 & mutex m2 ) {
+
+}
+void g( M1 & mutex m1, M2 & mutex m2 ) {
+	waitfor( f, m1, m2 );
+}
+g( `m11`, m2 ); // block on accept
+f( `m12`, m2 ); // cannot fulfil
+\end{cfa}
+\end{tabular}
+\lstMakeShortInline@%
+\end{cquote}
+For both internal and external scheduling, the set of monitors is disjoint so unblocking is impossible.
+
+
+\subsection{Extended \protect\lstinline@waitfor@}
+
+The extended form of the @waitfor@ statement conditionally accepts one of a group of mutex routines and allows a specific action to be performed \emph{after} the mutex routine finishes.
+\begin{cfa}
+`when` ( $\emph{conditional-expression}$ )	$\C{// optional guard}$
+	waitfor( $\emph{mutex-member-name}$ )
+		$\emph{statement}$					$\C{// action after call}$
+`or` `when` ( $\emph{conditional-expression}$ ) $\C{// optional guard}$
+	waitfor( $\emph{mutex-member-name}$ )
+		$\emph{statement}$					$\C{// action after call}$
+`or`	...									$\C{// list of waitfor clauses}$
+`when` ( $\emph{conditional-expression}$ )	$\C{// optional guard}$
+	`timeout`								$\C{// optional terminating timeout clause}$
+		$\emph{statement}$					$\C{// action after timeout}$
+`when` ( $\emph{conditional-expression}$ )	$\C{// optional guard}$
+	`else`									$\C{// optional terminating clause}$
+		$\emph{statement}$					$\C{// action when no immediate calls}$
+\end{cfa}
+For a @waitfor@ clause to be executed, its @when@ must be true and an outstanding call to its corresponding member(s) must exist.
+The \emph{conditional-expression} of a @when@ may call a routine, but the routine must not block or context switch.
+If there are several mutex calls that can be accepted, selection occurs top-to-bottom in the @waitfor@ clauses versus non-deterministically.
+If some accept guards are true and there are no outstanding calls to these members, the acceptor is accept-blocked until a call to one of these members is made.
+If all the accept guards are false, the statement does nothing, unless there is a terminating @else@ clause with a true guard, which is executed instead.
+Hence, the terminating @else@ clause allows a conditional attempt to accept a call without blocking.
+If there is a @timeout@ clause, it provides an upper bound on waiting, and can only appear with a conditional @else@, otherwise the timeout cannot be triggered.
+In all cases, the statement following is executed \emph{after} a clause is executed to know which of the clauses executed.
+
+Note, a group of conditional @waitfor@ clauses is \emph{not} the same as a group of @if@ statements, e.g.:
+\begin{cfa}
+if ( C1 ) waitfor( mem1 );			 when ( C1 ) waitfor( mem1 );
+else if ( C2 ) waitfor( mem2 );		or when ( C2 ) waitfor( mem2 );
+\end{cfa}
+The left example accepts only @mem1@ if @C1@ is true or only @mem2@ if @C2@ is true.
+The right example accepts either @mem1@ or @mem2@ if @C1@ and @C2@ are true.
+
+An interesting use of @waitfor@ is accepting the @mutex@ destructor to know when an object is deallocated.
+\begin{cfa}
+void insert( Buffer(T) & mutex buffer, T elem ) with( buffer ) {
+	if ( count == BufferSize )
+		waitfor( remove, buffer ) {
+			elements[back] = elem;
+			back = ( back + 1 ) % BufferSize;
+			count += 1;
+		} or `waitfor( ^?{}, buffer )` throw insertFail;
+}
+\end{cfa}
+When the buffer is deallocated, the current waiter is unblocked and informed, so it can perform an appropriate action.
+However, the basic @waitfor@ semantics do not support this functionality, since using an object after its destructor is called is undefined.
+Therefore, to make this useful capability work, the semantics for accepting the destructor is the same as @signal@, \ie the call to the destructor is placed on the urgent queue and the acceptor continues execution, which throws an exception to the acceptor and then the caller is unbloced from the urgent queue to deallocate the object.
+Accepting the destructor is an idiomatic way to terminate a thread in \CFA.
+
+
+\subsection{\protect\lstinline@mutex@ Threads}
+
+Threads in \CFA are monitors to allow direct communication among threads, \ie threads can have mutex routines that are called by other threads.
+Hence, all monitor features are available when using threads.
+Figure~\ref{f:pingpong} shows an example of two threads directly calling each other and accepting calls from each other in a cycle.
+Note, both ping/pong threads are globally declared, @pi@/@po@, and hence, start (and possibly complete) before the program main starts.
 
 \begin{figure}
-\begin{cfa}[caption={Example of nested external scheduling},label={f:nest-ext}]
-monitor M {};
-void foo( M & mutex a ) {}
-void bar( M & mutex b ) {
-	// Nested in the waitfor(bar, c) call
-	waitfor(foo, b);
-}
-void baz( M & mutex c ) {
-	waitfor(bar, c);
-}
-
-\end{cfa}
+\lstDeleteShortInline@%
+\begin{cquote}
+\begin{cfa}
+thread Ping {} pi;
+thread Pong {} po;
+void ping( Ping & mutex ) {}
+void pong( Pong & mutex ) {}
+int main() {}
+\end{cfa}
+\begin{tabular}{@{}l@{\hspace{3\parindentlnth}}l@{}}
+\begin{cfa}
+void main( Ping & pi ) {
+	for ( int i = 0; i < 10; i += 1 ) {
+		`waitfor( ping, pi );`
+		`pong( po );`
+	}
+}
+\end{cfa}
+&
+\begin{cfa}
+void main( Pong & po ) {
+	for ( int i = 0; i < 10; i += 1 ) {
+		`ping( pi );`
+		`waitfor( pong, po );`
+	}
+}
+\end{cfa}
+\end{tabular}
+\lstMakeShortInline@%
+\end{cquote}
+\caption{Threads ping/pong using external scheduling}
+\label{f:pingpong}
 \end{figure}
 
-Note that in the right picture, tasks need to always keep track of the monitors associated with mutex routines, and the routine mask needs to have both a routine pointer and a set of monitors, as is discussed in the next section.
-These details are omitted from the picture for the sake of simplicity.
-
-At this point, a decision must be made between flexibility and performance.
-Many design decisions in \CFA achieve both flexibility and performance, for example polymorphic routines add significant flexibility but inlining them means the optimizer can easily remove any runtime cost.
-Here, however, the cost of flexibility cannot be trivially removed.
-In the end, the most flexible approach has been chosen since it allows users to write programs that would otherwise be  hard to write.
-This decision is based on the assumption that writing fast but inflexible locks is closer to a solved problem than writing locks that are as flexible as external scheduling in \CFA.
-
-% ======================================================================
-% ======================================================================
-\subsection{Multi-Monitor Scheduling}
-% ======================================================================
-% ======================================================================
-
-External scheduling, like internal scheduling, becomes significantly more complex when introducing multi-monitor syntax.
-Even in the simplest possible case, some new semantics needs to be established:
-\begin{cfa}
-monitor M {};
-
-void f(M & mutex a);
-
-void g(M & mutex b, M & mutex c) {
-	waitfor(f); // two monitors M => unknown which to pass to f(M & mutex)
-}
-\end{cfa}
-The obvious solution is to specify the correct monitor as follows:
-
-\begin{cfa}
-monitor M {};
-
-void f(M & mutex a);
-
-void g(M & mutex a, M & mutex b) {
-	// wait for call to f with argument b
-	waitfor(f, b);
-}
-\end{cfa}
-This syntax is unambiguous.
-Both locks are acquired and kept by @g@.
-When routine @f@ is called, the lock for monitor @b@ is temporarily transferred from @g@ to @f@ (while @g@ still holds lock @a@).
-This behaviour can be extended to the multi-monitor @waitfor@ statement as follows.
-
-\begin{cfa}
-monitor M {};
-
-void f(M & mutex a, M & mutex b);
-
-void g(M & mutex a, M & mutex b) {
-	// wait for call to f with arguments a and b
-	waitfor(f, a, b);
-}
-\end{cfa}
-
-Note that the set of monitors passed to the @waitfor@ statement must be entirely contained in the set of monitors already acquired in the routine. @waitfor@ used in any other context is undefined behaviour.
-
-An important behaviour to note is when a set of monitors only match partially:
-
-\begin{cfa}
-mutex struct A {};
-
-mutex struct B {};
-
-void g(A & mutex a, B & mutex b) {
-	waitfor(f, a, b);
-}
-
-A a1, a2;
-B b;
-
-void foo() {
-	g(a1, b); // block on accept
-}
-
-void bar() {
-	f(a2, b); // fulfill cooperation
-}
-\end{cfa}
-While the equivalent can happen when using internal scheduling, the fact that conditions are specific to a set of monitors means that users have to use two different condition variables.
-In both cases, partially matching monitor sets does not wakeup the waiting thread.
-It is also important to note that in the case of external scheduling the order of parameters is irrelevant; @waitfor(f,a,b)@ and @waitfor(f,b,a)@ are indistinguishable waiting condition.
-
-% ======================================================================
-% ======================================================================
-\subsection{\protect\lstinline|waitfor| Semantics}
-% ======================================================================
-% ======================================================================
-
-Syntactically, the @waitfor@ statement takes a routine identifier and a set of monitors.
-While the set of monitors can be any list of expressions, the routine name is more restricted because the compiler validates at compile time the validity of the routine type and the parameters used with the @waitfor@ statement.
-It checks that the set of monitors passed in matches the requirements for a routine call.
-Figure~\ref{f:waitfor} shows various usages of the waitfor statement and which are acceptable.
-The choice of the routine type is made ignoring any non-@mutex@ parameter.
-One limitation of the current implementation is that it does not handle overloading, but overloading is possible.
+\section{Parallelism}
+
+Historically, computer performance was about processor speeds.
+However, with heat dissipation being a direct consequence of speed increase, parallelism has become the new source for increased performance~\cite{Sutter05, Sutter05b}.
+Now, high-performance applications must care about parallelism, which requires concurrency.
+The lowest-level approach of parallelism is to use \newterm{kernel threads} in combination with semantics like @fork@, @join@, \etc.
+However, kernel threads are better as an implementation tool because of complexity and higher cost.
+Therefore, different abstractions are often layered onto kernel threads to simplify them, \eg pthreads.
+
+
+\subsection{User Threads with Preemption}
+
+A direct improvement on kernel threads is user threads, \eg Erlang~\cite{Erlang} and \uC~\cite{uC++book}.
+This approach provides an interface that matches the language paradigms, more control over concurrency by the language runtime, and an abstract (and portable) interface to the underlying kernel threads across operating systems.
+In many cases, user threads can be used on a much larger scale (100,000 threads).
+Like kernel threads, user threads support preemption, which maximizes nondeterminism, but introduces the same concurrency errors: race, livelock, starvation, and deadlock.
+\CFA adopts user-threads as they represent the truest realization of concurrency and can build any other concurrency approach, \eg thread pools and actors~\cite{Actors}.
+
+
+\subsection{User Threads without Preemption (Fiber)}
+\label{s:fibers}
+
+A variant of user thread is \newterm{fibers}, which removes preemption, \eg Go~\cite{Go}.
+Like functional programming, which removes mutation and its associated problems, removing preemption from concurrency reduces nondeterminism, hence race and deadlock errors are more difficult to generate.
+However, preemption is necessary for concurrency that relies on spinning, so there are a class of problems that cannot be programmed without preemption.
+
+
+\subsection{Thread Pools}
+
+In contrast to direct threading is indirect \newterm{thread pools}, where small jobs (work units) are insert into a work pool for execution.
+If the jobs are dependent, \ie interact, there is an implicit/explicit dependency graph that ties them together.
+While removing direct concurrency, and hence the amount of context switching, thread pools significantly limit the interaction that can occur among jobs.
+Indeed, jobs should not block because that also block the underlying thread, which effectively means the CPU utilization, and therefore throughput, suffers.
+While it is possible to tune the thread pool with sufficient threads, it becomes difficult to obtain high throughput and good core utilization as job interaction increases.
+As well, concurrency errors return, which threads pools are suppose to mitigate.
+Intel's TBB library~\cite{TBB} is the gold standard for thread pools.
+
+
+\section{\protect\CFA Runtime Structure}
+
+Figure~\ref{f:RunTimeStructure} illustrates the runtime structure of a \CFA program.
+In addition to the new kinds of objects introduced by \CFA, there are two more runtime entities used to control parallel execution: cluster and (virtual) processor.
+An executing thread is illustrated by its containment in a processor.
+
 \begin{figure}
-\begin{cfa}[caption={Various correct and incorrect uses of the waitfor statement},label={f:waitfor}]
-monitor A{};
-monitor B{};
-
-void f1( A & mutex );
-void f2( A & mutex, B & mutex );
-void f3( A & mutex, int );
-void f4( A & mutex, int );
-void f4( A & mutex, double );
-
-void foo( A & mutex a1, A & mutex a2, B & mutex b1, B & b2 ) {
-	A * ap = & a1;
-	void (*fp)( A & mutex ) = f1;
-
-	waitfor(f1, a1);     // Correct : 1 monitor case
-	waitfor(f2, a1, b1); // Correct : 2 monitor case
-	waitfor(f3, a1);     // Correct : non-mutex arguments are ignored
-	waitfor(f1, *ap);    // Correct : expression as argument
-
-	waitfor(f1, a1, b1); // Incorrect : Too many mutex arguments
-	waitfor(f2, a1);     // Incorrect : Too few mutex arguments
-	waitfor(f2, a1, a2); // Incorrect : Mutex arguments don't match
-	waitfor(f1, 1);      // Incorrect : 1 not a mutex argument
-	waitfor(f9, a1);     // Incorrect : f9 routine does not exist
-	waitfor(*fp, a1 );   // Incorrect : fp not an identifier
-	waitfor(f4, a1);     // Incorrect : f4 ambiguous
-
-	waitfor(f2, a1, b2); // Undefined behaviour : b2 not mutex
-}
-\end{cfa}
+\centering
+\input{RunTimeStructure}
+\caption{\CFA Runtime Structure}
+\label{f:RunTimeStructure}
 \end{figure}
 
-Finally, for added flexibility, \CFA supports constructing a complex @waitfor@ statement using the @or@, @timeout@ and @else@.
-Indeed, multiple @waitfor@ clauses can be chained together using @or@; this chain forms a single statement that uses baton pass to any routine that fits one of the routine+monitor set passed in.
-To enable users to tell which accepted routine executed, @waitfor@s are followed by a statement (including the null statement @;@) or a compound statement, which is executed after the clause is triggered.
-A @waitfor@ chain can also be followed by a @timeout@, to signify an upper bound on the wait, or an @else@, to signify that the call should be non-blocking, which checks for a matching routine call already arrived and otherwise continues.
-Any and all of these clauses can be preceded by a @when@ condition to dynamically toggle the accept clauses on or off based on some current state.
-Figure~\ref{f:waitfor2} demonstrates several complex masks and some incorrect ones.
-
-\begin{figure}
-\lstset{language=CFA,deletedelim=**[is][]{`}{`}}
-\begin{cfa}
-monitor A{};
-
-void f1( A & mutex );
-void f2( A & mutex );
-
-void foo( A & mutex a, bool b, int t ) {
-	waitfor(f1, a);							$\C{// Correct : blocking case}$
-
-	waitfor(f1, a) {						$\C{// Correct : block with statement}$
-		sout | "f1" | endl;
-	}
-	waitfor(f1, a) {						$\C{// Correct : block waiting for f1 or f2}$
-		sout | "f1" | endl;
-	} or waitfor(f2, a) {
-		sout | "f2" | endl;
-	}
-	waitfor(f1, a); or else;				$\C{// Correct : non-blocking case}$
-
-	waitfor(f1, a) {						$\C{// Correct : non-blocking case}$
-		sout | "blocked" | endl;
-	} or else {
-		sout | "didn't block" | endl;
-	}
-	waitfor(f1, a) {						$\C{// Correct : block at most 10 seconds}$
-		sout | "blocked" | endl;
-	} or timeout( 10`s) {
-		sout | "didn't block" | endl;
-	}
-	// Correct : block only if b == true if b == false, don't even make the call
-	when(b) waitfor(f1, a);
-
-	// Correct : block only if b == true if b == false, make non-blocking call
-	waitfor(f1, a); or when(!b) else;
-
-	// Correct : block only of t > 1
-	waitfor(f1, a); or when(t > 1) timeout(t); or else;
-
-	// Incorrect : timeout clause is dead code
-	waitfor(f1, a); or timeout(t); or else;
-
-	// Incorrect : order must be waitfor [or waitfor... [or timeout] [or else]]
-	timeout(t); or waitfor(f1, a); or else;
-}
-\end{cfa}
-\caption{Correct and incorrect uses of the or, else, and timeout clause around a waitfor statement}
-\label{f:waitfor2}
-\end{figure}
-
-% ======================================================================
-% ======================================================================
-\subsection{Waiting For The Destructor}
-% ======================================================================
-% ======================================================================
-An interesting use for the @waitfor@ statement is destructor semantics.
-Indeed, the @waitfor@ statement can accept any @mutex@ routine, which includes the destructor (see section \ref{data}).
-However, with the semantics discussed until now, waiting for the destructor does not make any sense, since using an object after its destructor is called is undefined behaviour.
-The simplest approach is to disallow @waitfor@ on a destructor.
-However, a more expressive approach is to flip ordering of execution when waiting for the destructor, meaning that waiting for the destructor allows the destructor to run after the current @mutex@ routine, similarly to how a condition is signalled.
-\begin{figure}
-\begin{cfa}[caption={Example of an executor which executes action in series until the destructor is called.},label={f:dtor-order}]
-monitor Executer {};
-struct  Action;
-
-void ^?{}   (Executer & mutex this);
-void execute(Executer & mutex this, const Action & );
-void run    (Executer & mutex this) {
-	while(true) {
-		   waitfor(execute, this);
-		or waitfor(^?{}   , this) {
-			break;
-		}
-	}
-}
-\end{cfa}
-\end{figure}
-For example, listing \ref{f:dtor-order} shows an example of an executor with an infinite loop, which waits for the destructor to break out of this loop.
-Switching the semantic meaning introduces an idiomatic way to terminate a task and/or wait for its termination via destruction.
-
-
-% ######     #    ######     #    #       #       ####### #       ###  #####  #     #
-% #     #   # #   #     #   # #   #       #       #       #        #  #     # ##   ##
-% #     #  #   #  #     #  #   #  #       #       #       #        #  #       # # # #
-% ######  #     # ######  #     # #       #       #####   #        #   #####  #  #  #
-% #       ####### #   #   ####### #       #       #       #        #        # #     #
-% #       #     # #    #  #     # #       #       #       #        #  #     # #     #
-% #       #     # #     # #     # ####### ####### ####### ####### ###  #####  #     #
-\section{Parallelism}
-Historically, computer performance was about processor speeds and instruction counts.
-However, with heat dissipation being a direct consequence of speed increase, parallelism has become the new source for increased performance~\cite{Sutter05, Sutter05b}.
-In this decade, it is no longer reasonable to create a high-performance application without caring about parallelism.
-Indeed, parallelism is an important aspect of performance and more specifically throughput and hardware utilization.
-The lowest-level approach of parallelism is to use \textbf{kthread} in combination with semantics like @fork@, @join@, \etc.
-However, since these have significant costs and limitations, \textbf{kthread} are now mostly used as an implementation tool rather than a user oriented one.
-There are several alternatives to solve these issues that all have strengths and weaknesses.
-While there are many variations of the presented paradigms, most of these variations do not actually change the guarantees or the semantics, they simply move costs in order to achieve better performance for certain workloads.
-
-\section{Paradigms}
-\subsection{User-Level Threads}
-A direct improvement on the \textbf{kthread} approach is to use \textbf{uthread}.
-These threads offer most of the same features that the operating system already provides but can be used on a much larger scale.
-This approach is the most powerful solution as it allows all the features of multithreading, while removing several of the more expensive costs of kernel threads.
-The downside is that almost none of the low-level threading problems are hidden; users still have to think about data races, deadlocks and synchronization issues.
-These issues can be somewhat alleviated by a concurrency toolkit with strong guarantees, but the parallelism toolkit offers very little to reduce complexity in itself.
-
-Examples of languages that support \textbf{uthread} are Erlang~\cite{Erlang} and \uC~\cite{uC++book}.
-
-\subsection{Fibers : User-Level Threads Without Preemption} \label{fibers}
-A popular variant of \textbf{uthread} is what is often referred to as \textbf{fiber}.
-However, \textbf{fiber} do not present meaningful semantic differences with \textbf{uthread}.
-The significant difference between \textbf{uthread} and \textbf{fiber} is the lack of \textbf{preemption} in the latter.
-Advocates of \textbf{fiber} list their high performance and ease of implementation as major strengths, but the performance difference between \textbf{uthread} and \textbf{fiber} is controversial, and the ease of implementation, while true, is a weak argument in the context of language design.
-Therefore this proposal largely ignores fibers.
-
-An example of a language that uses fibers is Go~\cite{Go}
-
-\subsection{Jobs and Thread Pools}
-An approach on the opposite end of the spectrum is to base parallelism on \textbf{pool}.
-Indeed, \textbf{pool} offer limited flexibility but at the benefit of a simpler user interface.
-In \textbf{pool} based systems, users express parallelism as units of work, called jobs, and a dependency graph (either explicit or implicit) that ties them together.
-This approach means users need not worry about concurrency but significantly limit the interaction that can occur among jobs.
-Indeed, any \textbf{job} that blocks also block the underlying worker, which effectively means the CPU utilization, and therefore throughput, suffers noticeably.
-It can be argued that a solution to this problem is to use more workers than available cores.
-However, unless the number of jobs and the number of workers are comparable, having a significant number of blocked jobs always results in idles cores.
-
-The gold standard of this implementation is Intel's TBB library~\cite{TBB}.
-
-\subsection{Paradigm Performance}
-While the choice between the three paradigms listed above may have significant performance implications, it is difficult to pin down the performance implications of choosing a model at the language level.
-Indeed, in many situations one of these paradigms may show better performance but it all strongly depends on the workload.
-Having a large amount of mostly independent units of work to execute almost guarantees equivalent performance across paradigms and that the \textbf{pool}-based system has the best efficiency thanks to the lower memory overhead (\ie no thread stack per job).
-However, interactions among jobs can easily exacerbate contention.
-User-level threads allow fine-grain context switching, which results in better resource utilization, but a context switch is more expensive and the extra control means users need to tweak more variables to get the desired performance.
-Finally, if the units of uninterrupted work are large, enough the paradigm choice is largely amortized by the actual work done.
-
-\section{The \protect\CFA\ Kernel : Processors, Clusters and Threads}\label{kernel}
-A \textbf{cfacluster} is a group of \textbf{kthread} executed in isolation. \textbf{uthread} are scheduled on the \textbf{kthread} of a given \textbf{cfacluster}, allowing organization between \textbf{uthread} and \textbf{kthread}.
-It is important that \textbf{kthread} belonging to a same \textbf{cfacluster} have homogeneous settings, otherwise migrating a \textbf{uthread} from one \textbf{kthread} to the other can cause issues.
-A \textbf{cfacluster} also offers a pluggable scheduler that can optimize the workload generated by the \textbf{uthread}.
-
-\textbf{cfacluster} have not been fully implemented in the context of this paper.
-Currently \CFA only supports one \textbf{cfacluster}, the initial one.
-
-\subsection{Future Work: Machine Setup}\label{machine}
-While this was not done in the context of this paper, another important aspect of clusters is affinity.
-While many common desktop and laptop PCs have homogeneous CPUs, other devices often have more heterogeneous setups.
-For example, a system using \textbf{numa} configurations may benefit from users being able to tie clusters and/or kernel threads to certain CPU cores.
-OS support for CPU affinity is now common~\cite{affinityLinux, affinityWindows, affinityFreebsd, affinityNetbsd, affinityMacosx}, which means it is both possible and desirable for \CFA to offer an abstraction mechanism for portable CPU affinity.
-
-\subsection{Paradigms}\label{cfaparadigms}
-Given these building blocks, it is possible to reproduce all three of the popular paradigms.
-Indeed, \textbf{uthread} is the default paradigm in \CFA.
-However, disabling \textbf{preemption} on a cluster means threads effectively become fibers.
-Since several \textbf{cfacluster} with different scheduling policy can coexist in the same application, this allows \textbf{fiber} and \textbf{uthread} to coexist in the runtime of an application.
-Finally, it is possible to build executors for thread pools from \textbf{uthread} or \textbf{fiber}, which includes specialized jobs like actors~\cite{Actors}.
-
-
-
-\section{Behind the Scenes}
-There are several challenges specific to \CFA when implementing concurrency.
-These challenges are a direct result of bulk acquire and loose object definitions.
-These two constraints are the root cause of most design decisions in the implementation.
-Furthermore, to avoid contention from dynamically allocating memory in a concurrent environment, the internal-scheduling design is (almost) entirely free of mallocs.
-This approach avoids the chicken and egg problem~\cite{Chicken} of having a memory allocator that relies on the threading system and a threading system that relies on the runtime.
-This extra goal means that memory management is a constant concern in the design of the system.
-
-The main memory concern for concurrency is queues.
-All blocking operations are made by parking threads onto queues and all queues are designed with intrusive nodes, where each node has pre-allocated link fields for chaining, to avoid the need for memory allocation.
-Since several concurrency operations can use an unbound amount of memory (depending on bulk acquire), statically defining information in the intrusive fields of threads is insufficient.The only way to use a variable amount of memory without requiring memory allocation is to pre-allocate large buffers of memory eagerly and store the information in these buffers.
-Conveniently, the call stack fits that description and is easy to use, which is why it is used heavily in the implementation of internal scheduling, particularly variable-length arrays.
-Since stack allocation is based on scopes, the first step of the implementation is to identify the scopes that are available to store the information, and which of these can have a variable-length array.
-The threads and the condition both have a fixed amount of memory, while @mutex@ routines and blocking calls allow for an unbound amount, within the stack size.
-
-Note that since the major contributions of this paper are extending monitor semantics to bulk acquire and loose object definitions, any challenges that are not resulting of these characteristics of \CFA are considered as solved problems and therefore not discussed.
-
-% ======================================================================
-% ======================================================================
-\section{Mutex Routines}
-% ======================================================================
-% ======================================================================
-
-The first step towards the monitor implementation is simple @mutex@ routines.
-In the single monitor case, mutual-exclusion is done using the entry/exit procedure in listing \ref{f:entry1}.
-The entry/exit procedures do not have to be extended to support multiple monitors.
-Indeed it is sufficient to enter/leave monitors one-by-one as long as the order is correct to prevent deadlock~\cite{Havender68}.
-In \CFA, ordering of monitor acquisition relies on memory ordering.
-This approach is sufficient because all objects are guaranteed to have distinct non-overlapping memory layouts and mutual-exclusion for a monitor is only defined for its lifetime, meaning that destroying a monitor while it is acquired is undefined behaviour.
-When a mutex call is made, the concerned monitors are aggregated into a variable-length pointer array and sorted based on pointer values.
+
+\subsection{Cluster}
+\label{s:RuntimeStructureCluster}
+
+A \newterm{cluster} is a collection of threads and virtual processors (abstract kernel-thread) that execute the threads (like a virtual machine).
+The purpose of a cluster is to control the amount of parallelism that is possible among threads, plus scheduling and other execution defaults.
+The default cluster-scheduler is single-queue multi-server, which provides automatic load-balancing of threads on processors.
+However, the scheduler is pluggable, supporting alternative schedulers.
+If several clusters exist, both threads and virtual processors, can be explicitly migrated from one cluster to another.
+No automatic load balancing among clusters is performed by \CFA.
+
+When a \CFA program begins execution, it creates a user cluster with a single processor and a special processor to handle preemption that does not execute user threads.
+The user cluster is created to contain the application user-threads.
+Having all threads execute on the one cluster often maximizes utilization of processors, which minimizes runtime.
+However, because of limitations of the underlying operating system, heterogeneous hardware, or scheduling requirements (real-time), it is sometimes necessary to have multiple clusters.
+
+
+\subsection{Virtual Processor}
+\label{s:RuntimeStructureProcessor}
+
+A virtual processor is implemented by a kernel thread (\eg UNIX process), which is subsequently scheduled for execution on a hardware processor by the underlying operating system.
+Programs may use more virtual processors than hardware processors.
+On a multiprocessor, kernel threads are distributed across the hardware processors resulting in virtual processors executing in parallel.
+(It is possible to use affinity to lock a virtual processor onto a particular hardware processor~\cite{affinityLinux, affinityWindows, affinityFreebsd, affinityNetbsd, affinityMacosx}, which is used when caching issues occur or for heterogeneous hardware processors.)
+The \CFA runtime attempts to block unused processors and unblock processors as the system load increases;
+balancing the workload with processors is difficult.
+Preemption occurs on virtual processors rather than user threads, via operating-system interrupts.
+Thus virtual processors execute user threads, where preemption frequency applies to a virtual processor, so preemption occurs randomly across the executed user threads.
+Turning off preemption transforms user threads into fibers.
+
+
+\subsection{Debug Kernel}
+
+There are two versions of the \CFA runtime kernel: debug and non-debug.
+The debugging version has many runtime checks and internal assertions, \eg stack (non-writable) guard page, and checks for stack overflow whenever context switches occur among coroutines and threads, which catches most stack overflows.
+After a program is debugged, the non-debugging version can be used to decrease space and increase performance.
+
+
+\section{Implementation}
+
+Currently, \CFA has fixed-sized stacks, where the stack size can be set at coroutine/thread creation but with no subsequent growth.
+Schemes exist for dynamic stack-growth, such as stack copying and chained stacks.
+However, stack copying requires pointer adjustment to items on the stack, which is impossible without some form of garage collection.
+As well, chained stacks require all modules be recompiled to use this feature, which breaks backward compatibility with existing C libraries.
+In the long term, it is likely C libraries will migrate to stack chaining to support concurrency, at only a minimal cost to sequential programs.
+Nevertheless, experience teaching \uC~\cite{CS343} shows fixed-sized stacks are rarely an issue in most concurrent programs.
+
+A primary implementation challenge is avoiding contention from dynamically allocating memory because of bulk acquire, \eg the internal-scheduling design is (almost) free of allocations.
+All blocking operations are made by parking threads onto queues, therefore all queues are designed with intrusive nodes, where each node has preallocated link fields for chaining.
+Furthermore, several bulk-acquire operations need a variable amount of memory.
+This storage is allocated at the base of a thread's stack before blocking, which means programmers must add a small amount of extra space for stacks.
+
+In \CFA, ordering of monitor acquisition relies on memory ordering to prevent deadlock~\cite{Havender68}, because all objects are guaranteed to have distinct non-overlapping memory layouts, and mutual-exclusion for a monitor is only defined for its lifetime.
+When a mutex call is made, pointers to the concerned monitors are aggregated into a variable-length array and sorted.
 This array persists for the entire duration of the mutual-exclusion and its ordering reused extensively.
-\begin{figure}
-\begin{multicols}{2}
-Entry
-\begin{cfa}
-if monitor is free
-	enter
-elif already own the monitor
-	continue
-else
-	block
-increment recursions
-\end{cfa}
-\columnbreak
-Exit
-\begin{cfa}
-decrement recursion
-if recursion == 0
-	if entry queue not empty
-		wake-up thread
-\end{cfa}
-\end{multicols}
-\begin{cfa}[caption={Initial entry and exit routine for monitors},label={f:entry1}]
-\end{cfa}
-\end{figure}
-
-\subsection{Details: Interaction with polymorphism}
-Depending on the choice of semantics for when monitor locks are acquired, interaction between monitors and \CFA's concept of polymorphism can be more complex to support.
-However, it is shown that entry-point locking solves most of the issues.
-
-First of all, interaction between @otype@ polymorphism (see Section~\ref{s:ParametricPolymorphism}) and monitors is impossible since monitors do not support copying.
-Therefore, the main question is how to support @dtype@ polymorphism.
-It is important to present the difference between the two acquiring options: \textbf{callsite-locking} and entry-point locking, \ie acquiring the monitors before making a mutex routine-call or as the first operation of the mutex routine-call.
-For example:
-\begin{table}
-\begin{center}
-\begin{tabular}{|c|c|c|}
-Mutex & \textbf{callsite-locking} & \textbf{entry-point-locking} \\
-call & cfa-code & cfa-code \\
-\hline
-\begin{cfa}[tabsize=3]
-void foo(monitor& mutex a){
-
-	// Do Work
-	//...
-
-}
-
-void main() {
-	monitor a;
-
-	foo(a);
-
-}
-\end{cfa} & \begin{cfa}[tabsize=3]
-foo(& a) {
-
-	// Do Work
-	//...
-
-}
-
-main() {
-	monitor a;
-	acquire(a);
-	foo(a);
-	release(a);
-}
-\end{cfa} & \begin{cfa}[tabsize=3]
-foo(& a) {
-	acquire(a);
-	// Do Work
-	//...
-	release(a);
-}
-
-main() {
-	monitor a;
-
-	foo(a);
-
-}
-\end{cfa}
-\end{tabular}
-\end{center}
-\caption{Call-site vs entry-point locking for mutex calls}
-\label{tbl:locking-site}
-\end{table}
-
-Note the @mutex@ keyword relies on the type system, which means that in cases where a generic monitor-routine is desired, writing the mutex routine is possible with the proper trait, \eg:
-\begin{cfa}
-// Incorrect: T may not be monitor
-forall(dtype T)
-void foo(T * mutex t);
-
-// Correct: this routine only works on monitors (any monitor)
-forall(dtype T | is_monitor(T))
-void bar(T * mutex t));
-\end{cfa}
-
-Both entry point and \textbf{callsite-locking} are feasible implementations.
-The current \CFA implementation uses entry-point locking because it requires less work when using \textbf{raii}, effectively transferring the burden of implementation to object construction/destruction.
-It is harder to use \textbf{raii} for call-site locking, as it does not necessarily have an existing scope that matches exactly the scope of the mutual exclusion, \ie the routine body.
-For example, the monitor call can appear in the middle of an expression.
-Furthermore, entry-point locking requires less code generation since any useful routine is called multiple times but there is only one entry point for many call sites.
-
-% ======================================================================
-% ======================================================================
-\section{Threading} \label{impl:thread}
-% ======================================================================
-% ======================================================================
-
-Figure \ref{fig:system1} shows a high-level picture if the \CFA runtime system in regards to concurrency.
-Each component of the picture is explained in detail in the flowing sections.
-
-\begin{figure}
-\begin{center}
-{\resizebox{\textwidth}{!}{\input{system.pstex_t}}}
-\end{center}
-\caption{Overview of the entire system}
-\label{fig:system1}
-\end{figure}
-
-\subsection{Processors}
-Parallelism in \CFA is built around using processors to specify how much parallelism is desired. \CFA processors are object wrappers around kernel threads, specifically @pthread@s in the current implementation of \CFA.
-Indeed, any parallelism must go through operating-system libraries.
-However, \textbf{uthread} are still the main source of concurrency, processors are simply the underlying source of parallelism.
-Indeed, processor \textbf{kthread} simply fetch a \textbf{uthread} from the scheduler and run it; they are effectively executers for user-threads.
-The main benefit of this approach is that it offers a well-defined boundary between kernel code and user code, for example, kernel thread quiescing, scheduling and interrupt handling.
-Processors internally use coroutines to take advantage of the existing context-switching semantics.
-
-\subsection{Stack Management}
-One of the challenges of this system is to reduce the footprint as much as possible.
-Specifically, all @pthread@s created also have a stack created with them, which should be used as much as possible.
-Normally, coroutines also create their own stack to run on, however, in the case of the coroutines used for processors, these coroutines run directly on the \textbf{kthread} stack, effectively stealing the processor stack.
-The exception to this rule is the Main Processor, \ie the initial \textbf{kthread} that is given to any program.
-In order to respect C user expectations, the stack of the initial kernel thread, the main stack of the program, is used by the main user thread rather than the main processor, which can grow very large.
-
-\subsection{Context Switching}
-As mentioned in section \ref{coroutine}, coroutines are a stepping stone for implementing threading, because they share the same mechanism for context-switching between different stacks.
-To improve performance and simplicity, context-switching is implemented using the following assumption: all context-switches happen inside a specific routine call.
-This assumption means that the context-switch only has to copy the callee-saved registers onto the stack and then switch the stack registers with the ones of the target coroutine/thread.
-Note that the instruction pointer can be left untouched since the context-switch is always inside the same routine
-Threads, however, do not context-switch between each other directly.
-They context-switch to the scheduler.
-This method is called a 2-step context-switch and has the advantage of having a clear distinction between user code and the kernel where scheduling and other system operations happen.
-Obviously, this doubles the context-switch cost because threads must context-switch to an intermediate stack.
-The alternative 1-step context-switch uses the stack of the ``from'' thread to schedule and then context-switches directly to the ``to'' thread.
-However, the performance of the 2-step context-switch is still superior to a @pthread_yield@ (see section \ref{results}).
-Additionally, for users in need for optimal performance, it is important to note that having a 2-step context-switch as the default does not prevent \CFA from offering a 1-step context-switch (akin to the Microsoft @SwitchToFiber@~\cite{switchToWindows} routine).
-This option is not currently present in \CFA, but the changes required to add it are strictly additive.
-
-\subsection{Preemption} \label{preemption}
-Finally, an important aspect for any complete threading system is preemption.
-As mentioned in section \ref{basics}, preemption introduces an extra degree of uncertainty, which enables users to have multiple threads interleave transparently, rather than having to cooperate among threads for proper scheduling and CPU distribution.
-Indeed, preemption is desirable because it adds a degree of isolation among threads.
-In a fully cooperative system, any thread that runs a long loop can starve other threads, while in a preemptive system, starvation can still occur but it does not rely on every thread having to yield or block on a regular basis, which reduces significantly a programmer burden.
-Obviously, preemption is not optimal for every workload.
-However any preemptive system can become a cooperative system by making the time slices extremely large.
-Therefore, \CFA uses a preemptive threading system.
-
-Preemption in \CFA\footnote{Note that the implementation of preemption is strongly tied with the underlying threading system.
-For this reason, only the Linux implementation is cover, \CFA does not run on Windows at the time of writting} is based on kernel timers, which are used to run a discrete-event simulation.
-Every processor keeps track of the current time and registers an expiration time with the preemption system.
-When the preemption system receives a change in preemption, it inserts the time in a sorted order and sets a kernel timer for the closest one, effectively stepping through preemption events on each signal sent by the timer.
-These timers use the Linux signal {\tt SIGALRM}, which is delivered to the process rather than the kernel-thread.
-This results in an implementation problem, because when delivering signals to a process, the kernel can deliver the signal to any kernel thread for which the signal is not blocked, \ie:
+
+To improve performance and simplicity, context switching occur inside a routine call, so only callee-saved registers are copied onto the stack and then the stack register is switched;
+the corresponding registers are then restored for the other context.
+Note, the instruction pointer is untouched since the context switch is always inside the same routine.
+Unlike coroutines, threads do not context switch among each other;
+they context switch to the cluster scheduler.
+This method is a 2-step context-switch and provides a clear distinction between user and kernel code, where scheduling and other system operations happen.
+The alternative 1-step context-switch uses the \emph{from} thread's stack to schedule and then context-switches directly to the \emph{to} thread's stack.
+Experimental results (not presented) show the performance difference between these two approaches is virtually equivalent, because the 1-step performance is dominated by a lock instruction to prevent a race condition.
+
+All kernel threads (@pthreads@) created a stack.
+Each \CFA virtual processor is implemented as a coroutine and these coroutines run directly on the kernel-thread stack, effectively stealing this stack.
+The exception to this rule is the program main, \ie the initial kernel thread that is given to any program.
+In order to respect C expectations, the stack of the initial kernel thread is used by program main rather than the main processor, allowing it to grow dynamically as in a normal C program.
+
+Finally, an important aspect for a complete threading system is preemption, which introduces extra non-determinism via transparent interleaving, rather than cooperation among threads for proper scheduling and processor fairness from long-running threads.
+Because preemption frequency is usually long, 1 millisecond, performance cost is negligible.
+Preemption is normally handled by setting a count-down timer on each virtual processor.
+When the timer expires, an interrupt is delivered, and the interrupt handler resets the count-down timer, and if the virtual processor is executing in user code, the signal handler performs a user-level context-switch, or if executing in the language runtime-kernel, the preemption is ignored or rolled forward to the point where the runtime kernel context switches back to user code.
+Multiple signal handlers may be pending.
+When control eventually switches back to the signal handler, it returns normally, and execution continues in the interrupted user thread, even though the return from the signal handler may be on a different kernel thread than the one where the signal was delivered.
+The only issue with this approach is that signal masks from one kernel thread may be restored on another as part of returning from the signal handler;
+therefore, all virtual processors in a cluster need to have the same signal mask.
+
+However, on current UNIX systems:
 \begin{quote}
 A process-directed signal may be delivered to any one of the threads that does not currently have the signal blocked.
@@ -2522,896 +2107,376 @@
 SIGNAL(7) - Linux Programmer's Manual
 \end{quote}
-For the sake of simplicity, and in order to prevent the case of having two threads receiving alarms simultaneously, \CFA programs block the {\tt SIGALRM} signal on every kernel thread except one.
-
-Now because of how involuntary context-switches are handled, the kernel thread handling {\tt SIGALRM} cannot also be a processor thread.
-Hence, involuntary context-switching is done by sending signal {\tt SIGUSR1} to the corresponding proces\-sor and having the thread yield from inside the signal handler.
-This approach effectively context-switches away from the signal handler back to the kernel and the signal handler frame is eventually unwound when the thread is scheduled again.
-As a result, a signal handler can start on one kernel thread and terminate on a second kernel thread (but the same user thread).
-It is important to note that signal handlers save and restore signal masks because user-thread migration can cause a signal mask to migrate from one kernel thread to another.
-This behaviour is only a problem if all kernel threads, among which a user thread can migrate, differ in terms of signal masks\footnote{Sadly, official POSIX documentation is silent on what distinguishes ``async-signal-safe'' routines from other routines}.
-However, since the kernel thread handling preemption requires a different signal mask, executing user threads on the kernel-alarm thread can cause deadlocks.
-For this reason, the alarm thread is in a tight loop around a system call to @sigwaitinfo@, requiring very little CPU time for preemption.
-One final detail about the alarm thread is how to wake it when additional communication is required (\eg on thread termination).
-This unblocking is also done using {\tt SIGALRM}, but sent through the @pthread_sigqueue@.
-Indeed, @sigwait@ can differentiate signals sent from @pthread_sigqueue@ from signals sent from alarms or the kernel.
-
-\subsection{Scheduler}
-Finally, an aspect that was not mentioned yet is the scheduling algorithm.
-Currently, the \CFA scheduler uses a single ready queue for all processors, which is the simplest approach to scheduling.
-Further discussion on scheduling is present in section \ref{futur:sched}.
-
-% ======================================================================
-% ======================================================================
-\section{Internal Scheduling} \label{impl:intsched}
-% ======================================================================
-% ======================================================================
-The following figure is the traditional illustration of a monitor (repeated from page~\pageref{fig:ClassicalMonitor} for convenience):
-
-\begin{figure}
-\begin{center}
-{\resizebox{0.4\textwidth}{!}{\input{monitor}}}
-\end{center}
-\caption{Traditional illustration of a monitor}
-\end{figure}
-
-This picture has several components, the two most important being the entry queue and the AS-stack.
-The entry queue is an (almost) FIFO list where threads waiting to enter are parked, while the acceptor/signaller (AS) stack is a FILO list used for threads that have been signalled or otherwise marked as running next.
-
-For \CFA, this picture does not have support for blocking multiple monitors on a single condition.
-To support bulk acquire two changes to this picture are required.
-First, it is no longer helpful to attach the condition to \emph{a single} monitor.
-Secondly, the thread waiting on the condition has to be separated across multiple monitors, seen in figure \ref{fig:monitor_cfa}.
-
-\begin{figure}
-\begin{center}
-{\resizebox{0.8\textwidth}{!}{\input{int_monitor}}}
-\end{center}
-\caption{Illustration of \CFA Monitor}
-\label{fig:monitor_cfa}
-\end{figure}
-
-This picture and the proper entry and leave algorithms (see listing \ref{f:entry2}) is the fundamental implementation of internal scheduling.
-Note that when a thread is moved from the condition to the AS-stack, it is conceptually split into N pieces, where N is the number of monitors specified in the parameter list.
-The thread is woken up when all the pieces have popped from the AS-stacks and made active.
-In this picture, the threads are split into halves but this is only because there are two monitors.
-For a specific signalling operation every monitor needs a piece of thread on its AS-stack.
-
-\begin{figure}
-\begin{multicols}{2}
-Entry
-\begin{cfa}
-if monitor is free
-	enter
-elif already own the monitor
-	continue
-else
-	block
-increment recursion
-
-\end{cfa}
-\columnbreak
-Exit
-\begin{cfa}
-decrement recursion
-if recursion == 0
-	if signal_stack not empty
-		set_owner to thread
-		if all monitors ready
-			wake-up thread
-
-	if entry queue not empty
-		wake-up thread
-\end{cfa}
-\end{multicols}
-\begin{cfa}[caption={Entry and exit routine for monitors with internal scheduling},label={f:entry2}]
-\end{cfa}
-\end{figure}
-
-The solution discussed in \ref{s:InternalScheduling} can be seen in the exit routine of listing \ref{f:entry2}.
-Basically, the solution boils down to having a separate data structure for the condition queue and the AS-stack, and unconditionally transferring ownership of the monitors but only unblocking the thread when the last monitor has transferred ownership.
-This solution is deadlock safe as well as preventing any potential barging.
-The data structures used for the AS-stack are reused extensively for external scheduling, but in the case of internal scheduling, the data is allocated using variable-length arrays on the call stack of the @wait@ and @signal_block@ routines.
-
-\begin{figure}
-\begin{center}
-{\resizebox{0.8\textwidth}{!}{\input{monitor_structs.pstex_t}}}
-\end{center}
-\caption{Data structures involved in internal/external scheduling}
-\label{fig:structs}
-\end{figure}
-
-Figure \ref{fig:structs} shows a high-level representation of these data structures.
-The main idea behind them is that, a thread cannot contain an arbitrary number of intrusive ``next'' pointers for linking onto monitors.
-The @condition node@ is the data structure that is queued onto a condition variable and, when signalled, the condition queue is popped and each @condition criterion@ is moved to the AS-stack.
-Once all the criteria have been popped from their respective AS-stacks, the thread is woken up, which is what is shown in listing \ref{f:entry2}.
-
-% ======================================================================
-% ======================================================================
-\section{External Scheduling}
-% ======================================================================
-% ======================================================================
-Similarly to internal scheduling, external scheduling for multiple monitors relies on the idea that waiting-thread queues are no longer specific to a single monitor, as mentioned in section \ref{extsched}.
-For internal scheduling, these queues are part of condition variables, which are still unique for a given scheduling operation (\ie no signal statement uses multiple conditions).
-However, in the case of external scheduling, there is no equivalent object which is associated with @waitfor@ statements.
-This absence means the queues holding the waiting threads must be stored inside at least one of the monitors that is acquired.
-These monitors being the only objects that have sufficient lifetime and are available on both sides of the @waitfor@ statement.
-This requires an algorithm to choose which monitor holds the relevant queue.
-It is also important that said algorithm be independent of the order in which users list parameters.
-The proposed algorithm is to fall back on monitor lock ordering (sorting by address) and specify that the monitor that is acquired first is the one with the relevant waiting queue.
-This assumes that the lock acquiring order is static for the lifetime of all concerned objects but that is a reasonable constraint.
-
-This algorithm choice has two consequences:
-\begin{itemize}
-	\item The queue of the monitor with the lowest address is no longer a true FIFO queue because threads can be moved to the front of the queue.
-These queues need to contain a set of monitors for each of the waiting threads.
-Therefore, another thread whose set contains the same lowest address monitor but different lower priority monitors may arrive first but enter the critical section after a thread with the correct pairing.
-	\item The queue of the lowest priority monitor is both required and potentially unused.
-Indeed, since it is not known at compile time which monitor is the monitor which has the lowest address, every monitor needs to have the correct queues even though it is possible that some queues go unused for the entire duration of the program, for example if a monitor is only used in a specific pair.
-\end{itemize}
-Therefore, the following modifications need to be made to support external scheduling:
-\begin{itemize}
-	\item The threads waiting on the entry queue need to keep track of which routine they are trying to enter, and using which set of monitors.
-The @mutex@ routine already has all the required information on its stack, so the thread only needs to keep a pointer to that information.
-	\item The monitors need to keep a mask of acceptable routines.
-This mask contains for each acceptable routine, a routine pointer and an array of monitors to go with it.
-It also needs storage to keep track of which routine was accepted.
-Since this information is not specific to any monitor, the monitors actually contain a pointer to an integer on the stack of the waiting thread.
-Note that if a thread has acquired two monitors but executes a @waitfor@ with only one monitor as a parameter, setting the mask of acceptable routines to both monitors will not cause any problems since the extra monitor will not change ownership regardless.
-This becomes relevant when @when@ clauses affect the number of monitors passed to a @waitfor@ statement.
-	\item The entry/exit routines need to be updated as shown in listing \ref{f:entry3}.
-\end{itemize}
-
-\subsection{External Scheduling - Destructors}
-Finally, to support the ordering inversion of destructors, the code generation needs to be modified to use a special entry routine.
-This routine is needed because of the storage requirements of the call order inversion.
-Indeed, when waiting for the destructors, storage is needed for the waiting context and the lifetime of said storage needs to outlive the waiting operation it is needed for.
-For regular @waitfor@ statements, the call stack of the routine itself matches this requirement but it is no longer the case when waiting for the destructor since it is pushed on to the AS-stack for later.
-The @waitfor@ semantics can then be adjusted correspondingly, as seen in listing \ref{f:entry-dtor}
-
-\begin{figure}
-\begin{multicols}{2}
-Entry
-\begin{cfa}
-if monitor is free
-	enter
-elif already own the monitor
-	continue
-elif matches waitfor mask
-	push criteria to AS-stack
-	continue
-else
-	block
-increment recursion
-\end{cfa}
-\columnbreak
-Exit
-\begin{cfa}
-decrement recursion
-if recursion == 0
-	if signal_stack not empty
-		set_owner to thread
-		if all monitors ready
-			wake-up thread
-		endif
-	endif
-
-	if entry queue not empty
-		wake-up thread
-	endif
-\end{cfa}
-\end{multicols}
-\begin{cfa}[caption={Entry and exit routine for monitors with internal scheduling and external scheduling},label={f:entry3}]
-\end{cfa}
-\end{figure}
-
-\begin{figure}
-\begin{multicols}{2}
-Destructor Entry
-\begin{cfa}
-if monitor is free
-	enter
-elif already own the monitor
-	increment recursion
-	return
-create wait context
-if matches waitfor mask
-	reset mask
-	push self to AS-stack
-	baton pass
-else
-	wait
-increment recursion
-\end{cfa}
-\columnbreak
-Waitfor
-\begin{cfa}
-if matching thread is already there
-	if found destructor
-		push destructor to AS-stack
-		unlock all monitors
-	else
-		push self to AS-stack
-		baton pass
-	endif
-	return
-endif
-if non-blocking
-	Unlock all monitors
-	Return
-endif
-
-push self to AS-stack
-set waitfor mask
-block
-return
-\end{cfa}
-\end{multicols}
-\begin{cfa}[caption={Pseudo code for the \protect\lstinline|waitfor| routine and the \protect\lstinline|mutex| entry routine for destructors},label={f:entry-dtor}]
-\end{cfa}
-\end{figure}
-
-
-% ======================================================================
-% ======================================================================
-\section{Putting It All Together}
-% ======================================================================
-% ======================================================================
-
-
-\section{Threads As Monitors}
-As it was subtly alluded in section \ref{threads}, @thread@s in \CFA are in fact monitors, which means that all monitor features are available when using threads.
-For example, here is a very simple two thread pipeline that could be used for a simulator of a game engine:
-\begin{figure}
-\begin{cfa}[caption={Toy simulator using \protect\lstinline|thread|s and \protect\lstinline|monitor|s.},label={f:engine-v1}]
-// Visualization declaration
-thread Renderer {} renderer;
-Frame * simulate( Simulator & this );
-
-// Simulation declaration
-thread Simulator{} simulator;
-void render( Renderer & this );
-
-// Blocking call used as communication
-void draw( Renderer & mutex this, Frame * frame );
-
-// Simulation loop
-void main( Simulator & this ) {
-	while( true ) {
-		Frame * frame = simulate( this );
-		draw( renderer, frame );
-	}
-}
-
-// Rendering loop
-void main( Renderer & this ) {
-	while( true ) {
-		waitfor( draw, this );
-		render( this );
-	}
-}
-\end{cfa}
-\end{figure}
-One of the obvious complaints of the previous code snippet (other than its toy-like simplicity) is that it does not handle exit conditions and just goes on forever.
-Luckily, the monitor semantics can also be used to clearly enforce a shutdown order in a concise manner:
-\begin{figure}
-\begin{cfa}[caption={Same toy simulator with proper termination condition.},label={f:engine-v2}]
-// Visualization declaration
-thread Renderer {} renderer;
-Frame * simulate( Simulator & this );
-
-// Simulation declaration
-thread Simulator{} simulator;
-void render( Renderer & this );
-
-// Blocking call used as communication
-void draw( Renderer & mutex this, Frame * frame );
-
-// Simulation loop
-void main( Simulator & this ) {
-	while( true ) {
-		Frame * frame = simulate( this );
-		draw( renderer, frame );
-
-		// Exit main loop after the last frame
-		if( frame->is_last ) break;
-	}
-}
-
-// Rendering loop
-void main( Renderer & this ) {
-	while( true ) {
-		   waitfor( draw, this );
-		or waitfor( ^?{}, this ) {
-			// Add an exit condition
-			break;
-		}
-
-		render( this );
-	}
-}
-
-// Call destructor for simulator once simulator finishes
-// Call destructor for renderer to signify shutdown
-\end{cfa}
-\end{figure}
-
-\section{Fibers \& Threads}
-As mentioned in section \ref{preemption}, \CFA uses preemptive threads by default but can use fibers on demand.
-Currently, using fibers is done by adding the following line of code to the program~:
-\begin{cfa}
-unsigned int default_preemption() {
-	return 0;
-}
-\end{cfa}
-This routine is called by the kernel to fetch the default preemption rate, where 0 signifies an infinite time-slice, \ie no preemption.
-However, once clusters are fully implemented, it will be possible to create fibers and \textbf{uthread} in the same system, as in listing \ref{f:fiber-uthread}
-\begin{figure}
-\lstset{language=CFA,deletedelim=**[is][]{`}{`}}
-\begin{cfa}[caption={Using fibers and \textbf{uthread} side-by-side in \CFA},label={f:fiber-uthread}]
-// Cluster forward declaration
-struct cluster;
-
-// Processor forward declaration
-struct processor;
-
-// Construct clusters with a preemption rate
-void ?{}(cluster& this, unsigned int rate);
-// Construct processor and add it to cluster
-void ?{}(processor& this, cluster& cluster);
-// Construct thread and schedule it on cluster
-void ?{}(thread& this, cluster& cluster);
-
-// Declare two clusters
-cluster thread_cluster = { 10`ms };			// Preempt every 10 ms
-cluster fibers_cluster = { 0 };				// Never preempt
-
-// Construct 4 processors
-processor processors[4] = {
-	//2 for the thread cluster
-	thread_cluster;
-	thread_cluster;
-	//2 for the fibers cluster
-	fibers_cluster;
-	fibers_cluster;
-};
-
-// Declares thread
-thread UThread {};
-void ?{}(UThread& this) {
-	// Construct underlying thread to automatically
-	// be scheduled on the thread cluster
-	(this){ thread_cluster }
-}
-
-void main(UThread & this);
-
-// Declares fibers
-thread Fiber {};
-void ?{}(Fiber& this) {
-	// Construct underlying thread to automatically
-	// be scheduled on the fiber cluster
-	(this.__thread){ fibers_cluster }
-}
-
-void main(Fiber & this);
-\end{cfa}
-\end{figure}
-
-
-% ======================================================================
-% ======================================================================
-\section{Performance Results} \label{results}
-% ======================================================================
-% ======================================================================
-\section{Machine Setup}
-Table \ref{tab:machine} shows the characteristics of the machine used to run the benchmarks.
-All tests were made on this machine.
+Hence, the timer-expiry signal, which is generated \emph{externally} by the UNIX kernel to the UNIX process, is delivered to any of its UNIX subprocesses (kernel threads).
+To ensure each virtual processor receives its own preemption signals, a discrete-event simulation is run on a special virtual processor, and only it sets and receives timer events.
+Virtual processors register an expiration time with the discrete-event simulator, which is inserted in sorted order.
+The simulation sets the count-down timer to the value at the head of the event list, and when the timer expires, all events less than or equal to the current time are processed.
+Processing a preemption event sends an \emph{internal} @SIGUSR1@ signal to the registered virtual processor, which is always delivered to that processor.
+
+
+\section{Performance}
+\label{results}
+
+To verify the implementation of the \CFA runtime, a series of microbenchmarks are performed comparing \CFA with other widely used programming languages with concurrency.
+Table~\ref{t:machine} shows the specifications of the computer used to run the benchmarks, and the versions of the software used in the comparison.
+
 \begin{table}
-\begin{center}
-\begin{tabular}{| l | r | l | r |}
+\centering
+\caption{Experiment environment}
+\label{t:machine}
+
+\begin{tabular}{|l|r||l|r|}
 \hline
-Architecture		& x86\_64 			& NUMA node(s) 	& 8 \\
+Architecture		& x86\_64 				& NUMA node(s) 	& 8 \\
 \hline
-CPU op-mode(s)		& 32-bit, 64-bit 		& Model name 	& AMD Opteron\texttrademark  Processor 6380 \\
+CPU op-mode(s)		& 32-bit, 64-bit 		& Model name 	& AMD Opteron\texttrademark\ Processor 6380 \\
 \hline
-Byte Order			& Little Endian 		& CPU Freq 		& 2.5\si{\giga\hertz} \\
+Byte Order			& Little Endian 		& CPU Freq 		& 2.5 GHz \\
 \hline
-CPU(s)			& 64 				& L1d cache 	& \SI{16}{\kibi\byte} \\
+CPU(s)				& 64 					& L1d cache 	& 16 KiB \\
 \hline
-Thread(s) per core	& 2 				& L1i cache 	& \SI{64}{\kibi\byte} \\
+Thread(s) per core	& 2 					& L1i cache 	& 64 KiB \\
 \hline
-Core(s) per socket	& 8 				& L2 cache 		& \SI{2048}{\kibi\byte} \\
+Core(s) per socket	& 8 					& L2 cache 		& 2048 KiB \\
 \hline
-Socket(s)			& 4 				& L3 cache 		& \SI{6144}{\kibi\byte} \\
+Socket(s)			& 4 					& L3 cache 		& 6144 KiB \\
 \hline
 \hline
-Operating system		& Ubuntu 16.04.3 LTS	& Kernel		& Linux 4.4-97-generic \\
+Operating system	& Ubuntu 16.04.3 LTS	& Kernel		& Linux 4.4-97-generic \\
 \hline
-Compiler			& GCC 6.3 		& Translator	& CFA 1 \\
+gcc					& 6.3	 				& \CFA			& 1.0.0 \\
 \hline
-Java version		& OpenJDK-9 		& Go version	& 1.9.2 \\
+Java				& OpenJDK-9 			& Go			& 1.9.2 \\
 \hline
 \end{tabular}
-\end{center}
-\caption{Machine setup used for the tests}
-\label{tab:machine}
 \end{table}
 
-\section{Micro Benchmarks}
-All benchmarks are run using the same harness to produce the results, seen as the @BENCH()@ macro in the following examples.
-This macro uses the following logic to benchmark the code:
-\begin{cfa}
-#define BENCH(run, result) \
-	before = gettime(); \
-	run; \
-	after  = gettime(); \
-	result = (after - before) / N;
-\end{cfa}
-The method used to get time is @clock_gettime(CLOCK_THREAD_CPUTIME_ID);@.
-Each benchmark is using many iterations of a simple call to measure the cost of the call.
-The specific number of iterations depends on the specific benchmark.
-
-\subsection{Context-Switching}
-The first interesting benchmark is to measure how long context-switches take.
-The simplest approach to do this is to yield on a thread, which executes a 2-step context switch.
-Yielding causes the thread to context-switch to the scheduler and back, more precisely: from the \textbf{uthread} to the \textbf{kthread} then from the \textbf{kthread} back to the same \textbf{uthread} (or a different one in the general case).
-In order to make the comparison fair, coroutines also execute a 2-step context-switch by resuming another coroutine which does nothing but suspending in a tight loop, which is a resume/suspend cycle instead of a yield.
-Figure~\ref{f:ctx-switch} shows the code for coroutines and threads with the results in table \ref{tab:ctx-switch}.
-All omitted tests are functionally identical to one of these tests.
-The difference between coroutines and threads can be attributed to the cost of scheduling.
+All benchmarks are run using the following harness:
+\begin{cfa}
+unsigned int N = 10_000_000;
+#define BENCH( run ) Time before = getTimeNsec(); run; Duration result = (getTimeNsec() - before) / N;
+\end{cfa}
+The method used to get time is @clock_gettime( CLOCK_REALTIME )@.
+Each benchmark is performed @N@ times, where @N@ varies depending on the benchmark, the total time is divided by @N@ to obtain the average time for a benchmark.
+All omitted tests for other languages are functionally identical to the shown \CFA test.
+
+
+\paragraph{Context-Switching}
+
+In procedural programming, the cost of a routine call is important as modularization (refactoring) increases.
+(In many cases, a compiler inlines routine calls to eliminate this cost.)
+Similarly, when modularization extends to coroutines/tasks, the time for a context switch becomes a relevant factor.
+The coroutine context-switch is 2-step using resume/suspend, \ie from resumer to suspender and from suspender to resumer.
+The thread context switch is 2-step using yield, \ie enter and return from the runtime kernel.
+Figure~\ref{f:ctx-switch} shows the code for coroutines/threads with all results in Table~\ref{tab:ctx-switch}.
+The difference in performance between coroutine and thread context-switch is the cost of scheduling for threads, whereas coroutines are self-scheduling.
+
 \begin{figure}
-\begin{multicols}{2}
-\CFA Coroutines
-\begin{cfa}
-coroutine GreatSuspender {};
-void main(GreatSuspender& this) {
-	while(true) { suspend(); }
-}
+\lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}}
+
+\newbox\myboxA
+\begin{lrbox}{\myboxA}
+\begin{cfa}[aboveskip=0pt,belowskip=0pt]
+coroutine C {} c;
+void main( C & ) { for ( ;; ) { @suspend();@ } }
 int main() {
-	GreatSuspender s;
-	resume(s);
 	BENCH(
-		for(size_t i=0; i<n; i++) {
-			resume(s);
-		},
-		result
-	)
-	printf("%llu\n", result);
-}
-\end{cfa}
-\columnbreak
-\CFA Threads
-\begin{cfa}
-
-
+		for ( size_t i = 0; i < N; i += 1 ) { @resume( c );@ } )
+	sout | result`ns | endl;
+}
+\end{cfa}
+\end{lrbox}
+
+\newbox\myboxB
+\begin{lrbox}{\myboxB}
+\begin{cfa}[aboveskip=0pt,belowskip=0pt]
 
 
 int main() {
-
-
 	BENCH(
-		for(size_t i=0; i<n; i++) {
-			yield();
-		},
-		result
-	)
-	printf("%llu\n", result);
-}
-\end{cfa}
-\end{multicols}
-\begin{cfa}[caption={\CFA benchmark code used to measure context-switches for coroutines and threads.},label={f:ctx-switch}]
-\end{cfa}
-\end{figure}
-
-\begin{table}
-\begin{center}
-\begin{tabular}{| l | S[table-format=5.2,table-number-alignment=right] | S[table-format=5.2,table-number-alignment=right] | S[table-format=5.2,table-number-alignment=right] |}
+		for ( size_t i = 0; i < N; i += 1 ) { @yield();@ } )
+	sout | result`ns | endl;
+}
+\end{cfa}
+\end{lrbox}
+
+\subfloat[Coroutine]{\usebox\myboxA}
+\quad
+\subfloat[Thread]{\usebox\myboxB}
+\captionof{figure}{\CFA context-switch benchmark}
+\label{f:ctx-switch}
+
+\centering
+
+\captionof{table}{Context switch comparison (nanoseconds)}
+\label{tab:ctx-switch}
+\bigskip
+\begin{tabular}{|r|*{3}{D{.}{.}{3.2}|}}
 \cline{2-4}
-\multicolumn{1}{c |}{} & \multicolumn{1}{c |}{ Median } &\multicolumn{1}{c |}{ Average } & \multicolumn{1}{c |}{ Standard Deviation} \\
+\multicolumn{1}{c|}{} & \multicolumn{1}{c|}{Median} &\multicolumn{1}{c|}{Average} & \multicolumn{1}{c|}{Std Dev} \\
 \hline
-Kernel Thread	& 241.5	& 243.86	& 5.08 \\
+Kernel Thread	& 241.5		& 243.86	& 5.08 \\
 \CFA Coroutine	& 38		& 38		& 0    \\
 \CFA Thread		& 103		& 102.96	& 2.96 \\
-\uC Coroutine	& 46		& 45.86	& 0.35 \\
-\uC Thread		& 98		& 99.11	& 1.42 \\
+\uC Coroutine	& 46		& 45.86		& 0.35 \\
+\uC Thread		& 98		& 99.11		& 1.42 \\
 Goroutine		& 150		& 149.96	& 3.16 \\
 Java Thread		& 289		& 290.68	& 8.72 \\
 \hline
 \end{tabular}
-\end{center}
-\caption{Context Switch comparison.
-All numbers are in nanoseconds(\si{\nano\second})}
-\label{tab:ctx-switch}
-\end{table}
-
-\subsection{Mutual-Exclusion}
-The next interesting benchmark is to measure the overhead to enter/leave a critical-section.
-For monitors, the simplest approach is to measure how long it takes to enter and leave a monitor routine.
-Figure~\ref{f:mutex} shows the code for \CFA.
-To put the results in context, the cost of entering a non-inline routine and the cost of acquiring and releasing a @pthread_mutex@ lock is also measured.
-The results can be shown in table \ref{tab:mutex}.
-
-\begin{figure}
-\begin{cfa}[caption={\CFA benchmark code used to measure mutex routines.},label={f:mutex}]
-monitor M {};
-void __attribute__((noinline)) call( M & mutex m /*, m2, m3, m4*/ ) {}
-
+
+\bigskip
+\bigskip
+
+\lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}}
+\begin{cfa}
+monitor M {} m1/*, m2, m3, m4*/;
+void __attribute__((noinline)) do_call( M & mutex m/*, m2, m3, m4*/ ) {}
 int main() {
-	M m/*, m2, m3, m4*/;
-	BENCH(
-		for(size_t i=0; i<n; i++) {
-			call(m/*, m2, m3, m4*/);
-		},
-		result
-	)
-	printf("%llu\n", result);
-}
-\end{cfa}
-\end{figure}
-
-\begin{table}
-\begin{center}
-\begin{tabular}{| l | S[table-format=5.2,table-number-alignment=right] | S[table-format=5.2,table-number-alignment=right] | S[table-format=5.2,table-number-alignment=right] |}
+	BENCH( for( size_t i = 0; i < N; i += 1 ) { @do_call( m1/*, m2, m3, m4*/ );@ } )
+	sout | result`ns | endl;
+}
+\end{cfa}
+\captionof{figure}{\CFA acquire/release mutex benchmark}
+\label{f:mutex}
+
+\centering
+
+\captionof{table}{Mutex comparison (nanoseconds)}
+\label{tab:mutex}
+\bigskip
+
+\begin{tabular}{|r|*{3}{D{.}{.}{3.2}|}}
 \cline{2-4}
-\multicolumn{1}{c |}{} & \multicolumn{1}{c |}{ Median } &\multicolumn{1}{c |}{ Average } & \multicolumn{1}{c |}{ Standard Deviation} \\
+\multicolumn{1}{c|}{} & \multicolumn{1}{c|}{Median} &\multicolumn{1}{c|}{Average} & \multicolumn{1}{c|}{Std Dev} \\
 \hline
-C routine						& 2		& 2		& 0    \\
-FetchAdd + FetchSub				& 26		& 26		& 0    \\
-Pthreads Mutex Lock				& 31		& 31.86	& 0.99 \\
+C routine							& 2			& 2			& 0    \\
+FetchAdd + FetchSub					& 26		& 26		& 0    \\
+Pthreads Mutex Lock					& 31		& 31.86		& 0.99 \\
 \uC @monitor@ member routine		& 30		& 30		& 0    \\
-\CFA @mutex@ routine, 1 argument	& 41		& 41.57	& 0.9  \\
-\CFA @mutex@ routine, 2 argument	& 76		& 76.96	& 1.57 \\
+\CFA @mutex@ routine, 1 argument	& 41		& 41.57		& 0.9  \\
+\CFA @mutex@ routine, 2 argument	& 76		& 76.96		& 1.57 \\
 \CFA @mutex@ routine, 4 argument	& 145		& 146.68	& 3.85 \\
-Java synchronized routine			& 27		& 28.57	& 2.6  \\
+Java synchronized routine			& 27		& 28.57		& 2.6  \\
 \hline
 \end{tabular}
-\end{center}
-\caption{Mutex routine comparison.
-All numbers are in nanoseconds(\si{\nano\second})}
-\label{tab:mutex}
-\end{table}
-
-\subsection{Internal Scheduling}
-The internal-scheduling benchmark measures the cost of waiting on and signalling a condition variable.
-Figure~\ref{f:int-sched} shows the code for \CFA, with results table \ref{tab:int-sched}.
-As with all other benchmarks, all omitted tests are functionally identical to one of these tests.
+\end{figure}
+
+
+\paragraph{Mutual-Exclusion}
+
+Mutual exclusion is measured by entering/leaving a critical section.
+For monitors, entering and leaving a monitor routine is measured.
+Figure~\ref{f:mutex} shows the code for \CFA with all results in Table~\ref{tab:mutex}.
+To put the results in context, the cost of entering a non-inline routine and the cost of acquiring and releasing a @pthread_mutex@ lock is also measured.
+Note, the incremental cost of bulk acquire for \CFA, which is largely a fixed cost for small numbers of mutex objects.
+
+
+\paragraph{Internal Scheduling}
+
+Internal scheduling is measured by waiting on and signalling a condition variable.
+Figure~\ref{f:int-sched} shows the code for \CFA, with results in Table~\ref{tab:int-sched}.
+Note, the incremental cost of bulk acquire for \CFA, which is largely a fixed cost for small numbers of mutex objects.
 
 \begin{figure}
-\begin{cfa}[caption={Benchmark code for internal scheduling},label={f:int-sched}]
+\lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}}
+\begin{cfa}
 volatile int go = 0;
 condition c;
-monitor M {};
-M m1;
-
-void __attribute__((noinline)) do_call( M & mutex a1 ) { signal(c); }
-
+monitor M {} m;
+void __attribute__((noinline)) do_call( M & mutex a1 ) { signal( c ); }
 thread T {};
-void ^?{}( T & mutex this ) {}
 void main( T & this ) {
-	while(go == 0) { yield(); }
-	while(go == 1) { do_call(m1); }
-}
-int  __attribute__((noinline)) do_wait( M & mutex a1 ) {
-	go = 1;
-	BENCH(
-		for(size_t i=0; i<n; i++) {
-			wait(c);
-		},
-		result
-	)
-	printf("%llu\n", result);
-	go = 0;
-	return 0;
+	while ( go == 0 ) { yield(); }	// wait for other thread to start
+	while ( go == 1 ) { @do_call( m );@ }
+}
+int  __attribute__((noinline)) do_wait( M & mutex m ) {
+	go = 1;	// continue other thread
+	BENCH( for ( size_t i = 0; i < N; i += 1 ) { @wait( c );@ } );
+	go = 0;	// stop other thread
+	sout | result`ns | endl;
 }
 int main() {
 	T t;
-	return do_wait(m1);
-}
-\end{cfa}
-\end{figure}
-
-\begin{table}
-\begin{center}
-\begin{tabular}{| l | S[table-format=5.2,table-number-alignment=right] | S[table-format=5.2,table-number-alignment=right] | S[table-format=5.2,table-number-alignment=right] |}
+	do_wait( m );
+}
+\end{cfa}
+\captionof{figure}{\CFA Internal scheduling benchmark}
+\label{f:int-sched}
+
+\centering
+\captionof{table}{Internal scheduling comparison (nanoseconds)}
+\label{tab:int-sched}
+\bigskip
+
+\begin{tabular}{|r|*{3}{D{.}{.}{5.2}|}}
 \cline{2-4}
-\multicolumn{1}{c |}{} & \multicolumn{1}{c |}{ Median } &\multicolumn{1}{c |}{ Average } & \multicolumn{1}{c |}{ Standard Deviation} \\
+\multicolumn{1}{c|}{} & \multicolumn{1}{c|}{Median} &\multicolumn{1}{c|}{Average} & \multicolumn{1}{c|}{Std Dev} \\
 \hline
-Pthreads Condition Variable			& 5902.5	& 6093.29 	& 714.78 \\
-\uC @signal@					& 322		& 323 	& 3.36   \\
-\CFA @signal@, 1 @monitor@	& 352.5	& 353.11	& 3.66   \\
-\CFA @signal@, 2 @monitor@	& 430		& 430.29	& 8.97   \\
-\CFA @signal@, 4 @monitor@	& 594.5	& 606.57	& 18.33  \\
-Java @notify@				& 13831.5	& 15698.21	& 4782.3 \\
+Pthreads Condition Variable		& 5902.5	& 6093.29 	& 714.78 \\
+\uC @signal@					& 322		& 323	 	& 3.36   \\
+\CFA @signal@, 1 @monitor@		& 352.5		& 353.11	& 3.66   \\
+\CFA @signal@, 2 @monitor@		& 430		& 430.29	& 8.97   \\
+\CFA @signal@, 4 @monitor@		& 594.5		& 606.57	& 18.33  \\
+Java @notify@					& 13831.5	& 15698.21	& 4782.3 \\
 \hline
 \end{tabular}
-\end{center}
-\caption{Internal scheduling comparison.
-All numbers are in nanoseconds(\si{\nano\second})}
-\label{tab:int-sched}
-\end{table}
-
-\subsection{External Scheduling}
-The Internal scheduling benchmark measures the cost of the @waitfor@ statement (@_Accept@ in \uC).
-Figure~\ref{f:ext-sched} shows the code for \CFA, with results in table \ref{tab:ext-sched}.
-As with all other benchmarks, all omitted tests are functionally identical to one of these tests.
+\end{figure}
+
+
+\paragraph{External Scheduling}
+
+External scheduling is measured by accepting a call using the @waitfor@ statement (@_Accept@ in \uC).
+Figure~\ref{f:ext-sched} shows the code for \CFA, with results in Table~\ref{tab:ext-sched}.
+Note, the incremental cost of bulk acquire for \CFA, which is largely a fixed cost for small numbers of mutex objects.
 
 \begin{figure}
-\begin{cfa}[caption={Benchmark code for external scheduling},label={f:ext-sched}]
+\lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}}
+\begin{cfa}
 volatile int go = 0;
-monitor M {};
-M m1;
+monitor M {} m;
 thread T {};
-
-void __attribute__((noinline)) do_call( M & mutex a1 ) {}
-
-void ^?{}( T & mutex this ) {}
-void main( T & this ) {
-	while(go == 0) { yield(); }
-	while(go == 1) { do_call(m1); }
-}
-int  __attribute__((noinline)) do_wait( M & mutex a1 ) {
-	go = 1;
-	BENCH(
-		for(size_t i=0; i<n; i++) {
-			waitfor(call, a1);
-		},
-		result
-	)
-	printf("%llu\n", result);
-	go = 0;
-	return 0;
+void __attribute__((noinline)) do_call( M & mutex ) {}
+void main( T & ) {
+	while ( go == 0 ) { yield(); }	// wait for other thread to start
+	while ( go == 1 ) { @do_call( m );@ }
+}
+int __attribute__((noinline)) do_wait( M & mutex m ) {
+	go = 1;	// continue other thread
+	BENCH( for ( size_t i = 0; i < N; i += 1 ) { @waitfor( do_call, m );@ } )
+	go = 0;	// stop other thread
+	sout | result`ns | endl;
 }
 int main() {
 	T t;
-	return do_wait(m1);
-}
-\end{cfa}
-\end{figure}
-
-\begin{table}
-\begin{center}
-\begin{tabular}{| l | S[table-format=5.2,table-number-alignment=right] | S[table-format=5.2,table-number-alignment=right] | S[table-format=5.2,table-number-alignment=right] |}
+	do_wait( m );
+}
+\end{cfa}
+\captionof{figure}{\CFA external scheduling benchmark}
+\label{f:ext-sched}
+
+\centering
+
+\captionof{table}{External scheduling comparison (nanoseconds)}
+\label{tab:ext-sched}
+\bigskip
+\begin{tabular}{|r|*{3}{D{.}{.}{3.2}|}}
 \cline{2-4}
-\multicolumn{1}{c |}{} & \multicolumn{1}{c |}{ Median } &\multicolumn{1}{c |}{ Average } & \multicolumn{1}{c |}{ Standard Deviation} \\
+\multicolumn{1}{c|}{} & \multicolumn{1}{c|}{Median} &\multicolumn{1}{c|}{Average} & \multicolumn{1}{c|}{Std Dev} \\
 \hline
-\uC @Accept@					& 350		& 350.61	& 3.11  \\
-\CFA @waitfor@, 1 @monitor@	& 358.5	& 358.36	& 3.82  \\
+\uC @_Accept@				& 350		& 350.61	& 3.11  \\
+\CFA @waitfor@, 1 @monitor@	& 358.5		& 358.36	& 3.82  \\
 \CFA @waitfor@, 2 @monitor@	& 422		& 426.79	& 7.95  \\
-\CFA @waitfor@, 4 @monitor@	& 579.5	& 585.46	& 11.25 \\
+\CFA @waitfor@, 4 @monitor@	& 579.5		& 585.46	& 11.25 \\
 \hline
 \end{tabular}
-\end{center}
-\caption{External scheduling comparison.
-All numbers are in nanoseconds(\si{\nano\second})}
-\label{tab:ext-sched}
-\end{table}
-
-
-\subsection{Object Creation}
-Finally, the last benchmark measures the cost of creation for concurrent objects.
-Figure~\ref{f:creation} shows the code for @pthread@s and \CFA threads, with results shown in table \ref{tab:creation}.
-As with all other benchmarks, all omitted tests are functionally identical to one of these tests.
-The only note here is that the call stacks of \CFA coroutines are lazily created, therefore without priming the coroutine, the creation cost is very low.
-
-\begin{figure}
-\begin{center}
-@pthread@
-\begin{cfa}
+
+\bigskip
+\medskip
+
+\lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}}
+\begin{cfa}
+thread MyThread {};
+void main( MyThread & ) {}
 int main() {
-	BENCH(
-		for(size_t i=0; i<n; i++) {
-			pthread_t thread;
-			if(pthread_create(&thread,NULL,foo,NULL)<0) {
-				perror( "failure" );
-				return 1;
-			}
-
-			if(pthread_join(thread, NULL)<0) {
-				perror( "failure" );
-				return 1;
-			}
-		},
-		result
-	)
-	printf("%llu\n", result);
-}
-\end{cfa}
-
-
-
-\CFA Threads
-\begin{cfa}
-int main() {
-	BENCH(
-		for(size_t i=0; i<n; i++) {
-			MyThread m;
-		},
-		result
-	)
-	printf("%llu\n", result);
-}
-\end{cfa}
-\end{center}
-\caption{Benchmark code for \protect\lstinline|pthread|s and \CFA to measure object creation}
+	BENCH( for ( size_t i = 0; i < N; i += 1 ) { @MyThread m;@ } )
+	sout | result`ns | endl;
+}
+\end{cfa}
+\captionof{figure}{\CFA object creation benchmark}
 \label{f:creation}
-\end{figure}
-
-\begin{table}
-\begin{center}
-\begin{tabular}{| l | S[table-format=5.2,table-number-alignment=right] | S[table-format=5.2,table-number-alignment=right] | S[table-format=5.2,table-number-alignment=right] |}
+
+\centering
+
+\captionof{table}{Creation comparison (nanoseconds)}
+\label{tab:creation}
+\bigskip
+
+\begin{tabular}{|r|*{3}{D{.}{.}{5.2}|}}
 \cline{2-4}
-\multicolumn{1}{c |}{} & \multicolumn{1}{c |}{ Median } &\multicolumn{1}{c |}{ Average } & \multicolumn{1}{c |}{ Standard Deviation} \\
+\multicolumn{1}{c|}{} & \multicolumn{1}{c|}{Median} & \multicolumn{1}{c|}{Average} & \multicolumn{1}{c|}{Std Dev} \\
 \hline
-Pthreads			& 26996	& 26984.71	& 156.6  \\
-\CFA Coroutine Lazy	& 6		& 5.71	& 0.45   \\
+Pthreads				& 26996		& 26984.71	& 156.6  \\
+\CFA Coroutine Lazy		& 6			& 5.71		& 0.45   \\
 \CFA Coroutine Eager	& 708		& 706.68	& 4.82   \\
-\CFA Thread			& 1173.5	& 1176.18	& 15.18  \\
-\uC Coroutine		& 109		& 107.46	& 1.74   \\
-\uC Thread			& 526		& 530.89	& 9.73   \\
-Goroutine			& 2520.5	& 2530.93	& 61,56  \\
-Java Thread			& 91114.5	& 92272.79	& 961.58 \\
+\CFA Thread				& 1173.5	& 1176.18	& 15.18  \\
+\uC Coroutine			& 109		& 107.46	& 1.74   \\
+\uC Thread				& 526		& 530.89	& 9.73   \\
+Goroutine				& 2520.5	& 2530.93	& 61.56  \\
+Java Thread				& 91114.5	& 92272.79	& 961.58 \\
 \hline
 \end{tabular}
-\end{center}
-\caption{Creation comparison.
-All numbers are in nanoseconds(\si{\nano\second}).}
-\label{tab:creation}
-\end{table}
-
+\end{figure}
+
+
+\paragraph{Object Creation}
+
+Object creation is measured by creating/deleting the specific kind of concurrent object.
+Figure~\ref{f:creation} shows the code for \CFA, with results in Table~\ref{tab:creation}.
+The only note here is that the call stacks of \CFA coroutines are lazily created, therefore without priming the coroutine to force stack creation, the creation cost is artificially low.
 
 
 \section{Conclusion}
-This paper has achieved a minimal concurrency \textbf{api} that is simple, efficient and usable as the basis for higher-level features.
-The approach presented is based on a lightweight thread-system for parallelism, which sits on top of clusters of processors.
-This M:N model is judged to be both more efficient and allow more flexibility for users.
-Furthermore, this document introduces monitors as the main concurrency tool for users.
-This paper also offers a novel approach allowing multiple monitors to be accessed simultaneously without running into the Nested Monitor Problem~\cite{Lister77}.
-It also offers a full implementation of the concurrency runtime written entirely in \CFA, effectively the largest \CFA code base to date.
-
-
-% ======================================================================
-% ======================================================================
+
+This paper demonstrate a concurrency API that is simple, efficient, and able to build higher-level concurrency features.
+The approach provides concurrency based on a preemptive M:N user-level threading-system, executing in clusters, which encapsulate scheduling of work on multiple kernel threads providing parallelism.
+The M:N model is judged to be efficient and provide greater flexibility than a 1:1 threading model.
+High-level objects (monitor/task) are the core mechanism for mutual exclusion and synchronization.
+A novel aspect is allowing multiple mutex-objects to be accessed simultaneously reducing the potential for deadlock for this complex scenario.
+These concepts and the entire \CFA runtime-system are written in the \CFA language, demonstrating the expressiveness of the \CFA language.
+Performance comparisons with other concurrent systems/languages show the \CFA approach is competitive across all low-level operations, which translates directly into good performance in well-written concurrent applications.
+C programmers should feel comfortable using these mechanisms for developing concurrent applications, with the ability to obtain maximum available performance by mechanisms at the appropriate level.
+
+
 \section{Future Work}
-% ======================================================================
-% ======================================================================
-
-\subsection{Performance} \label{futur:perf}
-This paper presents a first implementation of the \CFA concurrency runtime.
-Therefore, there is still significant work to improve performance.
-Many of the data structures and algorithms may change in the future to more efficient versions.
-For example, the number of monitors in a single bulk acquire is only bound by the stack size, this is probably unnecessarily generous.
-It may be possible that limiting the number helps increase performance.
-However, it is not obvious that the benefit would be significant.
-
-\subsection{Flexible Scheduling} \label{futur:sched}
+
+While concurrency in \CFA has a strong start, development is still underway and there are missing features.
+
+\paragraph{Flexible Scheduling}
+\label{futur:sched}
+
 An important part of concurrency is scheduling.
 Different scheduling algorithms can affect performance (both in terms of average and variation).
 However, no single scheduler is optimal for all workloads and therefore there is value in being able to change the scheduler for given programs.
-One solution is to offer various tweaking options to users, allowing the scheduler to be adjusted to the requirements of the workload.
-However, in order to be truly flexible, it would be interesting to allow users to add arbitrary data and arbitrary scheduling algorithms.
-For example, a web server could attach Type-of-Service information to threads and have a ``ToS aware'' scheduling algorithm tailored to this specific web server.
-This path of flexible schedulers will be explored for \CFA.
-
-\subsection{Non-Blocking I/O} \label{futur:nbio}
-While most of the parallelism tools are aimed at data parallelism and control-flow parallelism, many modern workloads are not bound on computation but on IO operations, a common case being web servers and XaaS (anything as a service).
-These types of workloads often require significant engineering around amortizing costs of blocking IO operations.
-At its core, non-blocking I/O is an operating system level feature that allows queuing IO operations (\eg network operations) and registering for notifications instead of waiting for requests to complete.
-In this context, the role of the language makes Non-Blocking IO easily available and with low overhead.
-The current trend is to use asynchronous programming using tools like callbacks and/or futures and promises, which can be seen in frameworks like Node.js~\cite{NodeJs} for JavaScript, Spring MVC~\cite{SpringMVC} for Java and Django~\cite{Django} for Python.
-However, while these are valid solutions, they lead to code that is harder to read and maintain because it is much less linear.
-
-\subsection{Other Concurrency Tools} \label{futur:tools}
-While monitors offer a flexible and powerful concurrent core for \CFA, other concurrency tools are also necessary for a complete multi-paradigm concurrency package.
-Examples of such tools can include simple locks and condition variables, futures and promises~\cite{promises}, executors and actors.
+One solution is to offer various tweaking options, allowing the scheduler to be adjusted to the requirements of the workload.
+However, to be truly flexible, it is necessary to have a pluggable scheduler.
+Currently, the \CFA pluggable scheduler is too simple to handle complex scheduling, \eg quality of service and real-time, where the scheduler must interact with mutex objects to deal with issues like priority inversion.
+
+\paragraph{Non-Blocking I/O}
+\label{futur:nbio}
+
+Many modern workloads are not bound by computation but IO operations, a common case being web servers and XaaS~\cite{XaaS} (anything as a service).
+These types of workloads require significant engineering to amortizing costs of blocking IO-operations.
+At its core, non-blocking I/O is an operating-system level feature queuing IO operations, \eg network operations, and registering for notifications instead of waiting for requests to complete.
+Current trends use asynchronous programming like callbacks, futures, and/or promises, \eg Node.js~\cite{NodeJs} for JavaScript, Spring MVC~\cite{SpringMVC} for Java, and Django~\cite{Django} for Python.
+However, these solutions lead to code that is hard create, read and maintain.
+A better approach is to tie non-blocking I/O into the concurrency system to provide ease of use with low overhead, \eg thread-per-connection web-services.
+A non-blocking I/O library is currently under development for \CFA.
+
+\paragraph{Other Concurrency Tools}
+\label{futur:tools}
+
+While monitors offer a flexible and powerful concurrent for \CFA, other concurrency tools are also necessary for a complete multi-paradigm concurrency package.
+Examples of such tools can include futures and promises~\cite{promises}, executors and actors.
 These additional features are useful when monitors offer a level of abstraction that is inadequate for certain tasks.
 
-\subsection{Implicit Threading} \label{futur:implcit}
-Simpler applications can benefit greatly from having implicit parallelism.
-That is, parallelism that does not rely on the user to write concurrency.
-This type of parallelism can be achieved both at the language level and at the library level.
-The canonical example of implicit parallelism is parallel for loops, which are the simplest example of a divide and conquer algorithms~\cite{uC++book}.
-Table \ref{f:parfor} shows three different code examples that accomplish point-wise sums of large arrays.
-Note that none of these examples explicitly declare any concurrency or parallelism objects.
-
-\begin{table}
-\begin{center}
-\begin{tabular}[t]{|c|c|c|}
-Sequential & Library Parallel & Language Parallel \\
-\begin{cfa}[tabsize=3]
-void big_sum(
-	int* a, int* b,
-	int* o,
-	size_t len)
-{
-	for(
-		int i = 0;
-		i < len;
-		++i )
-	{
-		o[i]=a[i]+b[i];
-	}
-}
-
-
-
-
-
-int* a[10000];
-int* b[10000];
-int* c[10000];
-//... fill in a & b
-big_sum(a,b,c,10000);
-\end{cfa} &\begin{cfa}[tabsize=3]
-void big_sum(
-	int* a, int* b,
-	int* o,
-	size_t len)
-{
-	range ar(a, a+len);
-	range br(b, b+len);
-	range or(o, o+len);
-	parfor( ai, bi, oi,
-	[](	int* ai,
-		int* bi,
-		int* oi)
-	{
-		oi=ai+bi;
-	});
-}
-
-
-int* a[10000];
-int* b[10000];
-int* c[10000];
-//... fill in a & b
-big_sum(a,b,c,10000);
-\end{cfa}&\begin{cfa}[tabsize=3]
-void big_sum(
-	int* a, int* b,
-	int* o,
-	size_t len)
-{
-	parfor (ai,bi,oi)
-	    in (a, b, o )
-	{
-		oi = ai + bi;
-	}
-}
-
-
-
-
-
-
-
-int* a[10000];
-int* b[10000];
-int* c[10000];
-//... fill in a & b
-big_sum(a,b,c,10000);
-\end{cfa}
-\end{tabular}
-\end{center}
-\caption{For loop to sum numbers: Sequential, using library parallelism and language parallelism.}
-\label{f:parfor}
-\end{table}
-
-Implicit parallelism is a restrictive solution and therefore has its limitations.
-However, it is a quick and simple approach to parallelism, which may very well be sufficient for smaller applications and reduces the amount of boilerplate needed to start benefiting from parallelism in modern CPUs.
-
-
-% A C K N O W L E D G E M E N T S
-% -------------------------------
+\paragraph{Implicit Threading}
+\label{futur:implcit}
+
+Basic concurrent (embarrassingly parallel) applications can benefit greatly from implicit concurrency, where sequential programs are converted to concurrent, possibly with some help from pragmas to guide the conversion.
+This type of concurrency can be achieved both at the language level and at the library level.
+The canonical example of implicit concurrency is concurrent nested @for@ loops, which are amenable to divide and conquer algorithms~\cite{uC++book}.
+The \CFA language features should make it possible to develop a reasonable number of implicit concurrency mechanism to solve basic HPC data-concurrency problems.
+However, implicit concurrency is a restrictive solution and has its limitations, so it can never replace explicit concurrent programming.
+
+
 \section{Acknowledgements}
 
-Thanks to Aaron Moss, Rob Schluntz and Andrew Beach for their work on the \CFA project as well as all the discussions which helped concretize the ideas in this paper.
-Partial funding was supplied by the Natural Sciences and Engineering Research Council of Canada and a corporate partnership with Huawei Ltd.
-
-
-% B I B L I O G R A P H Y
-% -----------------------------
-%\bibliographystyle{plain}
+The authors would like to recognize the design assistance of Aaron Moss, Rob Schluntz and Andrew Beach on the features described in this paper.
+Funding for this project has been provided by Huawei Ltd.\ (\url{http://www.huawei.com}), and Peter Buhr is partially funded by the Natural Sciences and Engineering Research Council of Canada.
+
+{%
+\fontsize{9bp}{12bp}\selectfont%
 \bibliography{pl,local}
-
+}%
 
 \end{document}
Index: doc/papers/concurrency/annex/local.bib
===================================================================
--- doc/papers/concurrency/annex/local.bib	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/papers/concurrency/annex/local.bib	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -46,5 +46,5 @@
     title 	= {Thread Building Blocks},
     howpublished= {Intel, \url{https://www.threadingbuildingblocks.org}},
-    note	= {Accessed: 2018-3},
+    optnote	= {Accessed: 2018-3},
 }
 
Index: doc/papers/concurrency/figures/RunTimeStructure.fig
===================================================================
--- doc/papers/concurrency/figures/RunTimeStructure.fig	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
+++ doc/papers/concurrency/figures/RunTimeStructure.fig	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -0,0 +1,166 @@
+#FIG 3.2  Produced by xfig version 3.2.5c
+Landscape
+Center
+Inches
+Letter  
+100.00
+Single
+-2
+1200 2
+6 3855 2775 4155 2925
+1 3 0 1 0 0 0 0 0 0.000 1 0.0000 3930 2850 30 30 3930 2850 3960 2880
+1 3 0 1 0 0 0 0 0 0.000 1 0.0000 4035 2850 30 30 4035 2850 4065 2880
+-6
+6 4755 3525 5055 3675
+1 3 0 1 0 0 0 0 0 0.000 1 0.0000 4830 3600 30 30 4830 3600 4860 3630
+1 3 0 1 0 0 0 0 0 0.000 1 0.0000 4935 3600 30 30 4935 3600 4965 3630
+-6
+6 4650 2775 4950 2925
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4725 2850 15 15 4725 2850 4740 2865
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4800 2850 15 15 4800 2850 4815 2865
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4875 2850 15 15 4875 2850 4890 2865
+-6
+6 3225 2400 3525 2550
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 3300 2475 15 15 3300 2475 3315 2490
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 3375 2475 15 15 3375 2475 3390 2490
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 3450 2475 15 15 3450 2475 3465 2490
+-6
+6 5475 3450 5625 3750
+1 3 0 1 -1 -1 0 0 20 0.000 1 4.7120 5550 3525 15 15 5550 3525 5535 3540
+1 3 0 1 -1 -1 0 0 20 0.000 1 4.7120 5550 3600 15 15 5550 3600 5535 3615
+1 3 0 1 -1 -1 0 0 20 0.000 1 4.7120 5550 3675 15 15 5550 3675 5535 3690
+-6
+6 4275 3525 4575 3675
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4350 3600 15 15 4350 3600 4365 3615
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4425 3600 15 15 4425 3600 4440 3615
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4500 3600 15 15 4500 3600 4515 3615
+-6
+6 2175 4650 7050 4950
+1 3 0 1 0 0 0 0 0 0.000 1 0.0000 2250 4830 30 30 2250 4830 2280 4860
+1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4200 4800 150 75 4200 4800 4350 4875
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3275 4800 100 100 3275 4800 3375 4800
+2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5
+	 5400 4950 5400 4725 5175 4725 5175 4950 5400 4950
+2 2 1 1 -1 -1 0 0 -1 3.000 0 0 0 0 0 5
+	 6525 4950 6300 4950 6300 4725 6525 4725 6525 4950
+4 0 -1 0 0 0 10 0.0000 2 105 450 6600 4875 cluster\001
+4 0 -1 0 0 0 10 0.0000 2 105 660 5475 4875 processor\001
+4 0 -1 0 0 0 10 0.0000 2 105 555 4425 4875 monitor\001
+4 0 -1 0 0 0 10 0.0000 2 120 270 3450 4875 task\001
+4 0 -1 0 0 0 10 0.0000 2 105 660 2325 4875 coroutine\001
+-6
+6 3450 1275 3750 1425
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 3525 1350 15 15 3525 1350 3540 1365
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 3600 1350 15 15 3600 1350 3615 1365
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 3675 1350 15 15 3675 1350 3690 1365
+-6
+6 5550 1275 5850 1425
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 5625 1350 15 15 5625 1350 5640 1365
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 5700 1350 15 15 5700 1350 5715 1365
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 5775 1350 15 15 5775 1350 5790 1365
+-6
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 5550 2625 150 150 5550 2625 5700 2625
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 5550 3225 150 150 5550 3225 5700 3225
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 5550 3975 150 150 5550 3975 5700 3975
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3525 2850 150 150 3525 2850 3675 2850
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4200 2475 150 150 4200 2475 4350 2475
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4425 2850 150 150 4425 2850 4575 2850
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4650 2475 150 150 4650 2475 4800 2475
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3525 3600 150 150 3525 3600 3675 3600
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3975 3600 150 150 3975 3600 4125 3600
+1 3 0 1 0 0 0 0 0 0.000 1 0.0000 3525 3600 30 30 3525 3600 3555 3630
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3750 2475 150 150 3750 2475 3900 2625
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4875 3600 150 150 4875 3600 5025 3750
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3975 2850 150 150 3975 2850 4125 2850
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 7200 2775 150 150 7200 2775 7350 2775
+1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4650 1350 225 150 4650 1350 4875 1500
+1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 5250 1350 225 150 5250 1350 5475 1500
+1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4050 1350 225 150 4050 1350 4275 1500
+2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5
+	 2400 4200 2400 3750 1950 3750 1950 4200 2400 4200
+2 2 1 1 -1 -1 0 0 -1 4.000 0 0 0 0 0 5
+	 6300 4500 6300 1800 3000 1800 3000 4500 6300 4500
+2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5
+	 5775 2850 5775 2400 5325 2400 5325 2850 5775 2850
+2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5
+	 5775 4200 5775 3750 5325 3750 5325 4200 5775 4200
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 5175 3975 5325 3975
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 5175 3225 5325 3225
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 5175 2625 5325 2625
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 5775 3975 5925 3975
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 5775 3225 5925 3225
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 5775 2625 5925 2625
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
+	 5175 3975 5175 2625
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 5925 3975 5925 2025
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 5925 3750 6225 3750
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 3450 2625 3225 2625
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 3
+	1 1 1.00 45.00 90.00
+	 5925 2025 4200 2025 4200 2250
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
+	 3225 2625 3225 3600
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 3075 3600 3375 3600
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 3675 3600 3825 3600
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 4125 3600 4275 3600
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 4575 3600 4725 3600
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 5025 3600 5175 3600
+2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5
+	 5775 3450 5775 3000 5325 3000 5325 3450 5775 3450
+2 2 1 1 -1 -1 0 0 -1 4.000 0 0 0 0 0 5
+	 8100 4500 8100 1800 6600 1800 6600 4500 8100 4500
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 6675 3975 6975 3975
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 7050 2775 6825 2775
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
+	 6825 2775 6825 3975
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 7125 3975 7350 3975
+2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5
+	 7800 4200 7800 3750 7350 3750 7350 4200 7800 4200
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2
+	1 1 1.00 45.00 90.00
+	 7800 3975 8025 3975
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 4
+	1 1 1.00 45.00 90.00
+	 7875 3975 7875 2325 7200 2325 7200 2550
+4 1 -1 0 0 0 10 0.0000 2 105 720 5550 4425 Processors\001
+4 1 -1 0 0 0 10 0.0000 2 120 1005 4200 3225 Blocked Tasks\001
+4 1 -1 0 0 0 10 0.0000 2 150 870 4200 3975 Ready Tasks\001
+4 1 -1 0 0 0 10 0.0000 2 135 1095 7350 1725 Other Cluster(s)\001
+4 1 -1 0 0 0 10 0.0000 2 105 840 4650 1725 User Cluster\001
+4 1 -1 0 0 0 10 0.0000 2 150 615 2175 3675 Manager\001
+4 1 -1 0 0 0 10 0.0000 2 105 990 2175 3525 Discrete-event\001
+4 1 -1 0 0 0 10 0.0000 2 135 795 2175 4350 preemption\001
Index: doc/papers/concurrency/figures/ext_monitor.fig
===================================================================
--- doc/papers/concurrency/figures/ext_monitor.fig	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/papers/concurrency/figures/ext_monitor.fig	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -8,89 +8,89 @@
 -2
 1200 2
-5 1 0 1 -1 -1 0 0 -1 0.000 0 1 0 0 3150.000 3450.000 3150 3150 2850 3450 3150 3750
-5 1 0 1 -1 -1 0 0 -1 0.000 0 1 0 0 3150.000 4350.000 3150 4050 2850 4350 3150 4650
-6 5850 1950 6150 2250
-1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 6000 2100 105 105 6000 2100 6105 2205
-4 1 -1 0 0 0 10 0.0000 2 105 90 6000 2160 d\001
+5 1 0 1 -1 -1 0 0 -1 0.000 0 1 0 0 1575.000 3450.000 1575 3150 1275 3450 1575 3750
+5 1 0 1 -1 -1 0 0 -1 0.000 0 1 0 0 1575.000 4350.000 1575 4050 1275 4350 1575 4650
+6 4275 1950 4575 2250
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4425 2100 105 105 4425 2100 4530 2205
+4 1 -1 0 0 0 10 0.0000 2 105 90 4425 2160 d\001
 -6
-6 5100 2100 5400 2400
-1 3 0 1 -1 -1 1 0 4 0.000 1 0.0000 5250 2250 105 105 5250 2250 5355 2250
-4 1 -1 0 0 0 10 0.0000 2 105 120 5250 2295 X\001
+6 4275 1650 4575 1950
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4425 1800 105 105 4425 1800 4530 1905
+4 1 -1 0 0 0 10 0.0000 2 105 90 4425 1860 b\001
 -6
-6 5100 1800 5400 2100
-1 3 0 1 -1 -1 1 0 4 0.000 1 0.0000 5250 1950 105 105 5250 1950 5355 1950
-4 1 -1 0 0 0 10 0.0000 2 105 120 5250 2010 Y\001
+6 1495 5445 5700 5655
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 1575 5550 80 80 1575 5550 1655 5630
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 2925 5550 105 105 2925 5550 3030 5655
+1 3 0 1 -1 -1 0 0 4 0.000 1 0.0000 4425 5550 105 105 4425 5550 4530 5655
+4 0 -1 0 0 0 12 0.0000 2 135 1035 3150 5625 blocked task\001
+4 0 -1 0 0 0 12 0.0000 2 135 870 1725 5625 active task\001
+4 0 -1 0 0 0 12 0.0000 2 135 1050 4650 5625 routine mask\001
 -6
-6 5850 1650 6150 1950
-1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 6000 1800 105 105 6000 1800 6105 1905
-4 1 -1 0 0 0 10 0.0000 2 105 90 6000 1860 b\001
+6 3525 1800 3825 2400
+1 3 0 1 -1 -1 1 0 4 0.000 1 0.0000 3675 1950 105 105 3675 1950 3780 1950
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3525 1800 3825 1800 3825 2400 3525 2400 3525 1800
+4 1 4 0 0 0 10 0.0000 2 105 120 3675 2010 Y\001
 -6
-6 3070 5445 7275 5655
-1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 3150 5550 80 80 3150 5550 3230 5630
-1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4500 5550 105 105 4500 5550 4605 5655
-1 3 0 1 -1 -1 0 0 4 0.000 1 0.0000 6000 5550 105 105 6000 5550 6105 5655
-4 0 -1 0 0 0 12 0.0000 2 135 1035 4725 5625 blocked task\001
-4 0 -1 0 0 0 12 0.0000 2 135 870 3300 5625 active task\001
-4 0 -1 0 0 0 12 0.0000 2 135 1050 6225 5625 routine mask\001
+6 3525 2100 3825 2400
+1 3 0 1 -1 -1 1 0 4 0.000 1 0.0000 3675 2250 105 105 3675 2250 3780 2250
+4 1 4 0 0 0 10 0.0000 2 105 120 3675 2295 X\001
 -6
-1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3300 3600 105 105 3300 3600 3405 3705
-1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3600 3600 105 105 3600 3600 3705 3705
-1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 6600 3900 105 105 6600 3900 6705 4005
-1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 6900 3900 105 105 6900 3900 7005 4005
-1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 6000 2700 105 105 6000 2700 6105 2805
-1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 6000 2400 105 105 6000 2400 6105 2505
-1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 5100 4575 80 80 5100 4575 5180 4655
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 1725 3600 105 105 1725 3600 1830 3705
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 2025 3600 105 105 2025 3600 2130 3705
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 5025 3900 105 105 5025 3900 5130 4005
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 5325 3900 105 105 5325 3900 5430 4005
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4425 2700 105 105 4425 2700 4530 2805
+1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4425 2400 105 105 4425 2400 4530 2505
+1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 3525 4575 80 80 3525 4575 3605 4655
 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 4050 2925 5475 2925 5475 3225 4050 3225 4050 2925
+	 2475 2925 3900 2925 3900 3225 2475 3225 2475 2925
 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 4
-	 3150 3750 3750 3750 3750 4050 3150 4050
+	 1575 3750 2175 3750 2175 4050 1575 4050
 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
-	 3150 3450 3750 3450 3900 3675
+	 1575 3450 2175 3450 2325 3675
 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
-	 3750 3150 3600 3375
+	 2175 3150 2025 3375
 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 3
-	 3150 4350 3750 4350 3900 4575
+	 1575 4350 2175 4350 2325 4575
 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
-	 3750 4050 3600 4275
+	 2175 4050 2025 4275
 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 4
-	 3150 4650 3750 4650 3750 4950 4950 4950
+	 1575 4650 2175 4650 2175 4950 3375 4950
 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
-	 6450 3750 6300 3975
+	 4875 3750 4725 3975
 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2
-	 4950 4950 5175 5100
+	 3375 4950 3600 5100
 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 9
-	 5250 4950 6450 4950 6450 4050 7050 4050 7050 3750 6450 3750
-	 6450 2850 6150 2850 6150 1650
+	 3675 4950 4875 4950 4875 4050 5475 4050 5475 3750 4875 3750
+	 4875 2850 4575 2850 4575 1650
 2 2 1 1 -1 -1 0 0 -1 4.000 0 0 0 0 0 5
-	 5850 4200 5850 3300 4350 3300 4350 4200 5850 4200
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2
+	 4275 4200 4275 3300 2775 3300 2775 4200 4275 4200
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
 	1 1 1.00 60.00 120.00
-	7 1 1.00 60.00 120.00
-	 5250 3150 5250 2400
+	 3675 3075 3675 2400
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+	 4125 2850 4575 3000
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 3150 3150 3750 3150 3750 2850 5700 2850 5700 1650
-2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
-	 5700 2850 6150 3000
-2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
-	 5100 1800 5400 1800 5400 2400 5100 2400 5100 1800
-4 1 -1 0 0 0 10 0.0000 2 75 75 6000 2745 a\001
-4 1 -1 0 0 0 10 0.0000 2 75 75 6000 2445 c\001
-4 1 -1 0 0 0 12 0.0000 2 135 315 5100 5325 exit\001
-4 1 -1 0 0 0 12 0.0000 2 135 135 3300 3075 A\001
-4 1 -1 0 0 0 12 0.0000 2 135 795 3300 4875 condition\001
-4 1 -1 0 0 0 12 0.0000 2 135 135 3300 5100 B\001
-4 0 -1 0 0 0 12 0.0000 2 135 420 6600 3675 stack\001
-4 0 -1 0 0 0 12 0.0000 2 180 750 6600 3225 acceptor/\001
-4 0 -1 0 0 0 12 0.0000 2 180 750 6600 3450 signalled\001
-4 1 -1 0 0 0 12 0.0000 2 135 795 3300 2850 condition\001
-4 1 -1 0 0 0 12 0.0000 2 165 420 6000 1350 entry\001
-4 1 -1 0 0 0 12 0.0000 2 135 495 6000 1575 queue\001
-4 0 -1 0 0 0 12 0.0000 2 135 525 6300 2400 arrival\001
-4 0 -1 0 0 0 12 0.0000 2 135 630 6300 2175 order of\001
-4 1 -1 0 0 0 12 0.0000 2 135 525 5100 3675 shared\001
-4 1 -1 0 0 0 12 0.0000 2 135 735 5100 3975 variables\001
-4 0 0 50 -1 0 11 0.0000 2 165 855 4275 3150 Acceptables\001
-4 0 0 50 -1 0 11 0.0000 2 120 165 5775 2700 W\001
-4 0 0 50 -1 0 11 0.0000 2 120 135 5775 2400 X\001
-4 0 0 50 -1 0 11 0.0000 2 120 105 5775 2100 Z\001
-4 0 0 50 -1 0 11 0.0000 2 120 135 5775 1800 Y\001
+	 1575 3150 2175 3150 2175 2850 4125 2850 4125 1650
+4 1 -1 0 0 0 10 0.0000 2 75 75 4425 2745 a\001
+4 1 -1 0 0 0 10 0.0000 2 75 75 4425 2445 c\001
+4 1 -1 0 0 0 12 0.0000 2 135 315 3525 5325 exit\001
+4 1 -1 0 0 0 12 0.0000 2 135 135 1725 3075 A\001
+4 1 -1 0 0 0 12 0.0000 2 135 795 1725 4875 condition\001
+4 1 -1 0 0 0 12 0.0000 2 135 135 1725 5100 B\001
+4 0 -1 0 0 0 12 0.0000 2 135 420 5025 3675 stack\001
+4 0 -1 0 0 0 12 0.0000 2 180 750 5025 3225 acceptor/\001
+4 0 -1 0 0 0 12 0.0000 2 180 750 5025 3450 signalled\001
+4 1 -1 0 0 0 12 0.0000 2 135 795 1725 2850 condition\001
+4 1 -1 0 0 0 12 0.0000 2 165 420 4425 1350 entry\001
+4 1 -1 0 0 0 12 0.0000 2 135 495 4425 1575 queue\001
+4 0 -1 0 0 0 12 0.0000 2 135 525 4725 2400 arrival\001
+4 0 -1 0 0 0 12 0.0000 2 135 630 4725 2175 order of\001
+4 1 -1 0 0 0 12 0.0000 2 135 525 3525 3675 shared\001
+4 1 -1 0 0 0 12 0.0000 2 135 735 3525 3975 variables\001
+4 0 4 50 -1 0 11 0.0000 2 120 135 4150 1875 Y\001
+4 0 4 50 -1 0 11 0.0000 2 120 105 4150 2175 Z\001
+4 0 4 50 -1 0 11 0.0000 2 120 135 4150 2475 X\001
+4 0 4 50 -1 0 11 0.0000 2 120 165 4150 2775 W\001
+4 0 -1 0 0 3 12 0.0000 2 150 540 5025 4275 urgent\001
+4 1 0 50 -1 0 11 0.0000 2 165 600 3150 3150 accepted\001
Index: doc/papers/concurrency/figures/monitor.fig
===================================================================
--- doc/papers/concurrency/figures/monitor.fig	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/papers/concurrency/figures/monitor.fig	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -72,6 +72,4 @@
 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 4
 	 3600 1500 3600 2100 4200 2100 4200 900
-2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 4
-	 2700 1500 2700 2100 3300 2100 3300 1500
 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 9
 	 3600 4200 4800 4200 4800 3300 5400 3300 5400 3000 4800 3000
@@ -79,4 +77,6 @@
 2 2 1 1 -1 -1 0 0 -1 4.000 0 0 0 0 0 5
 	 4200 3450 4200 2550 2700 2550 2700 3450 4200 3450
+2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 4
+	 2700 1500 2700 2100 3300 2100 3300 1500
 4 1 -1 0 0 0 10 0.0000 2 75 75 4350 1995 a\001
 4 1 -1 0 0 0 10 0.0000 2 75 75 4350 1695 c\001
@@ -89,6 +89,6 @@
 4 0 -1 0 0 0 12 0.0000 2 180 750 4950 2700 signalled\001
 4 1 -1 0 0 0 12 0.0000 2 135 795 1650 2100 condition\001
-4 1 -1 0 0 0 12 0.0000 2 135 135 2550 1425 X\001
-4 1 -1 0 0 0 12 0.0000 2 135 135 3450 1425 Y\001
+4 1 4 0 0 0 12 0.0000 2 135 135 2550 1425 X\001
+4 1 4 0 0 0 12 0.0000 2 135 135 3450 1425 Y\001
 4 1 -1 0 0 0 12 0.0000 2 165 420 4350 600 entry\001
 4 1 -1 0 0 0 12 0.0000 2 135 495 4350 825 queue\001
@@ -100,2 +100,3 @@
 4 1 -1 0 0 0 10 0.0000 2 75 75 3450 1995 c\001
 4 1 -1 0 0 0 12 0.0000 2 135 570 3000 1200 queues\001
+4 0 -1 0 0 3 12 0.0000 2 150 540 4950 3525 urgent\001
Index: c/papers/concurrency/style/cfa-format.tex
===================================================================
--- doc/papers/concurrency/style/cfa-format.tex	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ 	(revision )
@@ -1,282 +1,0 @@
-%\usepackage[usenames,dvipsnames]{xcolor}
-\usepackage{listings}
-\usepackage{inconsolata}
-
-\definecolor{basicCol}{HTML}{000000}
-\definecolor{commentCol}{HTML}{000000}
-\definecolor{stringCol}{HTML}{000000}
-\definecolor{keywordCol}{HTML}{000000}
-\definecolor{identifierCol}{HTML}{000000}
-
-% from https://gist.github.com/nikolajquorning/92bbbeef32e1dd80105c9bf2daceb89a
-\lstdefinelanguage{sml} {
-	morekeywords= {
-		EQUAL, GREATER, LESS, NONE, SOME, abstraction, abstype, and, andalso, array, as, before,
-		bool, case, char, datatype, do, else, end, eqtype, exception, exn, false, fn, fun, functor,
-		handle, if, in, include, infix, infixr, int, let, list, local, nil, nonfix, not, o, of, op,
-		open, option, orelse, overload, print, raise, real, rec, ref, sharing, sig, signature,
-		string, struct, structure, substring, then, true, type, unit, val, vector, where, while,
-		with, withtype, word
-    },
-    morestring=[b]",
-    morecomment=[s]{(*}{*)},
-}
-
-\lstdefinelanguage{D}{
-	% Keywords
-	morekeywords=[1]{
-		abstract, alias, align, auto, body, break, cast, catch, class, const, continue, debug,
-		delegate, delete, deprecated, do, else, enum, export, false, final, finally, for, foreach,
-		foreach_reverse, function, goto, if, immutable, import, in, inout, interface, invariant, is,
-		lazy, macro, mixin, module, new, nothrow, null, out, override, package, pragma, private,
-		protected, public, pure, ref, return, shared, static, struct, super, switch, synchronized,
-		template, this, throw, true, try, typedef, typeid, typeof, union, unittest, volatile, while,
-		with
-	},
-	% Special identifiers, common functions
-	morekeywords=[2]{enforce},
-	% Ugly identifiers
-	morekeywords=[3]{
-		__DATE__, __EOF__, __FILE__, __LINE__, __TIMESTAMP__, __TIME__, __VENDOR__,
-		__VERSION__, __ctfe, __gshared, __monitor, __thread, __vptr, _argptr,
-		_arguments, _ctor, _dtor
-	},
-	% Basic types
-	morekeywords=[4]{
-		byte, ubyte, short, ushort, int, uint, long, ulong, cent, ucent, void, bool, bit, float,
-		double, real, ushort, int, uint, long, ulong, float, char, wchar, dchar, string, wstring,
-		dstring, ireal, ifloat, idouble, creal, cfloat, cdouble, size_t, ptrdiff_t, sizediff_t,
-		equals_t, hash_t
-	},
-	% Strings
-	morestring=[b]{"},
-	morestring=[b]{'},
-	morestring=[b]{`},
-	% Comments
-	comment=[l]{//},
-	morecomment=[s]{/*}{*/},
-	morecomment=[s][\color{blue}]{/**}{*/},
-	morecomment=[n]{/+}{+/},
-	morecomment=[n][\color{blue}]{/++}{+/},
-	% Options
-	sensitive=true
-}
-
-\lstdefinelanguage{rust}{
-	% Keywords
-	morekeywords=[1]{
-		abstract, alignof, as, become, box, break, const, continue, crate, do, else, enum, extern,
-		false, final, fn, for, if, impl, in, let, loop, macro, match, mod, move, mut, offsetof,
-		override, priv, proc, pub, pure, ref, return, Self, self, sizeof, static, struct, super,
-		trait, true, type, typeof, unsafe, unsized, use, virtual, where, while, yield
-	},
-	% Strings
-	morestring=[b]{"},
-	% Comments
-	comment=[l]{//},
-	morecomment=[s]{/*}{*/},
-	% Options
-	sensitive=true
-}
-
-\lstdefinelanguage{pseudo}{
-	morekeywords={string,uint,int,bool,float},
-	sensitive=true,
-	morecomment=[l]{//},
-	morecomment=[s]{/*}{*/},
-	morestring=[b]',
-	morestring=[b]",
-	morestring=[s]{`}{`},
-}
-
-\newcommand{\KWC}{K-W C\xspace}
-
-\lstdefinestyle{pseudoStyle}{
-	escapeinside={@@},
-	basicstyle=\linespread{0.9}\sf\footnotesize,		% reduce line spacing and use typewriter font
-	keywordstyle=\bfseries\color{blue},
-	keywordstyle=[2]\bfseries\color{Plum},
-	commentstyle=\itshape\color{OliveGreen},		    % green and italic comments
-	identifierstyle=\color{identifierCol},
-	stringstyle=\sf\color{Mahogany},					  % use sanserif font
-	mathescape=true,
-	columns=fixed,
-	aboveskip=4pt,								  % spacing above/below code block
-	belowskip=3pt,
-	keepspaces=true,
-	tabsize=4,
-	% frame=lines,
-	literate=,
-	showlines=true,								 % show blank lines at end of code
-	showspaces=false,
-	showstringspaces=false,
-	escapechar=\$,
-	xleftmargin=\parindentlnth,				     % indent code to paragraph indentation
-	moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
-	% moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
-	% moredelim=** allows cumulative application
-}
-
-\lstdefinestyle{defaultStyle}{
-	escapeinside={@@},
-	basicstyle=\linespread{0.9}\tt\footnotesize,		% reduce line spacing and use typewriter font
-	keywordstyle=\bfseries\color{blue},
-	keywordstyle=[2]\bfseries\color{Plum},
-	commentstyle=\itshape\color{OliveGreen},		    % green and italic comments
-	identifierstyle=\color{identifierCol},
-	stringstyle=\sf\color{Mahogany},					  % use sanserif font
-	mathescape=true,
-	columns=fixed,
-	aboveskip=4pt,								  % spacing above/below code block
-	belowskip=3pt,
-	keepspaces=true,
-	tabsize=4,
-	% frame=lines,
-	literate=,
-	showlines=true,								 % show blank lines at end of code
-	showspaces=false,
-	showstringspaces=false,
-	escapechar=\$,
-	xleftmargin=\parindentlnth,				     % indent code to paragraph indentation
-	moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
-	% moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
-	% moredelim=** allows cumulative application
-}
-
-\lstdefinestyle{cfaStyle}{
-	escapeinside={@@},
-	basicstyle=\linespread{0.9}\sf,		% reduce line spacing and use typewriter font
-%  keywordstyle=\bfseries\color{blue},
-	keywordstyle=[2]\bfseries\color{red},
-%  commentstyle=\sf\itshape\color{OliveGreen},		  % green and italic comments
-	identifierstyle=\color{identifierCol},
-%  stringstyle=\sf\color{Mahogany},					  % use sanserif font
-	stringstyle=\tt,										% use typewriter font
-	mathescape=true,
-	columns=fixed,
-	aboveskip=4pt,								  % spacing above/below code block
-	belowskip=3pt,
-	keepspaces=true,
-	tabsize=4,
-	% frame=lines,
-	literate=,
-	showlines=true,								 % show blank lines at end of code
-	showspaces=false,
-	showstringspaces=false,
-	escapechar=\$,
-	xleftmargin=\parindentlnth,				     % indent code to paragraph indentation
-	moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
-	morekeywords=[2]{accept, signal, signal_block, wait, waitfor},
-}
-
-\lstMakeShortInline[basewidth=0.5em,breaklines=true,basicstyle=\normalsize\ttfamily\color{basicCol}]@  % single-character for \lstinline
-
-\lstnewenvironment{ccode}[1][]{
-	\lstset{
-		language = C,
-		style=defaultStyle,
-		captionpos=b,
-		#1
-	}
-}{}
-
-\lstnewenvironment{cfacode}[1][]{
-	\lstset{
-		language = CFA,
-		style=cfaStyle,
-		captionpos=b,
-		#1
-	}
-}{}
-
-\lstnewenvironment{pseudo}[1][]{
-	\lstset{
-		language = pseudo,
-		style=pseudoStyle,
-		captionpos=b,
-		#1
-	}
-}{}
-
-\lstnewenvironment{cppcode}[1][]{
-	\lstset{
-		language = c++,
-		style=defaultStyle,
-		captionpos=b,
-		#1
-	}
-}{}
-
-\lstnewenvironment{ucppcode}[1][]{
-	\lstset{
-		language = c++,
-		style=defaultStyle,
-		captionpos=b,
-		#1
-	}
-}{}
-
-\lstnewenvironment{javacode}[1][]{
-	\lstset{
-		language = java,
-		style=defaultStyle,
-		captionpos=b,
-		#1
-	}
-}{}
-
-\lstnewenvironment{scalacode}[1][]{
-	\lstset{
-		language = scala,
-		style=defaultStyle,
-		captionpos=b,
-		#1
-	}
-}{}
-
-\lstnewenvironment{smlcode}[1][]{
-	\lstset{
-		language = sml,
-		style=defaultStyle,
-		captionpos=b,
-		#1
-	}
-}{}
-
-\lstnewenvironment{dcode}[1][]{
-	\lstset{
-		language = D,
-		style=defaultStyle,
-		captionpos=b,
-		#1
-	}
-}{}
-
-\lstnewenvironment{rustcode}[1][]{
-	\lstset{
-		language = rust,
-		style=defaultStyle,
-		captionpos=b,
-		#1
-	}
-}{}
-
-\lstnewenvironment{gocode}[1][]{
-	\lstset{
-		language = Golang,
-		style=defaultStyle,
-		captionpos=b,
-		#1
-	}
-}{}
-
-\newcommand{\zero}{\lstinline{zero_t}\xspace}
-\newcommand{\one}{\lstinline{one_t}\xspace}
-\newcommand{\ateq}{\lstinline{\@=}\xspace}
-\newcommand{\code}[1]{\lstinline[language=CFA,style=cfaStyle]{#1}}
-\newcommand{\pscode}[1]{\lstinline[language=pseudo,style=pseudoStyle]{#1}}
-
-% Local Variables: %
-% tab-width: 4 %
-% fill-column: 100 %
-% End: %
Index: c/papers/concurrency/style/style.tex
===================================================================
--- doc/papers/concurrency/style/style.tex	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ 	(revision )
@@ -1,12 +1,0 @@
-\input{common}                                          % bespoke macros used in the document
-\input{cfa-format}
-
-% \CFADefaultStyle
-
-% \lstset{
-% morekeywords=[2]{nomutex,mutex,thread,wait,wait_release,signal,signal_block,accept,monitor,suspend,resume,coroutine},
-% keywordstyle=[2]\color{blue},				% second set of keywords for concurency
-% basicstyle=\linespread{0.9}\tt\small,		% reduce line spacing and use typewriter font
-% stringstyle=\sf\color{Mahogany},			% use sanserif font
-% commentstyle=\itshape\color{OliveGreen},		% green and italic comments
-% }%
Index: doc/papers/general/Makefile
===================================================================
--- doc/papers/general/Makefile	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/papers/general/Makefile	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -59,6 +59,6 @@
 	dvips ${Build}/$< -o $@
 
-${BASE}.dvi : Makefile ${Build} ${BASE}.out.ps WileyNJD-AMA.bst ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
-		../../bibliography/pl.bib
+${BASE}.dvi : Makefile ${BASE}.out.ps WileyNJD-AMA.bst ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
+		../../bibliography/pl.bib | ${Build}
 	# Must have *.aux file containing citations for bibtex
 	if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi
@@ -75,5 +75,5 @@
 	mkdir -p ${Build}
 
-${BASE}.out.ps : ${Build}
+${BASE}.out.ps : | ${Build}
 	ln -fs ${Build}/Paper.out.ps .
 
@@ -84,11 +84,11 @@
 	gnuplot -e Build="'${Build}/'" evaluation/timing.gp
 
-%.tex : %.fig ${Build}
+%.tex : %.fig | ${Build}
 	fig2dev -L eepic $< > ${Build}/$@
 
-%.ps : %.fig ${Build}
+%.ps : %.fig | ${Build}
 	fig2dev -L ps $< > ${Build}/$@
 
-%.pstex : %.fig ${Build}
+%.pstex : %.fig | ${Build}
 	fig2dev -L pstex $< > ${Build}/$@
 	fig2dev -L pstex_t -p ${Build}/$@ $< > ${Build}/$@_t
Index: doc/proposals/ctordtor/Makefile
===================================================================
--- doc/proposals/ctordtor/Makefile	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/proposals/ctordtor/Makefile	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -1,10 +1,15 @@
-## Define the appropriate configuration variables.
+## Define the configuration variables.
 
-MACROS = ../../LaTeXmacros
-BIB = ../../bibliography
+Build = build
+Figures = figures
+Macros = ../../LaTeXmacros
+Bib = ../../bibliography
 
-TeXLIB = .:$(MACROS):$(MACROS)/listings:$(MACROS)/enumitem:$(BIB)/:
-LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error
+TeXLIB = .:${Macros}:${MACROS}/listings:${MACROS}/enumitem:${Bib}/:
+LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error -output-directory=${Build}
 BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex
+
+MAKEFLAGS = --no-print-directory # --silent
+VPATH = ${Build} ${Figures}
 
 ## Define the text source files.
@@ -29,33 +34,36 @@
 
 DOCUMENT = ctor.pdf
+BASE = ${basename ${DOCUMENT}}
 
 # Directives #
+
+.PHONY : all clean					# not file names
 
 all : ${DOCUMENT}
 
 clean :
-	rm -f *.bbl *.aux *.dvi *.idx *.ilg *.ind *.brf *.out *.log *.toc *.blg *.pstex_t *.cf \
-		${FIGURES} ${PICTURES} ${PROGRAMS} ${GRAPHS} ${basename ${DOCUMENT}}.ps ${DOCUMENT}
+	@rm -frv ${DOCUMENT} ${BASE}.ps ${Build}
 
 # File Dependencies #
 
-${DOCUMENT} : ${basename ${DOCUMENT}}.ps
+${DOCUMENT} : ${BASE}.ps
 	ps2pdf $<
 
-${basename ${DOCUMENT}}.ps : ${basename ${DOCUMENT}}.dvi
-	dvips $< -o $@
+${BASE}.ps : ${BASE}.dvi
+	dvips ${Build}/$< -o $@
 
-${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \
-		$(MACROS)/common.tex $(MACROS)/indexstyle $(BIB)/cfa.bib
+${BASE}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
+		${Macros}/common.tex ${Macros}/indexstyle ${Bib}/pl.bib | ${Build}
 	# Conditionally create an empty *.ind (index) file for inclusion until makeindex is run.
-	if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi
+	#if [ ! -r ${basename $@}.ind ] ; then touch ${Build}/${basename $@}.ind ; fi
 	# Must have *.aux file containing citations for bibtex
 	if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi
-	-${BibTeX} ${basename $@}
-	# Some citations reference others so run steps again to resolve these citations
+	-${BibTeX} ${Build}/${basename $@}
+	# Some citations reference others so run again to resolve these citations
 	${LaTeX} ${basename $@}.tex
-	-${BibTeX} ${basename $@}
+	-${BibTeX} ${Build}/${basename $@}
 	# Make index from *.aux entries and input index at end of document
-	makeindex -s $(MACROS)/indexstyle ${basename $@}.idx
+	#makeindex -s ${Macros}/indexstyle ${Build}/${basename $@}.idx
+	# Run again to finish citations
 	${LaTeX} ${basename $@}.tex
 	# Run again to get index title into table of contents
@@ -67,13 +75,16 @@
 ## Define the default recipes.
 
-%.tex : %.fig
-	fig2dev -L eepic $< > $@
+${Build}:
+	mkdir -p ${Build}
 
-%.ps : %.fig
-	fig2dev -L ps $< > $@
+%.tex : %.fig | ${Build}
+	fig2dev -L eepic $< > ${Build}/$@
 
-%.pstex : %.fig
-	fig2dev -L pstex $< > $@
-	fig2dev -L pstex_t -p $@ $< > $@_t
+%.ps : %.fig | ${Build}
+	fig2dev -L ps $< > ${Build}/$@
+
+%.pstex : %.fig | ${Build}
+	fig2dev -L pstex $< > ${Build}/$@
+	fig2dev -L pstex_t -p ${Build}/$@ $< > ${Build}/$@_t
 
 # Local Variables: #
Index: doc/proposals/ctordtor/ctor.tex
===================================================================
--- doc/proposals/ctordtor/ctor.tex	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/proposals/ctordtor/ctor.tex	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -1,10 +1,2 @@
-% 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)
-
 \documentclass[twoside,11pt]{article}
 
@@ -15,13 +7,14 @@
 \usepackage{textcomp}
 \usepackage[latin1]{inputenc}
+
 \usepackage{fullpage,times,comment}
 \usepackage{epic,eepic}
-\usepackage{upquote}									% switch curled `'" to straight
+\usepackage{upquote}					% switch curled `'" to straight
 \usepackage{calc}
 \usepackage{xspace}
 \usepackage{graphicx}
-\usepackage{varioref}									% extended references
-\usepackage{listings}									% format program code
-\usepackage[flushmargin]{footmisc}						% support label/reference in footnote
+\usepackage{varioref}					% extended references
+\usepackage{listings}					% format program code
+\usepackage[flushmargin]{footmisc}			% support label/reference in footnote
 \usepackage{latexsym}                                   % \Box glyph
 \usepackage{mathptmx}                                   % better math font with "times"
@@ -34,5 +27,5 @@
 \renewcommand{\UrlFont}{\small\sf}
 
-\setlength{\topmargin}{-0.45in}							% move running title into header
+\setlength{\topmargin}{-0.45in}				% move running title into header
 \setlength{\headsep}{0.25in}
 
@@ -43,4 +36,14 @@
 
 \interfootnotelinepenalty=10000
+
+\CFAStyle						% use default CFA format-style
+% 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)
+
 
 \title{
@@ -83,5 +86,4 @@
 \thispagestyle{plain}
 \pagenumbering{arabic}
-
 
 
Index: doc/proposals/tuples/Makefile
===================================================================
--- doc/proposals/tuples/Makefile	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/proposals/tuples/Makefile	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -1,10 +1,15 @@
-## Define the appropriate configuration variables.
+## Define the configuration variables.
 
-MACROS = ../../LaTeXmacros
-BIB = ../../bibliography
+Build = build
+Figures = figures
+Macros = ../../LaTeXmacros
+Bib = ../../bibliography
 
-TeXLIB = .:$(MACROS):$(MACROS)/listings:$(MACROS)/enumitem:$(BIB)/:
-LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error
+TeXLIB = .:${Macros}:${MACROS}/listings:${MACROS}/enumitem:${Bib}/:
+LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error -output-directory=${Build}
 BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex
+
+MAKEFLAGS = --no-print-directory --silent #
+VPATH = ${Build} ${Figures}
 
 ## Define the text source files.
@@ -29,33 +34,36 @@
 
 DOCUMENT = tuples.pdf
+BASE = ${basename ${DOCUMENT}}
 
 # Directives #
+
+.PHONY : all clean					# not file names
 
 all : ${DOCUMENT}
 
 clean :
-	rm -f *.bbl *.aux *.dvi *.idx *.ilg *.ind *.brf *.out *.log *.toc *.blg *.pstex_t *.cf \
-		${FIGURES} ${PICTURES} ${PROGRAMS} ${GRAPHS} ${basename ${DOCUMENT}}.ps ${DOCUMENT}
+	@rm -frv ${DOCUMENT} ${BASE}.ps ${Build}
 
 # File Dependencies #
 
-${DOCUMENT} : ${basename ${DOCUMENT}}.ps
+${DOCUMENT} : ${BASE}.ps
 	ps2pdf $<
 
-${basename ${DOCUMENT}}.ps : ${basename ${DOCUMENT}}.dvi
-	dvips $< -o $@
+${BASE}.ps : ${BASE}.dvi
+	dvips ${Build}/$< -o $@
 
-${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \
-		$(MACROS)/common.tex $(MACROS)/indexstyle $(BIB)/cfa.bib
+${BASE}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
+		${Macros}/common.tex ${Macros}/indexstyle ${Bib}/pl.bib | ${Build}
 	# Conditionally create an empty *.ind (index) file for inclusion until makeindex is run.
-	if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi
+	#if [ ! -r ${basename $@}.ind ] ; then touch ${Build}/${basename $@}.ind ; fi
 	# Must have *.aux file containing citations for bibtex
 	if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi
-	-${BibTeX} ${basename $@}
-	# Some citations reference others so run steps again to resolve these citations
+	-${BibTeX} ${Build}/${basename $@}
+	# Some citations reference others so run again to resolve these citations
 	${LaTeX} ${basename $@}.tex
-	-${BibTeX} ${basename $@}
+	-${BibTeX} ${Build}/${basename $@}
 	# Make index from *.aux entries and input index at end of document
-	makeindex -s $(MACROS)/indexstyle ${basename $@}.idx
+	#makeindex -s ${Macros}/indexstyle ${Build}/${basename $@}.idx
+	# Run again to finish citations
 	${LaTeX} ${basename $@}.tex
 	# Run again to get index title into table of contents
@@ -67,13 +75,16 @@
 ## Define the default recipes.
 
-%.tex : %.fig
-	fig2dev -L eepic $< > $@
+${Build}:
+	mkdir -p ${Build}
 
-%.ps : %.fig
-	fig2dev -L ps $< > $@
+%.tex : %.fig | ${Build}
+	fig2dev -L eepic $< > ${Build}/$@
 
-%.pstex : %.fig
-	fig2dev -L pstex $< > $@
-	fig2dev -L pstex_t -p $@ $< > $@_t
+%.ps : %.fig | ${Build}
+	fig2dev -L ps $< > ${Build}/$@
+
+%.pstex : %.fig | ${Build}
+	fig2dev -L pstex $< > ${Build}/$@
+	fig2dev -L pstex_t -p ${Build}/$@ $< > ${Build}/$@_t
 
 # Local Variables: #
Index: doc/proposals/tuples/tuples.tex
===================================================================
--- doc/proposals/tuples/tuples.tex	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/proposals/tuples/tuples.tex	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -1,10 +1,2 @@
-% 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)
-
 \documentclass[twoside,11pt]{article}
 
@@ -15,13 +7,14 @@
 \usepackage{textcomp}
 \usepackage[latin1]{inputenc}
+
 \usepackage{fullpage,times,comment}
 \usepackage{epic,eepic}
-\usepackage{upquote}									% switch curled `'" to straight
+\usepackage{upquote}					% switch curled `'" to straight
 \usepackage{calc}
 \usepackage{xspace}
 \usepackage{graphicx}
-\usepackage{varioref}									% extended references
-\usepackage{listings}									% format program code
-\usepackage[flushmargin]{footmisc}						% support label/reference in footnote
+\usepackage{varioref}					% extended references
+\usepackage{listings}					% format program code
+\usepackage[flushmargin]{footmisc}			% support label/reference in footnote
 \usepackage{latexsym}                                   % \Box glyph
 \usepackage{mathptmx}                                   % better math font with "times"
@@ -34,5 +27,5 @@
 \renewcommand{\UrlFont}{\small\sf}
 
-\setlength{\topmargin}{-0.45in}							% move running title into header
+\setlength{\topmargin}{-0.45in}				% move running title into header
 \setlength{\headsep}{0.25in}
 
@@ -42,4 +35,14 @@
 
 \interfootnotelinepenalty=10000
+
+\CFAStyle						% use default CFA format-style
+% 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)
+
 
 \title{
Index: doc/refrat/Makefile
===================================================================
--- doc/refrat/Makefile	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/refrat/Makefile	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -53,6 +53,6 @@
 	dvips ${Build}/$< -o $@
 
-${BASE}.dvi : Makefile ${Build} ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
-		${Macros}/common.tex ${Macros}/lstlang.sty ${Macros}/indexstyle ../bibliography/pl.bib
+${BASE}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
+		${Macros}/common.tex ${Macros}/lstlang.sty ${Macros}/indexstyle ../bibliography/pl.bib | ${Build}
 	# Conditionally create an empty *.ind (index) file for inclusion until makeindex is run.
 	if [ ! -r ${basename $@}.ind ] ; then touch ${Build}/${basename $@}.ind ; fi
@@ -78,11 +78,11 @@
 	mkdir -p ${Build}
 
-%.tex : %.fig ${Build}
+%.tex : %.fig | ${Build}
 	fig2dev -L eepic $< > ${Build}/$@
 
-%.ps : %.fig ${Build}
+%.ps : %.fig | ${Build}
 	fig2dev -L ps $< > ${Build}/$@
 
-%.pstex : %.fig ${Build}
+%.pstex : %.fig | ${Build}
 	fig2dev -L pstex $< > ${Build}/$@
 	fig2dev -L pstex_t -p ${Build}/$@ $< > ${Build}/$@_t
Index: doc/theses/aaron_moss/comp_II/Makefile
===================================================================
--- doc/theses/aaron_moss/comp_II/Makefile	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/theses/aaron_moss/comp_II/Makefile	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -32,4 +32,5 @@
 
 DOCUMENT = comp_II.pdf
+BASE = ${basename ${DOCUMENT}}
 
 # Directives #
@@ -40,16 +41,16 @@
 
 clean :
-	@rm -frv ${DOCUMENT} ${basename ${DOCUMENT}}.ps ${Build}
+	@rm -frv ${DOCUMENT} ${BASE}.ps ${Build}
 
 # File Dependencies #
 
-${DOCUMENT} : ${basename ${DOCUMENT}}.ps
+${DOCUMENT} : ${BASE}.ps
 	ps2pdf $<
 
-${basename ${DOCUMENT}}.ps : ${basename ${DOCUMENT}}.dvi
+${BASE}.ps : ${BASE}.dvi
 	dvips ${Build}/$< -o $@
 
-${basename ${DOCUMENT}}.dvi : Makefile ${Build} ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
-		${Macros}/common.tex ${Macros}/indexstyle ../../../bibliography/pl.bib
+${BASE}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
+		${Macros}/common.tex ${Macros}/indexstyle ../../../bibliography/pl.bib | ${Build}
 	# Must have *.aux file containing citations for bibtex
 	if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi
@@ -66,11 +67,11 @@
 	mkdir -p ${Build}
 
-%.tex : %.fig
+%.tex : %.fig ${Build}
 	fig2dev -L eepic $< > ${Build}/$@
 
-%.ps : %.fig
+%.ps : %.fig | ${Build}
 	fig2dev -L ps $< > ${Build}/$@
 
-%.pstex : %.fig
+%.pstex : %.fig | ${Build}
 	fig2dev -L pstex $< > ${Build}/$@
 	fig2dev -L pstex_t -p ${Build}/$@ $< > ${Build}/$@_t
Index: doc/theses/thierry_delisle/Makefile
===================================================================
--- doc/theses/thierry_delisle/Makefile	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/theses/thierry_delisle/Makefile	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -51,4 +51,5 @@
 
 DOCUMENT = thesis.pdf
+BASE = ${basename ${DOCUMENT}}
 
 # Directives #
@@ -59,16 +60,16 @@
 
 clean :
-	@rm -frv ${DOCUMENT} ${basename ${DOCUMENT}}.ps ${Build}
+	@rm -frv ${DOCUMENT} ${BASE}.ps ${Build}
 
 # File Dependencies #
 
-${DOCUMENT} : ${basename ${DOCUMENT}}.ps
+${DOCUMENT} : ${BASE}.ps
 	ps2pdf $<
 
-${basename ${DOCUMENT}}.ps : ${basename ${DOCUMENT}}.dvi
+${BASE}.ps : ${BASE}.dvi
 	dvips ${Build}/$< -o $@
 
-${basename ${DOCUMENT}}.dvi : Makefile ${Build} ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
-		${Macros}/common.tex ${Macros}/indexstyle annex/local.bib ../../bibliography/pl.bib
+${BASE}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
+		${Macros}/common.tex ${Macros}/indexstyle annex/local.bib ../../bibliography/pl.bib | ${Build}
 	# Must have *.aux file containing citations for bibtex
 	if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi
@@ -91,8 +92,8 @@
 	fig2dev -L eepic $< > ${Build}/$@
 
-%.ps : %.fig ${Build}
+%.ps : %.fig | ${Build}
 	fig2dev -L ps $< > ${Build}/$@
 
-%.pstex : %.fig ${Build}
+%.pstex : %.fig | ${Build}
 	fig2dev -L pstex $< > ${Build}/$@
 	fig2dev -L pstex_t -p ${Build}/$@ $< > ${Build}/$@_t
Index: doc/user/Makefile
===================================================================
--- doc/user/Makefile	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ doc/user/Makefile	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -57,6 +57,6 @@
 	dvips ${Build}/$< -o $@
 
-${BASE}.dvi : Makefile ${Build} ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
-		${Macros}/common.tex ${Macros}/lstlang.sty ${Macros}/indexstyle ../bibliography/pl.bib
+${BASE}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
+		${Macros}/common.tex ${Macros}/lstlang.sty ${Macros}/indexstyle ../bibliography/pl.bib | ${Build}
 	# Conditionally create an empty *.ind (index) file for inclusion until makeindex is run.
 	if [ ! -r ${basename $@}.ind ] ; then touch ${Build}/${basename $@}.ind ; fi
@@ -79,11 +79,11 @@
 	mkdir -p ${Build}
 
-%.tex : %.fig ${Build}
+%.tex : %.fig | ${Build}
 	fig2dev -L eepic $< > ${Build}/$@
 
-%.ps : %.fig ${Build}
+%.ps : %.fig | ${Build}
 	fig2dev -L ps $< > ${Build}/$@
 
-%.pstex : %.fig ${Build}
+%.pstex : %.fig | ${Build}
 	fig2dev -L pstex $< > ${Build}/$@
 	fig2dev -L pstex_t -p ${Build}/$@ $< > ${Build}/$@_t
Index: src/Parser/TypedefTable.cc
===================================================================
--- src/Parser/TypedefTable.cc	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/Parser/TypedefTable.cc	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 15:20:13 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jun  7 13:17:56 2018
-// Update Count     : 192
+// Last Modified On : Fri Jun 22 06:14:39 2018
+// Update Count     : 206
 //
 
@@ -78,11 +78,12 @@
 	debugPrint( cerr << "Adding current at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << endl );
 	auto ret = kindTable.insertAt( scope, identifier, kind );
-	if ( ! ret.second ) ret.first->second = kind;		// exists => update
+	//if ( ! ret.second ) ret.first->second = kind;		// exists => update
+	assert( ret.first->second == kind );				// exists
 } // TypedefTable::addToScope
 
 void TypedefTable::addToEnclosingScope( const string & identifier, int kind, const char * locn __attribute__((unused)) ) {
-	assert( kindTable.currentScope() >= 1 );
-	auto scope = kindTable.currentScope() - 1;
-	debugPrint( cerr << "Adding enclosing at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << endl );
+	assert( kindTable.currentScope() >= 1 + level );
+	auto scope = kindTable.currentScope() - 1 - level;
+	debugPrint( cerr << "Adding enclosing at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << " level " << level << endl );
 	auto ret = kindTable.insertAt( scope, identifier, kind );
 	if ( ! ret.second ) ret.first->second = kind;		// exists => update
@@ -91,11 +92,9 @@
 void TypedefTable::enterScope() {
 	kindTable.beginScope();
-	debugPrint( cerr << "Entering scope " << kindTable.currentScope() << endl );
-	debugPrint( print() );
+	debugPrint( cerr << "Entering scope " << kindTable.currentScope() << endl; print() );
 } // TypedefTable::enterScope
 
 void TypedefTable::leaveScope() {
-	debugPrint( cerr << "Leaving scope " << kindTable.currentScope() << endl );
-	debugPrint( print() );
+	debugPrint( cerr << "Leaving scope " << kindTable.currentScope() << endl; print() );
 	kindTable.endScope();
 } // TypedefTable::leaveScope
@@ -114,7 +113,7 @@
 		--scope;
 		debugPrint( cerr << endl << "[" << scope << "]" );
-	}
+	} // while
 	debugPrint( cerr << endl );
-}
+} // TypedefTable::print
 
 // Local Variables: //
Index: src/Parser/TypedefTable.h
===================================================================
--- src/Parser/TypedefTable.h	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/Parser/TypedefTable.h	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 15:24:36 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jun  7 12:10:17 2018
-// Update Count     : 85
+// Last Modified On : Fri Jun 22 05:29:58 2018
+// Update Count     : 86
 //
 
@@ -25,4 +25,5 @@
 	typedef ScopedMap< std::string, int > KindTable;
 	KindTable kindTable;	
+	unsigned int level = 0;
   public:
 	~TypedefTable();
@@ -37,4 +38,7 @@
 	void leaveScope();
 
+	void up() { level += 1; }
+	void down() { level -= 1; }
+
 	void print( void ) const;
 }; // TypedefTable
Index: src/Parser/lex.ll
===================================================================
--- src/Parser/lex.ll	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/Parser/lex.ll	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -10,6 +10,6 @@
  * Created On       : Sat Sep 22 08:58:10 2001
  * Last Modified By : Peter A. Buhr
- * Last Modified On : Thu Jun  7 08:27:40 2018
- * Update Count     : 679
+ * Last Modified On : Wed Jun 20 09:08:28 2018
+ * Update Count     : 682
  */
 
@@ -25,6 +25,13 @@
 //**************************** Includes and Defines ****************************
 
+// trigger before each matching rule's action
+#define YY_USER_ACTION \
+	yylloc.first_line = yylineno; \
+	yylloc.first_column = column; \
+	column += yyleng; \
+	yylloc.last_column = column; \
+	yylloc.last_line = yylineno; \
+	yylloc.filename = yyfilename ? yyfilename : "";
 unsigned int column = 0;								// position of the end of the last token parsed
-#define YY_USER_ACTION yylloc.first_line = yylineno; yylloc.first_column = column; column += yyleng; yylloc.last_column = column; yylloc.last_line = yylineno; yylloc.filename = yyfilename ? yyfilename : "";				// trigger before each matching rule's action
 
 #include <string>
@@ -49,5 +56,5 @@
 #define NUMERIC_RETURN(x)	rm_underscore(); RETURN_VAL( x ) // numeric constant
 #define KEYWORD_RETURN(x)	RETURN_CHAR( x )			// keyword
-#define QKEYWORD_RETURN(x)	typedefTable.isKind( yytext ); RETURN_VAL(x); // quasi-keyword
+#define QKEYWORD_RETURN(x)	RETURN_VAL(x);				// quasi-keyword
 #define IDENTIFIER_RETURN()	RETURN_VAL( typedefTable.isKind( yytext ) )
 #define ATTRIBUTE_RETURN()	RETURN_VAL( ATTR_IDENTIFIER )
Index: src/Parser/parser.yy
===================================================================
--- src/Parser/parser.yy	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/Parser/parser.yy	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -10,6 +10,6 @@
 // Created On       : Sat Sep  1 20:22:55 2001
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jun  7 10:07:12 2018
-// Update Count     : 3527
+// Last Modified On : Sun Jun 24 10:41:10 2018
+// Update Count     : 3587
 //
 
@@ -136,5 +136,5 @@
 } // build_postfix_name
 
-bool forall = false, xxx = false;						// aggregate have one or more forall qualifiers ?
+bool forall = false, xxx = false, yyy = false;			// aggregate have one or more forall qualifiers ?
 
 // https://www.gnu.org/software/bison/manual/bison.html#Location-Type
@@ -304,5 +304,7 @@
 %type<en> enumerator_value_opt
 
-%type<decl> exception_declaration external_definition external_definition_list external_definition_list_no_pop_push external_definition_list_opt
+%type<decl> external_definition external_definition_list external_definition_list_opt
+
+%type<decl> exception_declaration
 
 %type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list
@@ -503,9 +505,7 @@
 		{ $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
 	| type_name '.' no_attr_identifier					// CFA, nested type
-		// { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
-		{ $$ = nullptr; }
+		{ SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
 	| type_name '.' '[' field_list ']'					// CFA, nested type / tuple field selector
-		// { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
-		{ $$ = nullptr; }
+		{ SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
 	| GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
 		{
@@ -1821,23 +1821,26 @@
 	;
 
+fred:
+	// empty
+		{ yyy = false; }
+	;
+
 aggregate_type:											// struct, union
 	aggregate_key attribute_list_opt '{' field_declaration_list_opt '}'
 		{ $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); }
-	| aggregate_key attribute_list_opt no_attr_identifier
+	| aggregate_key attribute_list_opt no_attr_identifier fred
 		{
 			typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); // create typedef
-			//if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update
 			forall = false;								// reset
 		}
 	  '{' field_declaration_list_opt '}'
-		{ $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); }
-	| aggregate_key attribute_list_opt type_name
+		{ $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $7, true )->addQualifiers( $2 ); }
+	| aggregate_key attribute_list_opt type_name fred
 		{
 			typedefTable.makeTypedef( *$3->type->symbolic.name, forall ? TYPEGENname : TYPEDEFname ); // create typedef
-			//if ( forall ) typedefTable.changeKind( *$3->type->symbolic.name, TYPEGENname ); // possibly update
 			forall = false;								// reset
 		}
 	  '{' field_declaration_list_opt '}'
-		{ $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, nullptr, $6, true )->addQualifiers( $2 ); }
+		{ $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, nullptr, $7, true )->addQualifiers( $2 ); }
 	| aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list_opt '}' // CFA
 		{ $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); }
@@ -1846,12 +1849,11 @@
 
 aggregate_type_nobody:									// struct, union - {...}
-	aggregate_key attribute_list_opt no_attr_identifier
+	aggregate_key attribute_list_opt no_attr_identifier fred
 		{
 			typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname );
-			//if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update
 			forall = false;								// reset
 			$$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
 		}
-	| aggregate_key attribute_list_opt type_name
+	| aggregate_key attribute_list_opt type_name fred
 		{
 			// Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is
@@ -1867,15 +1869,15 @@
 aggregate_key:
 	STRUCT
-		{ $$ = DeclarationNode::Struct; }
+		{ yyy = true; $$ = DeclarationNode::Struct; }
 	| UNION
-		{ $$ = DeclarationNode::Union; }
+		{ yyy = true; $$ = DeclarationNode::Union; }
 	| EXCEPTION
-		{ $$ = DeclarationNode::Exception; }
+		{ yyy = true; $$ = DeclarationNode::Exception; }
 	| COROUTINE
-		{ $$ = DeclarationNode::Coroutine; }
+		{ yyy = true; $$ = DeclarationNode::Coroutine; }
 	| MONITOR
-		{ $$ = DeclarationNode::Monitor; }
+		{ yyy = true; $$ = DeclarationNode::Monitor; }
 	| THREAD
-		{ $$ = DeclarationNode::Thread; }
+		{ yyy = true; $$ = DeclarationNode::Thread; }
 	;
 
@@ -2320,6 +2322,5 @@
 
 translation_unit:
-	// empty
-		{}												// empty input file
+	// empty, input file
 	| external_definition_list
 		{ parseTree = parseTree ? parseTree->appendList( $1 ) : $1;	}
@@ -2335,22 +2336,16 @@
 	;
 
-	// SKULLDUGGERY: Declarations in extern "X" and distribution need to be added to the current lexical scope.
-	// However, external_definition_list creates a new scope around each external_definition, but the pop loses all the
-	// types in the extern "X" and distribution at the end of the block. This version of external_definition_list does
-
-	// not do push/pop for declarations at the level of the extern "X" and distribution block. Any recursive uses of
-	// external_definition_list within the extern "X" and distribution block correctly pushes/pops for that scope level.
-external_definition_list_no_pop_push:
-	external_definition
-	| external_definition_list_no_pop_push
-		{ forall = xxx; }
-	  external_definition
-		{ $$ = $1 ? $1->appendList( $3 ) : $3; }
-	;
-
 external_definition_list_opt:
 	// empty
 		{ $$ = nullptr; }
-	| external_definition_list_no_pop_push
+	| external_definition_list
+	;
+
+up:
+		{ typedefTable.up(); }
+	;
+
+down:
+		{ typedefTable.down(); }
 	;
 
@@ -2372,15 +2367,18 @@
 			linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
 		}
-	  '{' external_definition_list_opt '}'
+	  '{' up external_definition_list_opt down '}'
 		{
 			linkage = linkageStack.top();
 			linkageStack.pop();
-			$$ = $5;
+			$$ = $6;
 		}
 	| type_qualifier_list
-		{ if ( $1->type->forall ) xxx = forall = true; } // remember generic type
-	  '{' external_definition_list_opt '}'				// CFA, namespace
-		{
-			for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
+		{
+			if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
+			if ( $1->type->forall ) xxx = forall = true; // remember generic type
+		}
+	  '{' up external_definition_list_opt down '}'		// CFA, namespace
+		{
+			for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
 				if ( isMangled( iter->linkage ) ) {		// ignore extern "C"
 					iter->addQualifiers( $1->clone() );
@@ -2389,11 +2387,14 @@
  			xxx = false;
 			delete $1;
-			$$ = $4;
+			$$ = $5;
 		}
 	| declaration_qualifier_list
-		{ if ( $1->type->forall ) xxx = forall = true; } // remember generic type
-	  '{' external_definition_list_opt '}'				// CFA, namespace
-		{
-			for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
+		{
+			if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
+			if ( $1->type->forall ) xxx = forall = true; // remember generic type
+		}
+	  '{' up external_definition_list_opt down '}'		// CFA, namespace
+		{
+			for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
 				if ( isMangled( iter->linkage ) ) {		// ignore extern "C"
 					iter->addQualifiers( $1->clone() );
@@ -2402,14 +2403,14 @@
  			xxx = false;
 			delete $1;
-			$$ = $4;
+			$$ = $5;
 		}
 	| declaration_qualifier_list type_qualifier_list
 		{
-			// forall must be in the type_qualifier_list
-			if ( $2->type->forall ) xxx = forall = true; // remember generic type
-		}
-	  '{' external_definition_list_opt '}'				// CFA, namespace
-		{
-			for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
+			if ( ($1->type && $1->type->qualifiers.val) || $2->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
+			if ( ($1->type && $1->type->forall) || $2->type->forall ) xxx = forall = true; // remember generic type
+		}
+	  '{' up external_definition_list_opt down '}'		// CFA, namespace
+		{
+			for ( DeclarationNode * iter = $6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
 				if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) {	// ignore extern "C"
 					iter->addQualifiers( $1->clone() );
@@ -2420,5 +2421,5 @@
 			delete $1;
 			delete $2;
-			$$ = $5;
+			$$ = $6;
 		}
 	;
Index: src/ResolvExpr/AlternativeFinder.cc
===================================================================
--- src/ResolvExpr/AlternativeFinder.cc	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/ResolvExpr/AlternativeFinder.cc	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -1099,5 +1099,5 @@
 			argExpansions.emplace_back();
 			auto& argE = argExpansions.back();
-			argE.reserve( arg.alternatives.size() );
+			// argE.reserve( arg.alternatives.size() );
 
 			for ( const Alternative& actual : arg ) {
Index: src/ResolvExpr/CommonType.cc
===================================================================
--- src/ResolvExpr/CommonType.cc	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/ResolvExpr/CommonType.cc	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -24,5 +24,5 @@
 #include "SynTree/Type.h"                // for BasicType, BasicType::Kind::...
 #include "SynTree/Visitor.h"             // for Visitor
-#include "Unify.h"                       // for unifyExact, bindVar, WidenMode
+#include "Unify.h"                       // for unifyExact, WidenMode
 #include "typeops.h"                     // for isFtype
 
@@ -238,5 +238,5 @@
 				AssertionSet need, have;
 				WidenMode widen( widenFirst, widenSecond );
-				if ( entry != openVars.end() && ! bindVar(var, voidPointer->get_base(), entry->second, env, need, have, openVars, widen, indexer ) ) return;
+				if ( entry != openVars.end() && ! env.bindVar(var, voidPointer->get_base(), entry->second, need, have, openVars, widen, indexer ) ) return;
 			}
 		}
Index: src/ResolvExpr/ExplodedActual.h
===================================================================
--- src/ResolvExpr/ExplodedActual.h	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/ResolvExpr/ExplodedActual.h	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -32,6 +32,7 @@
 
 		ExplodedActual() : env(), cost(Cost::zero), exprs() {}
-
 		ExplodedActual( const Alternative& actual, const SymTab::Indexer& indexer );
+		ExplodedActual(ExplodedActual&&) = default;
+		ExplodedActual& operator= (ExplodedActual&&) = default;
 	};
 }
Index: src/ResolvExpr/Resolver.cc
===================================================================
--- src/ResolvExpr/Resolver.cc	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/ResolvExpr/Resolver.cc	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -582,8 +582,6 @@
 
 							// Make sure we don't widen any existing bindings
-							for ( auto & i : resultEnv ) {
-								i.allowWidening = false;
-							}
-
+							resultEnv.forbidWidening();
+							
 							// Find any unbound type variables
 							resultEnv.extractOpenVars( openVars );
Index: src/ResolvExpr/TypeEnvironment.cc
===================================================================
--- src/ResolvExpr/TypeEnvironment.cc	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/ResolvExpr/TypeEnvironment.cc	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 12:19:47 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sun May 17 12:23:36 2015
-// Update Count     : 3
+// Last Modified By : Aaron B. Moss
+// Last Modified On : Mon Jun 18 11:58:00 2018
+// Update Count     : 4
 //
 
@@ -17,4 +17,5 @@
 #include <algorithm>                   // for copy, set_intersection
 #include <iterator>                    // for ostream_iterator, insert_iterator
+#include <memory>                      // for unique_ptr
 #include <utility>                     // for pair, move
 
@@ -22,5 +23,8 @@
 #include "SynTree/Type.h"              // for Type, FunctionType, Type::Fora...
 #include "SynTree/TypeSubstitution.h"  // for TypeSubstitution
+#include "Tuples/Tuples.h"             // for isTtype
 #include "TypeEnvironment.h"
+#include "typeops.h"                   // for occurs
+#include "Unify.h"                     // for unifyInexact
 
 namespace ResolvExpr {
@@ -65,4 +69,10 @@
 	}
 
+	EqvClass::EqvClass( EqvClass &&other ) 
+	: vars{std::move(other.vars)}, type{other.type}, 
+	  allowWidening{std::move(other.allowWidening)}, data{std::move(other.data)} {
+		  other.type = nullptr;
+	}
+
 	EqvClass &EqvClass::operator=( const EqvClass &other ) {
 		if ( this == &other ) return *this;
@@ -72,6 +82,25 @@
 	}
 
+	EqvClass &EqvClass::operator=( EqvClass &&other ) {
+		if ( this == &other ) return *this;
+		delete type;
+		
+		vars = std::move(other.vars);
+		type = other.type;
+		other.type = nullptr;
+		allowWidening = std::move(other.allowWidening);
+		data = std::move(other.data);
+
+		return *this;
+	}
+
 	EqvClass::~EqvClass() {
 		delete type;
+	}
+
+	void EqvClass::set_type( Type* ty ) {
+		if ( ty == type ) return;
+		delete type;
+		type = ty;
 	}
 
@@ -92,11 +121,5 @@
 	const EqvClass* TypeEnvironment::lookup( const std::string &var ) const {
 		for ( std::list< EqvClass >::const_iterator i = env.begin(); i != env.end(); ++i ) {
-			if ( i->vars.find( var ) != i->vars.end() ) {
-///       std::cout << var << " is in class ";
-///       i->print( std::cout );
-				return &*i;
-			}
-///     std::cout << var << " is not in class ";
-///     i->print( std::cout );
+			if ( i->vars.find( var ) != i->vars.end() ) return &*i;
 		} // for
 		return nullptr;
@@ -116,9 +139,4 @@
 	}
 
-	void TypeEnvironment::add( const EqvClass &eqvClass ) {
-		filterOverlappingClasses( env, eqvClass );
-		env.push_back( eqvClass );
-	}
-
 	void TypeEnvironment::add( EqvClass &&eqvClass ) {
 		filterOverlappingClasses( env, eqvClass );
@@ -131,5 +149,5 @@
 			newClass.vars.insert( (*i)->get_name() );
 			newClass.data = TypeDecl::Data{ (*i) };
-			env.push_back( newClass );
+			env.push_back( std::move(newClass) );
 		} // for
 	}
@@ -145,5 +163,5 @@
 			// transition to TypeSubstitution
 			newClass.data = TypeDecl::Data{ TypeDecl::Dtype, false };
-			add( newClass );
+			add( std::move(newClass) );
 		}
 	}
@@ -152,13 +170,8 @@
 		for ( std::list< EqvClass >::const_iterator theClass = env.begin(); theClass != env.end(); ++theClass ) {
 			for ( std::set< std::string >::const_iterator theVar = theClass->vars.begin(); theVar != theClass->vars.end(); ++theVar ) {
-///       std::cerr << "adding " << *theVar;
 				if ( theClass->type ) {
-///         std::cerr << " bound to ";
-///         theClass->type->print( std::cerr );
-///         std::cerr << std::endl;
 					sub.add( *theVar, theClass->type );
 				} else if ( theVar != theClass->vars.begin() ) {
 					TypeInstType *newTypeInst = new TypeInstType( Type::Qualifiers(), *theClass->vars.begin(), theClass->data.kind == TypeDecl::Ftype );
-///         std::cerr << " bound to variable " << *theClass->vars.begin() << std::endl;
 					sub.add( *theVar, newTypeInst );
 					delete newTypeInst;
@@ -166,8 +179,4 @@
 			} // for
 		} // for
-///   std::cerr << "input env is:" << std::endl;
-///   print( std::cerr, 8 );
-///   std::cerr << "sub is:" << std::endl;
-///   sub.print( std::cerr, 8 );
 		sub.normalize();
 	}
@@ -181,7 +190,5 @@
 	std::list< EqvClass >::iterator TypeEnvironment::internal_lookup( const std::string &var ) {
 		for ( std::list< EqvClass >::iterator i = env.begin(); i != env.end(); ++i ) {
-			if ( i->vars.find( var ) == i->vars.end() ) {
-				return i;
-			} // if
+			if ( i->vars.count( var ) ) return i;
 		} // for
 		return env.end();
@@ -190,34 +197,4 @@
 	void TypeEnvironment::simpleCombine( const TypeEnvironment &second ) {
 		env.insert( env.end(), second.env.begin(), second.env.end() );
-	}
-
-	void TypeEnvironment::combine( const TypeEnvironment &second, Type *(*combineFunc)( Type*, Type* ) ) {
-		TypeEnvironment secondCopy( second );
-		for ( std::list< EqvClass >::iterator firstClass = env.begin(); firstClass != env.end(); ++firstClass ) {
-			EqvClass &newClass = *firstClass;
-			std::set< std::string > newVars;
-			for ( std::set< std::string >::const_iterator var = firstClass->vars.begin(); var != firstClass->vars.end(); ++var ) {
-				std::list< EqvClass >::iterator secondClass = secondCopy.internal_lookup( *var );
-				if ( secondClass != secondCopy.env.end() ) {
-					newVars.insert( secondClass->vars.begin(), secondClass->vars.end() );
-					if ( secondClass->type ) {
-						if ( newClass.type ) {
-							Type *newType = combineFunc( newClass.type, secondClass->type );
-							delete newClass.type;
-							newClass.type = newType;
-							newClass.allowWidening = newClass.allowWidening && secondClass->allowWidening;
-						} else {
-							newClass.type = secondClass->type->clone();
-							newClass.allowWidening = secondClass->allowWidening;
-						} // if
-					} // if
-					secondCopy.env.erase( secondClass );
-				} // if
-			} // for
-			newClass.vars.insert( newVars.begin(), newVars.end() );
-		} // for
-		for ( std::list< EqvClass >::iterator secondClass = secondCopy.env.begin(); secondClass != secondCopy.env.end(); ++secondClass ) {
-			env.push_back( *secondClass );
-		} // for
 	}
 
@@ -241,4 +218,152 @@
 	}
 
+	bool isFtype( Type *type ) {
+		if ( dynamic_cast< FunctionType* >( type ) ) {
+			return true;
+		} else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( type ) ) {
+			return typeInst->get_isFtype();
+		} // if
+		return false;
+	}
+
+	bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) {
+		switch ( data.kind ) {
+		  case TypeDecl::Dtype:
+			// to bind to an object type variable, the type must not be a function type.
+			// if the type variable is specified to be a complete type then the incoming
+			// type must also be complete
+			// xxx - should this also check that type is not a tuple type and that it's not a ttype?
+			return ! isFtype( type ) && (! data.isComplete || type->isComplete() );
+		  case TypeDecl::Ftype:
+			return isFtype( type );
+		  case TypeDecl::Ttype:
+			// ttype unifies with any tuple type
+			return dynamic_cast< TupleType * >( type ) || Tuples::isTtype( type );
+		} // switch
+		return false;
+	}
+
+	bool TypeEnvironment::bindVar( TypeInstType *typeInst, Type *bindTo, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {
+		
+		// remove references from other, so that type variables can only bind to value types
+		bindTo = bindTo->stripReferences();
+		OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() );
+		assert( tyvar != openVars.end() );
+		if ( ! tyVarCompatible( tyvar->second, bindTo ) ) {
+			return false;
+		} // if
+		if ( occurs( bindTo, typeInst->get_name(), *this ) ) {
+			return false;
+		} // if
+		auto curClass = internal_lookup( typeInst->get_name() );
+		if ( curClass != env.end() ) {
+			if ( curClass->type ) {
+				Type *common = 0;
+				// attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to
+				std::unique_ptr< Type > newType( curClass->type->clone() );
+				newType->get_qualifiers() = typeInst->get_qualifiers();
+				if ( unifyInexact( newType.get(), bindTo, *this, need, have, openVars, widenMode & WidenMode( curClass->allowWidening, true ), indexer, common ) ) {
+					if ( common ) {
+						common->get_qualifiers() = Type::Qualifiers{};
+						curClass->set_type( common );
+					} // if
+				} else return false;
+			} else {
+				Type* newType = bindTo->clone();
+				newType->get_qualifiers() = Type::Qualifiers{};
+				curClass->set_type( newType );
+				curClass->allowWidening = widenMode.widenFirst && widenMode.widenSecond;
+			} // if
+		} else {
+			EqvClass newClass;
+			newClass.vars.insert( typeInst->get_name() );
+			newClass.type = bindTo->clone();
+			newClass.type->get_qualifiers() = Type::Qualifiers();
+			newClass.allowWidening = widenMode.widenFirst && widenMode.widenSecond;
+			newClass.data = data;
+			env.push_back( std::move(newClass) );
+		} // if
+		return true;
+	}
+
+	bool TypeEnvironment::bindVarToVar( TypeInstType *var1, TypeInstType *var2, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {
+
+		auto class1 = internal_lookup( var1->get_name() );
+		auto class2 = internal_lookup( var2->get_name() );
+		
+		// exit early if variables already bound together
+		if ( class1 != env.end() && class1 == class2 ) {
+			class1->allowWidening &= widenMode;
+			return true;
+		}
+
+		bool widen1 = false, widen2 = false;
+		const Type *type1 = nullptr, *type2 = nullptr;
+
+		// check for existing bindings, perform occurs check
+		if ( class1 != env.end() ) {
+			if ( class1->type ) {
+				if ( occurs( class1->type, var2->get_name(), *this ) ) return false;
+				type1 = class1->type;
+			} // if
+			widen1 = widenMode.widenFirst && class1->allowWidening;
+		} // if
+		if ( class2 != env.end() ) {
+			if ( class2->type ) {
+				if ( occurs( class2->type, var1->get_name(), *this ) ) return false;
+				type2 = class2->type;
+			} // if
+			widen2 = widenMode.widenSecond && class2->allowWidening;
+		} // if
+
+		if ( type1 && type2 ) {
+			// both classes bound, merge if bound types can be unified
+			std::unique_ptr<Type> newType1{ type1->clone() }, newType2{ type2->clone() };
+			WidenMode newWidenMode{ widen1, widen2 };
+			Type *common = 0;
+			if ( unifyInexact( newType1.get(), newType2.get(), *this, need, have, openVars, newWidenMode, indexer, common ) ) {
+				class1->vars.insert( class2->vars.begin(), class2->vars.end() );
+				class1->allowWidening = widen1 && widen2;
+				if ( common ) {
+					common->get_qualifiers() = Type::Qualifiers{};
+					class1->set_type( common );
+				}
+				env.erase( class2 );
+			} else return false;
+		} else if ( class1 != env.end() && class2 != env.end() ) {
+			// both classes exist, at least one unbound, merge unconditionally
+			if ( type1 ) {
+				class1->vars.insert( class2->vars.begin(), class2->vars.end() );
+				class1->allowWidening = widen1;
+				env.erase( class2 );
+			} else {
+				class2->vars.insert( class1->vars.begin(), class1->vars.end() );
+				class2->allowWidening = widen2;
+				env.erase( class1 );
+			} // if
+		} else if ( class1 != env.end() ) {
+			// var2 unbound, add to class1
+			class1->vars.insert( var2->get_name() );
+			class1->allowWidening = widen1;
+		} else if ( class2 != env.end() ) {
+			// var1 unbound, add to class2
+			class2->vars.insert( var1->get_name() );
+			class2->allowWidening = widen2;
+		} else {
+			// neither var bound, create new class
+			EqvClass newClass;
+			newClass.vars.insert( var1->get_name() );
+			newClass.vars.insert( var2->get_name() );
+			newClass.allowWidening = widen1 && widen2;
+			newClass.data = data;
+			env.push_back( std::move(newClass) );
+		} // if
+		return true;
+	}
+
+	void TypeEnvironment::forbidWidening() {
+		for ( EqvClass& c : env ) c.allowWidening = false;
+	}
+
 	std::ostream & operator<<( std::ostream & out, const TypeEnvironment & env ) {
 		env.print( out );
Index: src/ResolvExpr/TypeEnvironment.h
===================================================================
--- src/ResolvExpr/TypeEnvironment.h	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/ResolvExpr/TypeEnvironment.h	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 12:24:58 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jul 22 09:35:45 2017
-// Update Count     : 3
+// Last Modified By : Aaron B. Moss
+// Last Modified On : Mon Jun 18 11:58:00 2018
+// Update Count     : 4
 //
 
@@ -21,4 +21,7 @@
 #include <set>                         // for set
 #include <string>                      // for string
+#include <utility>                     // for move, swap
+
+#include "WidenMode.h"                 // for WidenMode
 
 #include "SynTree/Declaration.h"       // for TypeDecl::Data, DeclarationWit...
@@ -77,7 +80,12 @@
 		EqvClass( const EqvClass &other );
 		EqvClass( const EqvClass &other, const Type *ty );
+		EqvClass( EqvClass &&other );
 		EqvClass &operator=( const EqvClass &other );
+		EqvClass &operator=( EqvClass &&other );
 		~EqvClass();
 		void print( std::ostream &os, Indenter indent = {} ) const;
+
+		/// Takes ownership of `ty`, freeing old `type`
+		void set_type(Type* ty);
 	};
 
@@ -85,6 +93,7 @@
 	  public:
 		const EqvClass* lookup( const std::string &var ) const;
-		void add( const EqvClass &eqvClass );
+	  private:
 		void add( EqvClass &&eqvClass  );
+	  public:
 		void add( const Type::ForallList &tyDecls );
 		void add( const TypeSubstitution & sub );
@@ -94,5 +103,5 @@
 		bool isEmpty() const { return env.empty(); }
 		void print( std::ostream &os, Indenter indent = {} ) const;
-		void combine( const TypeEnvironment &second, Type *(*combineFunc)( Type*, Type* ) );
+		// void combine( const TypeEnvironment &second, Type *(*combineFunc)( Type*, Type* ) );
 		void simpleCombine( const TypeEnvironment &second );
 		void extractOpenVars( OpenVarSet &openVars ) const;
@@ -103,12 +112,22 @@
 		void addActual( const TypeEnvironment& actualEnv, OpenVarSet& openVars );
 
-		typedef std::list< EqvClass >::iterator iterator;
-		iterator begin() { return env.begin(); }
-		iterator end() { return env.end(); }
-		typedef std::list< EqvClass >::const_iterator const_iterator;
-		const_iterator begin() const { return env.begin(); }
-		const_iterator end() const { return env.end(); }
+		/// Binds the type class represented by `typeInst` to the type `bindTo`; will add 
+		/// the class if needed. Returns false on failure.
+		bool bindVar( TypeInstType *typeInst, Type *bindTo, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer );
+		
+		/// Binds the type classes represented by `var1` and `var2` together; will add 
+		/// one or both classes if needed. Returns false on failure.
+		bool bindVarToVar( TypeInstType *var1, TypeInstType *var2, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer );
+
+		/// Disallows widening for all bindings in the environment
+		void forbidWidening();
+
+		using iterator = std::list< EqvClass >::const_iterator;
+		iterator begin() const { return env.begin(); }
+		iterator end() const { return env.end(); }
+
 	  private:
 		std::list< EqvClass > env;
+		
 		std::list< EqvClass >::iterator internal_lookup( const std::string &var );
 	};
Index: src/ResolvExpr/Unify.cc
===================================================================
--- src/ResolvExpr/Unify.cc	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/ResolvExpr/Unify.cc	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 12:27:10 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Mar 16 16:22:54 2017
-// Update Count     : 42
+// Last Modified By : Aaron B. Moss
+// Last Modified On : Mon Jun 18 11:58:00 2018
+// Update Count     : 43
 //
 
@@ -129,152 +129,4 @@
 	}
 
-	bool isFtype( Type *type ) {
-		if ( dynamic_cast< FunctionType* >( type ) ) {
-			return true;
-		} else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( type ) ) {
-			return typeInst->get_isFtype();
-		} // if
-		return false;
-	}
-
-	bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) {
-		switch ( data.kind ) {
-		  case TypeDecl::Dtype:
-			// to bind to an object type variable, the type must not be a function type.
-			// if the type variable is specified to be a complete type then the incoming
-			// type must also be complete
-			// xxx - should this also check that type is not a tuple type and that it's not a ttype?
-			return ! isFtype( type ) && (! data.isComplete || type->isComplete() );
-		  case TypeDecl::Ftype:
-			return isFtype( type );
-		  case TypeDecl::Ttype:
-			// ttype unifies with any tuple type
-			return dynamic_cast< TupleType * >( type ) || Tuples::isTtype( type );
-		} // switch
-		return false;
-	}
-
-	bool bindVar( TypeInstType *typeInst, Type *other, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {
-		// remove references from other, so that type variables can only bind to value types
-		other = other->stripReferences();
-		OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() );
-		assert( tyvar != openVars.end() );
-		if ( ! tyVarCompatible( tyvar->second, other ) ) {
-			return false;
-		} // if
-		if ( occurs( other, typeInst->get_name(), env ) ) {
-			return false;
-		} // if
-		if ( const EqvClass *curClass = env.lookup( typeInst->get_name() ) ) {
-			if ( curClass->type ) {
-				Type *common = 0;
-				// attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to
-				std::unique_ptr< Type > newType( curClass->type->clone() );
-				newType->get_qualifiers() = typeInst->get_qualifiers();
-				if ( unifyInexact( newType.get(), other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass->allowWidening, true ), indexer, common ) ) {
-					if ( common ) {
-						common->get_qualifiers() = Type::Qualifiers();
-						env.add( EqvClass{ *curClass, common } );
-					} // if
-					return true;
-				} else {
-					return false;
-				} // if
-			} else {
-				EqvClass newClass { *curClass, other };
-				newClass.type->get_qualifiers() = Type::Qualifiers();
-				newClass.allowWidening = widenMode.widenFirst && widenMode.widenSecond;
-				env.add( std::move(newClass) );
-			} // if
-		} else {
-			EqvClass newClass;
-			newClass.vars.insert( typeInst->get_name() );
-			newClass.type = other->clone();
-			newClass.type->get_qualifiers() = Type::Qualifiers();
-			newClass.allowWidening = widenMode.widenFirst && widenMode.widenSecond;
-			newClass.data = data;
-			env.add( newClass );
-		} // if
-		return true;
-	}
-
-	bool bindVarToVar( TypeInstType *var1, TypeInstType *var2, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {
-		bool result = true;
-		const EqvClass *class1 = env.lookup( var1->get_name() );
-		const EqvClass *class2 = env.lookup( var2->get_name() );
-		bool widen1 = false, widen2 = false;
-		Type *type1 = nullptr, *type2 = nullptr;
-
-		if ( class1 ) {
-			if ( class1->type ) {
-				if ( occurs( class1->type, var2->get_name(), env ) ) {
-					return false;
-				} // if
-				type1 = class1->type->clone();
-			} // if
-			widen1 = widenMode.widenFirst && class1->allowWidening;
-		} // if
-		if ( class2 ) {
-			if ( class2->type ) {
-				if ( occurs( class2->type, var1->get_name(), env ) ) {
-					return false;
-				} // if
-				type2 = class2->type->clone();
-			} // if
-			widen2 = widenMode.widenSecond && class2->allowWidening;
-		} // if
-
-		if ( type1 && type2 ) {
-//    std::cerr << "has type1 && type2" << std::endl;
-			WidenMode newWidenMode ( widen1, widen2 );
-			Type *common = 0;
-			if ( unifyInexact( type1, type2, env, needAssertions, haveAssertions, openVars, newWidenMode, indexer, common ) ) {
-				EqvClass newClass1 = *class1;
-				newClass1.vars.insert( class2->vars.begin(), class2->vars.end() );
-				newClass1.allowWidening = widen1 && widen2;
-				if ( common ) {
-					common->get_qualifiers() = Type::Qualifiers();
-					delete newClass1.type;
-					newClass1.type = common;
-				} // if
-				env.add( std::move(newClass1) );
-			} else {
-				result = false;
-			} // if
-		} else if ( class1 && class2 ) {
-			if ( type1 ) {
-				EqvClass newClass1 = *class1;
-				newClass1.vars.insert( class2->vars.begin(), class2->vars.end() );
-				newClass1.allowWidening = widen1;
-				env.add( std::move(newClass1) );
-			} else {
-				EqvClass newClass2 = *class2;
-				newClass2.vars.insert( class1->vars.begin(), class1->vars.end() );
-				newClass2.allowWidening = widen2;
-				env.add( std::move(newClass2) );
-			} // if
-		} else if ( class1 ) {
-			EqvClass newClass1 = *class1;
-			newClass1.vars.insert( var2->get_name() );
-			newClass1.allowWidening = widen1;
-			env.add( std::move(newClass1) );
-		} else if ( class2 ) {
-			EqvClass newClass2 = *class2;
-			newClass2.vars.insert( var1->get_name() );
-			newClass2.allowWidening = widen2;
-			env.add( std::move(newClass2) );
-		} else {
-			EqvClass newClass;
-			newClass.vars.insert( var1->get_name() );
-			newClass.vars.insert( var2->get_name() );
-			newClass.allowWidening = widen1 && widen2;
-			newClass.data = data;
-			env.add( newClass );
-		} // if
-		delete type1;
-		delete type2;
-		return result;
-	}
-
 	bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) {
 		OpenVarSet closedVars;
@@ -321,9 +173,9 @@
 
 		if ( isopen1 && isopen2 && entry1->second == entry2->second ) {
-			result = bindVarToVar( var1, var2, entry1->second, env, needAssertions, haveAssertions, openVars, widenMode, indexer );
+			result = env.bindVarToVar( var1, var2, entry1->second, needAssertions, haveAssertions, openVars, widenMode, indexer );
 		} else if ( isopen1 ) {
-			result = bindVar( var1, type2, entry1->second, env, needAssertions, haveAssertions, openVars, widenMode, indexer );
+			result = env.bindVar( var1, type2, entry1->second, needAssertions, haveAssertions, openVars, widenMode, indexer );
 		} else if ( isopen2 ) { // TODO: swap widenMode values in call, since type positions are flipped?
-			result = bindVar( var2, type1, entry2->second, env, needAssertions, haveAssertions, openVars, widenMode, indexer );
+			result = env.bindVar( var2, type1, entry2->second, needAssertions, haveAssertions, openVars, widenMode, indexer );
 		} else {
 			PassVisitor<Unify> comparator( type2, env, needAssertions, haveAssertions, openVars, widenMode, indexer );
Index: src/ResolvExpr/Unify.h
===================================================================
--- src/ResolvExpr/Unify.h	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/ResolvExpr/Unify.h	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 13:09:04 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Jul 21 23:09:34 2017
-// Update Count     : 3
+// Last Modified By : Aaron B. Moss
+// Last Modified On : Mon Jun 18 11:58:00 2018
+// Update Count     : 4
 //
 
@@ -21,4 +21,5 @@
 #include "SynTree/Declaration.h"  // for TypeDecl, TypeDecl::Data
 #include "TypeEnvironment.h"      // for AssertionSet, OpenVarSet
+#include "WidenMode.h"            // for WidenMode
 
 class Type;
@@ -29,19 +30,8 @@
 
 namespace ResolvExpr {
-	struct WidenMode {
-		WidenMode( bool widenFirst, bool widenSecond ): widenFirst( widenFirst ), widenSecond( widenSecond ) {}
-		WidenMode &operator|=( const WidenMode &other ) { widenFirst |= other.widenFirst; widenSecond |= other.widenSecond; return *this; }
-		WidenMode &operator&=( const WidenMode &other ) { widenFirst &= other.widenFirst; widenSecond &= other.widenSecond; return *this; }
-		WidenMode operator|( const WidenMode &other ) { WidenMode newWM( *this ); newWM |= other; return newWM; }
-		WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; }
-		operator bool() { return widenFirst && widenSecond; }
-
-		bool widenFirst : 1, widenSecond : 1;
-	};
-
-	bool bindVar( TypeInstType *typeInst, Type *other, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer );
 	bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
 	bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType );
 	bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
+	bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer, Type *&common );
 
 	template< typename Iterator1, typename Iterator2 >
Index: src/ResolvExpr/WidenMode.h
===================================================================
--- src/ResolvExpr/WidenMode.h	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
+++ src/ResolvExpr/WidenMode.h	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -0,0 +1,35 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// WidenMode.h --
+//
+// Author           : Aaron B. Moss
+// Created On       : Mon Jun 18 11:58:00 2018
+// Last Modified By : Aaron B. Moss
+// Last Modified On : Mon Jun 18 11:58:00 2018
+// Update Count     : 1
+//
+
+#pragma once
+
+namespace ResolvExpr {
+	struct WidenMode {
+		WidenMode( bool widenFirst, bool widenSecond ): widenFirst( widenFirst ), widenSecond( widenSecond ) {}
+		WidenMode &operator|=( const WidenMode &other ) { widenFirst |= other.widenFirst; widenSecond |= other.widenSecond; return *this; }
+		WidenMode &operator&=( const WidenMode &other ) { widenFirst &= other.widenFirst; widenSecond &= other.widenSecond; return *this; }
+		WidenMode operator|( const WidenMode &other ) { WidenMode newWM( *this ); newWM |= other; return newWM; }
+		WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; }
+		operator bool() { return widenFirst && widenSecond; }
+
+		bool widenFirst : 1, widenSecond : 1;
+	};
+} // namespace ResolvExpr
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/SynTree/Type.cc
===================================================================
--- src/SynTree/Type.cc	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/SynTree/Type.cc	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Sep 25 15:16:32 2017
-// Update Count     : 38
+// Last Modified On : Fri Jun 22 10:17:19 2018
+// Update Count     : 39
 //
 #include "Type.h"
@@ -69,5 +69,5 @@
 
 // These must remain in the same order as the corresponding bit fields.
-const char * Type::FuncSpecifiersNames[] = { "inline", "fortran", "_Noreturn" };
+const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" };
 const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" };
 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
Index: src/tests/.gitignore
===================================================================
--- src/tests/.gitignore	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/tests/.gitignore	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -1,2 +1,3 @@
 .out/
 .err/
+.type
Index: src/tests/concurrent/coroutineYield.c
===================================================================
--- src/tests/concurrent/coroutineYield.c	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/tests/concurrent/coroutineYield.c	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -5,4 +5,5 @@
 #include <time>
 
+#define __kick_rate 150000ul
 #include "long_tests.h"
 
@@ -25,7 +26,11 @@
 void main(Coroutine& this) {
 	while(true) {
-		sout | "Coroutine 1" | endl;
+		#if !defined(TEST_FOREVER)
+			sout | "Coroutine 1" | endl;
+		#endif
 		yield();
-		sout | "Coroutine 2" | endl;
+		#if !defined(TEST_FOREVER)
+			sout | "Coroutine 2" | endl;
+		#endif
 		suspend();
 	}
@@ -36,7 +41,11 @@
 	Coroutine c;
 	for(int i = 0; TEST(i < N); i++) {
-		sout | "Thread 1" | endl;
+		#if !defined(TEST_FOREVER)
+			sout | "Thread 1" | endl;
+		#endif
 		resume(c);
-		sout | "Thread 2" | endl;
+		#if !defined(TEST_FOREVER)
+			sout | "Thread 2" | endl;
+		#endif
 		yield();
 		KICK_WATCHDOG;
Index: src/tests/concurrent/signal/disjoint.c
===================================================================
--- src/tests/concurrent/signal/disjoint.c	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/tests/concurrent/signal/disjoint.c	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -69,7 +69,8 @@
 	}
 
-	d.counter++;
-
-	if( (d.counter % 1000) == 0 ) sout | d.counter | endl;
+	#if !defined(TEST_FOREVER)
+		d.counter++;
+		if( (d.counter % 1000) == 0 ) sout | d.counter | endl;
+	#endif
 
 	return TEST(d.counter < N);
Index: src/tests/concurrent/signal/wait.c
===================================================================
--- src/tests/concurrent/signal/wait.c	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/tests/concurrent/signal/wait.c	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -12,4 +12,5 @@
 #include <time>
 
+#define __kick_rate 12000ul
 #include "long_tests.h"
 
Index: src/tests/long_tests.h
===================================================================
--- src/tests/long_tests.h	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/tests/long_tests.h	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -4,11 +4,18 @@
 
 #if   defined(TEST_FOREVER)
+
+static unsigned long long __kick_count = 0;
+#if !defined(__kick_rate)
+#define __kick_rate 5000ul
+#endif
+
 #define TEST(x) 1
-#define KICK_WATCHDOG write(STDOUT_FILENO, ".", 1)
-#elif defined(TEST_LONG)
+#define KICK_WATCHDOG do { __kick_count++; if(__kick_count > __kick_rate) { write(STDOUT_FILENO, ".", 1); __kick_count = 0; } } while(0)
+
+
+#else
+
 #define TEST(x) x
 #define KICK_WATCHDOG
-#else
-#define TEST(x) x
-#define KICK_WATCHDOG
+
 #endif
Index: src/tests/preempt_longrun/Makefile.am
===================================================================
--- src/tests/preempt_longrun/Makefile.am	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/tests/preempt_longrun/Makefile.am	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -25,5 +25,10 @@
 TIME = /usr/bin/time -f "%E"
 
-BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -I.. -I. -DTEST_$(shell echo $(type) | tr a-z A-Z)
+# $(shell ./update-type $(type))
+# ./update-type $(type)
+
+UPDATED_TYPE = $(shell ./update-type $(type))
+
+BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -I.. -I. -DTEST_$(shell cat .type | tr a-z A-Z)
 CFLAGS = ${BUILD_FLAGS}
 CC = @CFA_BINDIR@/@CFA_NAME@
@@ -45,7 +50,7 @@
 
 clean-local:
-	rm -f ${TESTS} core* out.log
+	rm -f ${TESTS} core* out.log .type
 
-% : %.c ${CC}
+% : %.c ${CC} ${UPDATED_TYPE}
 	${AM_V_GEN}${CC} ${CFLAGS} ${<} $(debug) -o ${@}
 
Index: src/tests/preempt_longrun/Makefile.in
===================================================================
--- src/tests/preempt_longrun/Makefile.in	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/tests/preempt_longrun/Makefile.in	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -456,5 +456,9 @@
 WATCHDOG = ${abs_top_srcdir}/tools/watchdog
 TIME = /usr/bin/time -f "%E"
-BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -I.. -I. -DTEST_$(shell echo $(type) | tr a-z A-Z)
+
+# $(shell ./update-type $(type))
+# ./update-type $(type)
+UPDATED_TYPE = $(shell ./update-type $(type))
+BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -I.. -I. -DTEST_$(shell cat .type | tr a-z A-Z)
 TESTS = block coroutine create disjoint enter enter3 processor stack wait yield
 all: all-am
@@ -889,7 +893,7 @@
 
 clean-local:
-	rm -f ${TESTS} core* out.log
-
-% : %.c ${CC}
+	rm -f ${TESTS} core* out.log .type
+
+% : %.c ${CC} ${UPDATED_TYPE}
 	${AM_V_GEN}${CC} ${CFLAGS} ${<} $(debug) -o ${@}
 
Index: src/tests/preempt_longrun/enter.c
===================================================================
--- src/tests/preempt_longrun/enter.c	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/tests/preempt_longrun/enter.c	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -4,4 +4,5 @@
 #include <time>
 
+#define __kick_rate 75000ul
 #include "long_tests.h"
 
Index: src/tests/preempt_longrun/enter3.c
===================================================================
--- src/tests/preempt_longrun/enter3.c	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/tests/preempt_longrun/enter3.c	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -4,4 +4,5 @@
 #include <time>
 
+#define __kick_rate 75000ul
 #include "long_tests.h"
 
Index: src/tests/preempt_longrun/stack.c
===================================================================
--- src/tests/preempt_longrun/stack.c	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/tests/preempt_longrun/stack.c	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -4,4 +4,5 @@
 #include <time>
 
+#define __kick_rate 5000000ul
 #include "long_tests.h"
 
@@ -17,15 +18,17 @@
 
 void main(worker_t & this) {
-	volatile long long p = 5_021_609ul;
-	volatile long long a = 326_417ul;
-	volatile long long n = 1l;
-	for (volatile long long i = 0; TEST(i < p); i++) {
-		n *= a;
-		n %= p;
-		KICK_WATCHDOG;
-	}
+	while(TEST(0)) {
+		volatile long long p = 5_021_609ul;
+		volatile long long a = 326_417ul;
+		volatile long long n = 1l;
+		for (volatile long long i = 0; i < p; i++) {
+			n *= a;
+			n %= p;
+			KICK_WATCHDOG;
+		}
 
-	if( !TEST(n == a) ) {
-		abort();
+		if( !TEST(n == a) ) {
+			abort();
+		}
 	}
 }
Index: src/tests/preempt_longrun/update-type
===================================================================
--- src/tests/preempt_longrun/update-type	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
+++ src/tests/preempt_longrun/update-type	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+if [ "$#" -ne 1 ]
+then
+	echo "illegal number of parameters, must be 1 was $#"
+	exit
+fi
+
+NEW="$(echo $1 | tr a-z A-Z)"
+TYPE_FILE=".type"
+if [ -f "$TYPE_FILE" ]
+then
+	OLD="$(cat $TYPE_FILE | tr a-z A-Z)"
+	if [ $OLD == $NEW ]
+	then
+		echo > /dev/null
+		# echo "$TYPE_FILE stayed unchanged"
+	else
+		echo "$NEW" > "$TYPE_FILE"
+		# echo "$TYPE_FILE changed from '$OLD' to '$NEW'"
+	fi
+else
+	echo "$NEW" > "$TYPE_FILE"
+fi
+echo "$TYPE_FILE"
Index: src/tests/preempt_longrun/yield.c
===================================================================
--- src/tests/preempt_longrun/yield.c	(revision a12c81f30d4d4bc145747889f469cda8edb98b21)
+++ src/tests/preempt_longrun/yield.c	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -3,4 +3,5 @@
 #include <time>
 
+#define __kick_rate 550000ul
 #include "long_tests.h"
 
