Index: doc/theses/colby_parsons_MMAth/text/mutex_stmt.tex
===================================================================
--- doc/theses/colby_parsons_MMAth/text/mutex_stmt.tex	(revision aae9c1797b4b9d902f4bd84cca9600885f694007)
+++ doc/theses/colby_parsons_MMAth/text/mutex_stmt.tex	(revision 9509d67a48906b243fdd5104ab679d3e1ea4a532)
@@ -83,5 +83,5 @@
 \end{figure}
 
-Like Java, \CFA monitors have \Newterm{multi-acquire} semantics so the thread in the monitor may acquire it multiple times without deadlock, allowing recursion and calling of other MX functions.
+Like Java, \CFA monitors have \Newterm{multi-acquire} (reentrant locking) semantics so the thread in the monitor may acquire it multiple times without deadlock, allowing recursion and calling of other MX functions.
 For robustness, \CFA monitors ensure the monitor lock is released regardless of how an acquiring function ends, normal or exceptional, and returning a shared variable is safe via copying before the lock is released.
 Monitor objects can be passed through multiple helper functions without acquiring mutual exclusion, until a designated function associated with the object is called.
@@ -104,5 +104,6 @@
 }
 \end{cfa}
-The \CFA monitor implementation ensures multi-lock acquisition is done in a deadlock-free manner regardless of the number of MX parameters and monitor arguments. It it important to note that \CFA monitors do not attempt to solve the nested monitor problem~\cite{Lister77}.
+The \CFA monitor implementation ensures multi-lock acquisition is done in a deadlock-free manner regardless of the number of MX parameters and monitor arguments via resource ordering.
+It it important to note that \CFA monitors do not attempt to solve the nested monitor problem~\cite{Lister77}.
 
 \section{\lstinline{mutex} statement}
@@ -165,5 +166,6 @@
 In detail, the mutex statement has a clause and statement block, similar to a conditional or loop statement.
 The clause accepts any number of lockable objects (like a \CFA MX function prototype), and locks them for the duration of the statement.
-The locks are acquired in a deadlock free manner and released regardless of how control-flow exits the statement.
+The locks are acquired in a deadlock-free manner and released regardless of how control-flow exits the statement.
+Note that this deadlock-freedom has some limitations \see{\VRef{s:DeadlockAvoidance}}.
 The mutex statement provides easy lock usage in the common case of lexically wrapping a CS.
 Examples of \CFA mutex statement are shown in \VRef[Listing]{l:cfa_mutex_ex}.
@@ -210,5 +212,5 @@
 Like Java, \CFA introduces a new statement rather than building from existing language features, although \CFA has sufficient language features to mimic \CC RAII locking.
 This syntactic choice makes MX explicit rather than implicit via object declarations.
-Hence, it is easier for programmers and language tools to identify MX points in a program, \eg scan for all @mutex@ parameters and statements in a body of code.
+Hence, it is easy for programmers and language tools to identify MX points in a program, \eg scan for all @mutex@ parameters and statements in a body of code; similar scanning can be done with Java's @synchronized@.
 Furthermore, concurrent safety is provided across an entire program for the complex operation of acquiring multiple locks in a deadlock-free manner.
 Unlike Java, \CFA's mutex statement and \CC's @scoped_lock@ both use parametric polymorphism to allow user defined types to work with this feature.
@@ -231,5 +233,5 @@
 thread$\(_2\)$ : sout | "uvw" | "xyz";
 \end{cfa}
-any of the outputs can appear, included a segment fault due to I/O buffer corruption:
+any of the outputs can appear:
 \begin{cquote}
 \small\tt
@@ -260,9 +262,8 @@
 mutex( sout ) {	// acquire stream lock for sout for block duration
 	sout | "abc";
-	mutex( sout ) sout | "uvw" | "xyz"; // OK because sout lock is recursive
+	sout | "uvw" | "xyz";
 	sout | "def";
 } // implicitly release sout lock
 \end{cfa}
-The inner lock acquire is likely to occur through a function call that does a thread-safe print.
 
 \section{Deadlock Avoidance}\label{s:DeadlockAvoidance}
@@ -309,6 +310,8 @@
 For fewer than 7 locks ($2^3-1$), the sort is unrolled performing the minimum number of compare and swaps for the given number of locks;
 for 7 or more locks, insertion sort is used.
-Since it is extremely rare to hold more than 6 locks at a time, the algorithm is fast and executes in $O(1)$ time.
-Furthermore, lock addresses are unique across program execution, even for dynamically allocated locks, so the algorithm is safe across the entire program execution.
+It is assumed to be rare to hold more than 6 locks at a time.
+For 6 or fewer locks the algorithm is fast and executes in $O(1)$ time.
+Furthermore, lock addresses are unique across program execution, even for dynamically allocated locks, so the algorithm is safe across the entire program execution, as long as lifetimes of objects are appropriately managed. 
+For example, deleting a lock and allocating another one could give the new lock the same address as the deleted one, however deleting a lock in use by another thread is a programming error irrespective of the usage of the @mutex@ statement.
 
 The downside to the sorting approach is that it is not fully compatible with manual usages of the same locks outside the @mutex@ statement, \ie the lock are acquired without using the @mutex@ statement.
