Index: doc/papers/concurrency/Paper.tex
===================================================================
--- doc/papers/concurrency/Paper.tex	(revision 7b28e4ace0ec445f539a338c9970ea62ff93af8b)
+++ doc/papers/concurrency/Paper.tex	(revision 332d3c2b316eac5592b52393f9afbc00ef2439c5)
@@ -1540,242 +1540,24 @@
 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.
 
-Both internal and external scheduling extend to multiple monitors in a natural way.
-\begin{cquote}
-\begin{tabular}{@{}l@{\hspace{3\parindentlnth}}l@{}}
-\begin{cfa}
-monitor M { `condition e`; ... };
-void foo( M & mutex m1, M & mutex m2 ) {
-	... wait( `e` ); ...   // wait( e, m1, m2 )
-	... wait( `e, m1` ); ...
-	... wait( `e, m2` ); ...
-}
-\end{cfa}
-&
-\begin{cfa}
-void rtn$\(_1\)$( M & mutex m1, M & mutex m2 );
-void rtn$\(_2\)$( M & mutex m1 );
-void bar( M & mutex m1, M & mutex m2 ) {
-	... waitfor( `rtn` ); ...       // $\LstCommentStyle{waitfor( rtn\(_1\), m1, m2 )}$
-	... waitfor( `rtn, m1` ); ... // $\LstCommentStyle{waitfor( rtn\(_2\), m1 )}$
-}
-\end{cfa}
-\end{tabular}
-\end{cquote}
-For @wait( e )@, the default semantics is to atomically block the signaller and release all acquired mutex types in the parameter list, \ie @wait( e, m1, m2 )@.
-To override the implicit multi-monitor wait, specific mutex parameter(s) can be specified, \eg @wait( e, m1 )@.
-Wait statically verifies the released monitors are the acquired mutex-parameters so unconditional release is safe.
-Finally, a signaller,
-\begin{cfa}
-void baz( M & mutex m1, M & mutex m2 ) {
-	... signal( e ); ...
-}
-\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.
-
-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.
-To statically verify the released monitors match with the accepted routine's mutex parameters, the routine (pointer) prototype must be accessible.
-
-Given the ability to release a subset of acquired monitors can result in a \newterm{nested monitor}~\cite{Lister77} deadlock.
-\begin{cfa}
-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 )}$
-	... 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@.
-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.
-
-Finally, an important aspect of monitor implementation is barging, \ie can calling threads barge ahead of signalled threads?
-If barging is allowed, synchronization between a singller and signallee is difficult, often requiring multiple unblock/block cycles (looping around a wait rechecking if a condition is met).
-\begin{quote}
-However, we decree that a signal operation be followed immediately by resumption of a waiting program, without possibility of an intervening procedure call from yet a third program.
-It is only in this way that a waiting program has an absolute guarantee that it can acquire the resource just released by the signalling program without any danger that a third program will interpose a monitor entry and seize the resource instead.~\cite[p.~550]{Hoare74}
-\end{quote}
-\CFA scheduling \emph{precludes} barging, which simplifies synchronization among threads in the monitor and increases correctness.
-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.
-
-
-\subsection{Barging Prevention}
-
-Figure~\ref{f:BargingPrevention} shows \CFA code where bulk acquire adds complexity to the internal-signalling semantics.
-The complexity begins at the end of the inner @mutex@ statement, where the semantics of internal scheduling need to be extended for multiple monitors.
-The problem is that bulk acquire is used in the inner @mutex@ statement where one of the monitors is already acquired.
-When the signalling thread reaches the end of the inner @mutex@ statement, it should transfer ownership of @m1@ and @m2@ to the waiting threads to prevent barging into the outer @mutex@ statement by another thread.
-However, both the signalling and waiting thread W1 still need monitor @m1@.
-
-\begin{figure}
-\newbox\myboxA
-\begin{lrbox}{\myboxA}
-\begin{cfa}[aboveskip=0pt,belowskip=0pt]
-monitor M m1, m2;
-condition c;
-mutex( m1 ) { // $\LstCommentStyle{\color{red}outer}$
-	...
-	mutex( m1, m2 ) { // $\LstCommentStyle{\color{red}inner}$
-		... `signal( c )`; ...
-		// m1, m2 acquired
-	} // $\LstCommentStyle{\color{red}release m2}$
-	// m1 acquired
-} // release m1
-\end{cfa}
-\end{lrbox}
-
-\newbox\myboxB
-\begin{lrbox}{\myboxB}
-\begin{cfa}[aboveskip=0pt,belowskip=0pt]
-
-
-mutex( m1 ) {
-	...
-	mutex( m1, m2 ) {
-		... `wait( c )`; // block and release m1, m2
-		// m1, m2 acquired
-	} // $\LstCommentStyle{\color{red}release m2}$
-	// m1 acquired
-} // release m1
-\end{cfa}
-\end{lrbox}
-
-\newbox\myboxC
-\begin{lrbox}{\myboxC}
-\begin{cfa}[aboveskip=0pt,belowskip=0pt]
-
-
-mutex( m2 ) {
-	... `wait( c )`; ...
-	// m2 acquired
-} // $\LstCommentStyle{\color{red}release m2}$
-
-
-
-
-\end{cfa}
-\end{lrbox}
-
-\begin{cquote}
-\subfloat[Signalling Thread]{\label{f:SignallingThread}\usebox\myboxA}
-\hspace{2\parindentlnth}
-\subfloat[Waiting Thread (W1)]{\label{f:WaitingThread}\usebox\myboxB}
-\hspace{2\parindentlnth}
-\subfloat[Waiting Thread (W2)]{\label{f:OtherWaitingThread}\usebox\myboxC}
-\end{cquote}
-\caption{Barging Prevention}
-\label{f:BargingPrevention}
-\end{figure}
-
-One scheduling solution is for the signaller to keep ownership of all locks until the last lock is ready to be transferred, because this semantics fits most closely to the behaviour of single-monitor scheduling.
-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.
-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.
-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}
-
-
-\subsection{Signalling: Now or Later}
+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.
+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 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.
 
 \begin{figure}