@@ -338,5 +341,5 @@
 \end{cquote}
 Comparatively, if the @scoped_lock@ is used and the same locks are acquired elsewhere, there is no concern of the @scoped_lock@ deadlocking, due to its avoidance scheme, but it may livelock.
-The convenience and safety of the @mutex@ statement, \ie guaranteed lock release with exceptions, should encourage programmers to always use it for locking, mitigating any deadlock scenario versus combining manual locking with the mutex statement.
+The convenience and safety of the @mutex@ statement, \ie guaranteed lock release with exceptions, should encourage programmers to always use it for locking, mitigating most deadlock scenarios versus combining manual locking with the mutex statement.
 Both \CC and the \CFA do not provide any deadlock guarantees for nested @scoped_lock@s or @mutex@ statements. 
 To do so would require solving the nested monitor problem~\cite{Lister77}, which currently does not have any practical solutions.
@@ -344,5 +347,5 @@
 \section{Performance}
 Given the two multi-acquisition algorithms in \CC and \CFA, each with differing advantages and disadvantages, it interesting to compare their performance.
-Comparison with Java is not possible, since it only takes a single lock.
+Comparison with Java was not conducted, since the synchronized statement only takes a single object and does not provide deadlock avoidance or prevention.
 
 The comparison starts with a baseline that acquires the locks directly without a mutex statement or @scoped_lock@ in a fixed ordering and then releases them.
@@ -356,4 +359,5 @@
 Each variation is run 11 times on 2, 4, 8, 16, 24, 32 cores and with 2, 4, and 8 locks being acquired.
 The median is calculated and is plotted alongside the 95\% confidence intervals for each point.
+The confidence intervals are calculated using bootstrapping to avoid normality assumptions.
 
 \begin{figure}
@@ -388,5 +392,5 @@
 }
 \end{cfa}
-\caption{Deadlock avoidance benchmark pseudocode}
+\caption{Deadlock avoidance benchmark \CFA pseudocode}
 \label{l:deadlock_avoid_pseudo}
 \end{figure}
@@ -396,7 +400,7 @@
 % sudo dmidecode -t system
 \item
-Supermicro AS--1123US--TR4 AMD EPYC 7662 64--core socket, hyper-threading $\times$ 2 sockets (256 processing units) 2.0 GHz, TSO memory model, running Linux v5.8.0--55--generic, gcc--10 compiler
+Supermicro AS--1123US--TR4 AMD EPYC 7662 64--core socket, hyper-threading $\times$ 2 sockets (256 processing units), TSO memory model, running Linux v5.8.0--55--generic, gcc--10 compiler
 \item
-Supermicro SYS--6029U--TR4 Intel Xeon Gold 5220R 24--core socket, hyper-threading $\times$ 2 sockets (48 processing units) 2.2GHz, TSO memory model, running Linux v5.8.0--59--generic, gcc--10 compiler
+Supermicro SYS--6029U--TR4 Intel Xeon Gold 5220R 24--core socket, hyper-threading $\times$ 2 sockets (96 processing units), TSO memory model, running Linux v5.8.0--59--generic, gcc--10 compiler
 \end{list}
 %The hardware architectures are different in threading (multithreading vs hyper), cache structure (MESI or MESIF), NUMA layout (QPI vs HyperTransport), memory model (TSO vs WO), and energy/thermal mechanisms (turbo-boost).
@@ -411,9 +415,10 @@
 For example, on the AMD machine with 32 threads and 8 locks, the benchmarks would occasionally livelock indefinitely, with no threads making any progress for 3 hours before the experiment was terminated manually.
 It is likely that shorter bouts of livelock occurred in many of the experiments, which would explain large confidence intervals for some of the data points in the \CC data.
-In Figures~\ref{f:mutex_bench8_AMD} and \ref{f:mutex_bench8_Intel} there is the counter-intuitive result of the mutex statement performing better than the baseline.
+In Figures~\ref{f:mutex_bench8_AMD} and \ref{f:mutex_bench8_Intel} there is the counter-intuitive result of the @mutex@ statement performing better than the baseline.
 At 7 locks and above the mutex statement switches from a hard coded sort to insertion sort, which should decrease performance.
 The hard coded sort is branch-free and constant-time and was verified to be faster than insertion sort for 6 or fewer locks.
-It is likely the increase in throughput compared to baseline is due to the delay spent in the insertion sort, which decreases contention on the locks.
-
+Part of the difference in throughput compared to baseline is due to the delay spent in the insertion sort, which decreases contention on the locks.
+This was verified to be part of the difference in throughput by experimenting with varying NCS delays in the baseline; however it only comprises a small portion of difference.
+It is possible that the baseline is slowed down or the @mutex@ is sped up by other factors that are not easily identifiable.
 
 \begin{figure}