@@ -1839,22 +1621,246 @@
 \subfloat[\lstinline@signal_block@]{\label{f:DatingSignalBlock}\usebox\myboxB}
 \caption{Dating service. }
-\label{f:Dating service}
+\label{f:DatingService}
 \end{figure}
 
-An important note is that, until now, signalling a monitor was a delayed operation.
-The ownership of the monitor is transferred only when the monitor would have otherwise been released, not at the point of the @signal@ statement.
-However, in some cases, it may be more convenient for users to immediately transfer ownership to the thread that is waiting for cooperation, which is achieved using the @signal_block@ routine.
-
-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.
-
-% ======================================================================
-% ======================================================================
+Both internal and external scheduling extend to multiple monitors in a natural way.
+\begin{cquote}
+\begin{tabular}{@{}l@{\hspace{3\parindentlnth}}l@{}}
+\begin{cfa}
+monitor M { `condition e`; ... };
+void foo( M & mutex m1, M & mutex m2 ) {
+	... wait( `e` ); ...   // wait( e, m1, m2 )
+	... wait( `e, m1` ); ...
+	... wait( `e, m2` ); ...
+}
+\end{cfa}
+&
+\begin{cfa}
+void rtn$\(_1\)$( M & mutex m1, M & mutex m2 );
+void rtn$\(_2\)$( M & mutex m1 );
+void bar( M & mutex m1, M & mutex m2 ) {
+	... waitfor( `rtn` ); ...       // $\LstCommentStyle{waitfor( rtn\(_1\), m1, m2 )}$
+	... waitfor( `rtn, m1` ); ... // $\LstCommentStyle{waitfor( rtn\(_2\), m1 )}$
+}
+\end{cfa}
+\end{tabular}
+\end{cquote}
+For @wait( e )@, the default semantics is to atomically block the signaller and release all acquired mutex types in the parameter list, \ie @wait( e, m1, m2 )@.
+To override the implicit multi-monitor wait, specific mutex parameter(s) can be specified, \eg @wait( e, m1 )@.
+Wait statically verifies the released monitors are the acquired mutex-parameters so unconditional release is safe.
+Finally, a signaller,
+\begin{cfa}
+void baz( M & mutex m1, M & mutex m2 ) {
+	... signal( e ); ...
+}
+\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.
+
+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.
+To statically verify the released monitors match with the accepted routine's mutex parameters, the routine (pointer) prototype must be accessible.
+
+Given the ability to release a subset of acquired monitors can result in a \newterm{nested monitor}~\cite{Lister77} deadlock.
+\begin{cfa}
+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 )}$
+	... 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@.
+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.
+
+Finally, an important aspect of monitor implementation is barging, \ie can calling threads barge ahead of signalled threads?
+If barging is allowed, synchronization between a singller and signallee is difficult, often requiring multiple unblock/block cycles (looping around a wait rechecking if a condition is met).
+\begin{quote}
+However, we decree that a signal operation be followed immediately by resumption of a waiting program, without possibility of an intervening procedure call from yet a third program.
+It is only in this way that a waiting program has an absolute guarantee that it can acquire the resource just released by the signalling program without any danger that a third program will interpose a monitor entry and seize the resource instead.~\cite[p.~550]{Hoare74}
+\end{quote}
+\CFA scheduling \emph{precludes} barging, which simplifies synchronization among threads in the monitor and increases correctness.
+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.
+
+
+\subsection{Barging Prevention}
+
+Figure~\ref{f:BargingPrevention} shows \CFA code where bulk acquire adds complexity to the internal-signalling semantics.
+The complexity begins at the end of the inner @mutex@ statement, where the semantics of internal scheduling need to be extended for multiple monitors.
+The problem is that bulk acquire is used in the inner @mutex@ statement where one of the monitors is already acquired.
+When the signalling thread reaches the end of the inner @mutex@ statement, it should transfer ownership of @m1@ and @m2@ to the waiting threads to prevent barging into the outer @mutex@ statement by another thread.
+However, both the signalling and waiting thread W1 still need monitor @m1@.
+
+\begin{figure}
+\newbox\myboxA
+\begin{lrbox}{\myboxA}
+\begin{cfa}[aboveskip=0pt,belowskip=0pt]
+monitor M m1, m2;
+condition c;
+mutex( m1 ) { // $\LstCommentStyle{\color{red}outer}$
+	...
+	mutex( m1, m2 ) { // $\LstCommentStyle{\color{red}inner}$
+		... `signal( c )`; ...
+		// m1, m2 acquired
+	} // $\LstCommentStyle{\color{red}release m2}$
+	// m1 acquired
+} // release m1
+\end{cfa}
+\end{lrbox}
+
+\newbox\myboxB
+\begin{lrbox}{\myboxB}
+\begin{cfa}[aboveskip=0pt,belowskip=0pt]
+
+
+mutex( m1 ) {
+	...
+	mutex( m1, m2 ) {
+		... `wait( c )`; // block and release m1, m2
+		// m1, m2 acquired
+	} // $\LstCommentStyle{\color{red}release m2}$
+	// m1 acquired
+} // release m1
+\end{cfa}
+\end{lrbox}
+
+\newbox\myboxC
+\begin{lrbox}{\myboxC}
+\begin{cfa}[aboveskip=0pt,belowskip=0pt]
+
+
+mutex( m2 ) {
+	... `wait( c )`; ...
+	// m2 acquired
+} // $\LstCommentStyle{\color{red}release m2}$
+
+
+
+
+\end{cfa}
+\end{lrbox}
+
+\begin{cquote}
+\subfloat[Signalling Thread]{\label{f:SignallingThread}\usebox\myboxA}
+\hspace{2\parindentlnth}
+\subfloat[Waiting Thread (W1)]{\label{f:WaitingThread}\usebox\myboxB}
+\hspace{2\parindentlnth}
+\subfloat[Waiting Thread (W2)]{\label{f:OtherWaitingThread}\usebox\myboxC}
+\end{cquote}
+\caption{Barging Prevention}
+\label{f:BargingPrevention}
+\end{figure}
+
+One scheduling solution is for the signaller to keep ownership of all locks until the last lock is ready to be transferred, because this semantics fits most closely to the behaviour of single-monitor scheduling.
+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.
+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.
+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}).
 
