Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/cfa/contend.cfa
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/cfa/contend.cfa	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/cfa/contend.cfa	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,99 @@
+#include <select.hfa>
+#include <thread.hfa>
+#include <channel.hfa>
+#include <locks.hfa>
+#include <fstream.hfa>
+#include <stdio.h>
+#include <time.hfa>
+#include <string.h>
+
+// #define NUM_CHANS 1
+#define GLUE_HELPER(x, y) x##y
+#define FN_GLUE(x, y) GLUE_HELPER(x, y)
+
+size_t Processors = 2, Producers = 1, Consumers = 1, ChannelSize = 10;
+
+channel(size_t) * chans;
+
+static inline void cons_wait_1( size_t & val ) { waituntil( val << chans[0] ) {} }
+static inline void cons_wait_2( size_t & val ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} }
+static inline void cons_wait_3( size_t & val ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} }
+static inline void cons_wait_4( size_t & val ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} or waituntil( val << chans[3] ) {} }
+static inline void cons_wait_5( size_t & val ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} or waituntil( val << chans[3] ) {} or waituntil( val << chans[4] ) {} }
+static inline void cons_wait_6( size_t & val ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} or waituntil( val << chans[3] ) {} or waituntil( val << chans[4] ) {} or waituntil( val << chans[5] ) {} }
+static inline void cons_wait_7( size_t & val ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} or waituntil( val << chans[3] ) {} or waituntil( val << chans[4] ) {} or waituntil( val << chans[5] ) {} or waituntil( val << chans[6] ) {} }
+static inline void cons_wait_8( size_t & val ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} or waituntil( val << chans[3] ) {} or waituntil( val << chans[4] ) {} or waituntil( val << chans[5] ) {} or waituntil( val << chans[6] ) {} or waituntil( val << chans[7] ) {}}
+
+static inline void prods_wait_1( size_t val ) { waituntil( val >> chans[0] ) {} }
+static inline void prods_wait_2( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} }
+static inline void prods_wait_3( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} }
+static inline void prods_wait_4( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} or waituntil( val >> chans[3] ) {} }
+static inline void prods_wait_5( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} or waituntil( val >> chans[3] ) {} or waituntil( val >> chans[4] ) {} }
+static inline void prods_wait_6( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} or waituntil( val >> chans[3] ) {} or waituntil( val >> chans[4] ) {} or waituntil( val >> chans[5] ) {} }
+static inline void prods_wait_7( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} or waituntil( val >> chans[3] ) {} or waituntil( val >> chans[4] ) {} or waituntil( val >> chans[5] ) {} or waituntil( val >> chans[6] ) {} }
+static inline void prods_wait_8( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} or waituntil( val >> chans[3] ) {} or waituntil( val >> chans[4] ) {} or waituntil( val >> chans[5] ) {} or waituntil( val >> chans[6] ) {} or waituntil( val >> chans[7] ) {}}
+
+size_t globalTotal = 0;
+
+thread Consumer {};
+void main( Consumer & this ) {
+    size_t val, i = 0;
+    try {
+        for(;; i++ ) {
+            FN_GLUE(cons_wait_, NUM_CHANS)(val);
+        }
+    } catch( channel_closed * e ) {}
+    __atomic_fetch_add( &globalTotal, i, __ATOMIC_SEQ_CST );
+}
+
+thread Producer {};
+void main( Producer & this ) {
+    try {
+        for( size_t i = 0;; i++ ) {
+            FN_GLUE(prods_wait_, NUM_CHANS)(i);
+        }
+    } catch( channel_closed * e ) {}
+}
+
+int main( int argc, char * argv[] ) {
+    switch ( argc ) {
+	  case 3:
+		if ( strcmp( argv[2], "d" ) != 0 ) {			// default ?
+			ChannelSize = atoi( argv[2] );
+		} // if
+	  case 2:
+		if ( strcmp( argv[1], "d" ) != 0 ) {			// default ?
+			Processors = atoi( argv[1] );
+			if ( Processors < 1 ) goto Usage;
+		} // if
+	  case 1:											// use defaults
+		break;
+	  default:
+	  Usage:
+		sout | "Usage: " | argv[0]
+             | " [ processors (> 0) | 'd' (default " | Processors
+			 | ") ] [ channel size (>= 0) | 'd' (default " | ChannelSize
+			 | ") ]" ;
+		exit( EXIT_FAILURE );
+	} // switch
+    Producers = Processors / 2;
+    Consumers = Processors / 2;
+
+    processor p[Processors - 1];
+
+    chans = aalloc( NUM_CHANS );
+    for ( i; NUM_CHANS )
+        chans[i]{ ChannelSize };
+
+    {
+        Producer p[Producers];
+        Consumer c[Consumers];
+
+        sleep(10`s);
+
+        for ( i; NUM_CHANS )
+            close( chans[i] );
+    }
+    adelete( chans );
+    printf("%zu\n", globalTotal);
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/cfa/sidechan.cfa
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/cfa/sidechan.cfa	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/cfa/sidechan.cfa	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,100 @@
+#include <select.hfa>
+#include <thread.hfa>
+#include <channel.hfa>
+#include <locks.hfa>
+#include <fstream.hfa>
+#include <stdio.h>
+#include <time.hfa>
+#include <string.h>
+
+size_t Sets = 1, ChannelSize = 100, Channels = 2;
+
+channel(size_t) * chans;
+
+size_t globalTotal = 0;
+int cons_counter = 0, prod_counter = 0;
+
+thread SelectConsumer {};
+void main( SelectConsumer & this ) {
+    size_t val, i = 0;
+    try {
+        for(;; i++ ) {
+            waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {}
+        }
+    } catch( channel_closed * e ) {}
+    __atomic_fetch_add( &globalTotal, i, __ATOMIC_SEQ_CST );
+}
+
+thread SelectProducer {};
+void main( SelectProducer & this ) {
+    try {
+        for( size_t i = 0;; i++ ) {
+            waituntil( i >> chans[0] ) {} or waituntil( i >> chans[1] ) {}
+        }
+    } catch( channel_closed * e ) {}
+}
+
+thread Consumer {};
+void main( Consumer & this ) {
+    int idx = __atomic_fetch_add( &cons_counter, 1, __ATOMIC_SEQ_CST ) % Channels;
+    size_t val, i = 0;
+    try {
+        for(;; i++ ) {
+            remove( chans[idx] );
+        }
+    } catch( channel_closed * e ) {}
+    __atomic_fetch_add( &globalTotal, i, __ATOMIC_SEQ_CST );
+}
+
+thread Producer {};
+void main( Producer & this ) {
+    int idx = __atomic_fetch_add( &prod_counter, 1, __ATOMIC_SEQ_CST ) % Channels;
+    try {
+        for( size_t i = 0;; i++ ) {
+            insert( chans[idx], i );
+        }
+    } catch( channel_closed * e ) {}
+}
+
+int main( int argc, char * argv[] ) {
+    switch ( argc ) {
+	  case 3:
+		if ( strcmp( argv[2], "d" ) != 0 ) {			// default ?
+			ChannelSize = atoi( argv[2] );
+		} // if
+	  case 2:
+		if ( strcmp( argv[1], "d" ) != 0 ) {			// default ?
+			Sets = atoi( argv[1] );
+			if ( Sets < 1 ) goto Usage;
+		} // if
+	  case 1:											// use defaults
+		break;
+	  default:
+	  Usage:
+		sout | "Usage: " | argv[0]
+             | " [ sets (> 0) | 'd' (default " | Sets
+			 | ") ] [ channel size (>= 0) | 'd' (default " | ChannelSize
+			 | ") ]" ;
+		exit( EXIT_FAILURE );
+	} // switch
+
+    processor p[Sets * 2 + Sets * Channels * 2 - 1];
+
+    chans = aalloc( Channels );
+    for ( i; Channels )
+        chans[i]{ ChannelSize };
+
+    {
+        Producer p[Sets * Channels];
+        SelectProducer sp[Sets];
+        Consumer c[Sets * Channels];
+        SelectConsumer sc[Sets];
+
+        sleep(10`s);
+
+        for ( i; Channels )
+            close( chans[i] );
+    }
+    adelete( chans );
+    printf("%zu\n", globalTotal);
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/cfa/spin.cfa
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/cfa/spin.cfa	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/cfa/spin.cfa	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,99 @@
+#include <select.hfa>
+#include <thread.hfa>
+#include <channel.hfa>
+#include <locks.hfa>
+#include <fstream.hfa>
+#include <stdio.h>
+#include <time.hfa>
+#include <string.h>
+
+// #define NUM_CHANS 1
+#define GLUE_HELPER(x, y) x##y
+#define FN_GLUE(x, y) GLUE_HELPER(x, y)
+
+size_t Processors = 2, Producers = 1, Consumers = 1, ChannelSize = 10;
+
+channel(size_t) * chans;
+
+static inline void cons_wait_1( size_t & val, size_t & i ) { waituntil( val << chans[0] ) {} or else { i--; }  }
+static inline void cons_wait_2( size_t & val, size_t & i ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or else { i--; }  }
+static inline void cons_wait_3( size_t & val, size_t & i ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} or else { i--; }  }
+static inline void cons_wait_4( size_t & val, size_t & i ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} or waituntil( val << chans[3] ) {} or else { i--; }  }
+static inline void cons_wait_5( size_t & val, size_t & i ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} or waituntil( val << chans[3] ) {} or waituntil( val << chans[4] ) {} or else { i--; }  }
+static inline void cons_wait_6( size_t & val, size_t & i ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} or waituntil( val << chans[3] ) {} or waituntil( val << chans[4] ) {} or waituntil( val << chans[5] ) {} or else { i--; }  }
+static inline void cons_wait_7( size_t & val, size_t & i ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} or waituntil( val << chans[3] ) {} or waituntil( val << chans[4] ) {} or waituntil( val << chans[5] ) {} or waituntil( val << chans[6] ) {} or else { i--; }  }
+static inline void cons_wait_8( size_t & val, size_t & i ) { waituntil( val << chans[0] ) {} or waituntil( val << chans[1] ) {} or waituntil( val << chans[2] ) {} or waituntil( val << chans[3] ) {} or waituntil( val << chans[4] ) {} or waituntil( val << chans[5] ) {} or waituntil( val << chans[6] ) {} or waituntil( val << chans[7] ) {} or else { i--; } }
+
+static inline void prods_wait_1( size_t val ) { waituntil( val >> chans[0] ) {} or else {} }
+static inline void prods_wait_2( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or else {} }
+static inline void prods_wait_3( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} or else {} }
+static inline void prods_wait_4( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} or waituntil( val >> chans[3] ) {} or else {} }
+static inline void prods_wait_5( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} or waituntil( val >> chans[3] ) {} or waituntil( val >> chans[4] ) {} or else {} }
+static inline void prods_wait_6( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} or waituntil( val >> chans[3] ) {} or waituntil( val >> chans[4] ) {} or waituntil( val >> chans[5] ) {} or else {} }
+static inline void prods_wait_7( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} or waituntil( val >> chans[3] ) {} or waituntil( val >> chans[4] ) {} or waituntil( val >> chans[5] ) {} or waituntil( val >> chans[6] ) {} or else {} }
+static inline void prods_wait_8( size_t val ) { waituntil( val >> chans[0] ) {} or waituntil( val >> chans[1] ) {} or waituntil( val >> chans[2] ) {} or waituntil( val >> chans[3] ) {} or waituntil( val >> chans[4] ) {} or waituntil( val >> chans[5] ) {} or waituntil( val >> chans[6] ) {} or waituntil( val >> chans[7] ) {} or else {} }
+
+size_t globalTotal = 0;
+
+thread Consumer {};
+void main( Consumer & this ) {
+    size_t val, i = 0;
+    try {
+        for(;; i++ ) {
+            FN_GLUE(cons_wait_, NUM_CHANS)(val, i);
+        }
+    } catch( channel_closed * e ) {}
+    __atomic_fetch_add( &globalTotal, i, __ATOMIC_SEQ_CST );
+}
+
+thread Producer {};
+void main( Producer & this ) {
+    try {
+        for( size_t i = 0;; i++ ) {
+            FN_GLUE(prods_wait_, NUM_CHANS)(i);
+        }
+    } catch( channel_closed * e ) {}
+}
+
+int main( int argc, char * argv[] ) {
+    switch ( argc ) {
+	  case 3:
+		if ( strcmp( argv[2], "d" ) != 0 ) {			// default ?
+			ChannelSize = atoi( argv[2] );
+		} // if
+	  case 2:
+		if ( strcmp( argv[1], "d" ) != 0 ) {			// default ?
+			Processors = atoi( argv[1] );
+			if ( Processors < 1 ) goto Usage;
+		} // if
+	  case 1:											// use defaults
+		break;
+	  default:
+	  Usage:
+		sout | "Usage: " | argv[0]
+             | " [ processors (> 0) | 'd' (default " | Processors
+			 | ") ] [ channel size (>= 0) | 'd' (default " | ChannelSize
+			 | ") ]" ;
+		exit( EXIT_FAILURE );
+	} // switch
+    Producers = Processors / 2;
+    Consumers = Processors / 2;
+
+    processor p[Processors - 1];
+
+    chans = aalloc( NUM_CHANS );
+    for ( i; NUM_CHANS )
+        chans[i]{ ChannelSize };
+
+    {
+        Producer p[Producers];
+        Consumer c[Consumers];
+
+        sleep(10`s);
+
+        for ( i; NUM_CHANS )
+            close( chans[i] );
+    }
+    adelete( chans );
+    printf("%zu\n", globalTotal);
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend/contend.go
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend/contend.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend/contend.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,123 @@
+package main
+
+import (
+	"fmt"
+	"sync"
+	"time"
+	"runtime"
+	"os"
+	"strconv"
+)
+
+var Processors, Channels, Prods, Cons, ChannelSize int = 2, 8, 1, 1, 10
+var cons_done, prod_done bool = false, false;
+var total_operations, cons_check, prod_check uint64 = 0, 0, 0
+var m sync.Mutex
+
+var prodJoin chan int = make(chan int, Prods)
+var consJoin chan int = make(chan int, Cons)
+
+func consumer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if cons_done { break }
+		
+		select {
+			case <- chans[0]:
+			case <- chans[1]:
+			case <- chans[2]:
+			case <- chans[3]:
+			case <- chans[4]:
+			case <- chans[5]:
+			case <- chans[6]:
+			case <- chans[7]:
+		}
+		if ! prod_done { count++ }
+	}
+	m.Lock()
+	total_operations += count
+	m.Unlock()
+	consJoin <- 0
+}
+
+func producer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if prod_done { break }
+		select {
+			case chans[0] <- count:
+			case chans[1] <- count:
+			case chans[2] <- count:
+			case chans[3] <- count:
+			case chans[4] <- count:
+			case chans[5] <- count:
+			case chans[6] <- count:
+			case chans[7] <- count:
+		}
+		count++
+	}
+	prodJoin <- 0
+}
+
+func usage() {
+	fmt.Printf( "Usage: %v " +
+		"[ processors (> 0) | 'd' (default %v) ] " +
+		"[ ChannelSize (> 0) | 'd' (default %v) ]\n",
+		os.Args[0], Processors, ChannelSize );
+	os.Exit( 1 );
+}
+
+func main() {
+	switch len( os.Args ) {
+		case 3:
+			if os.Args[2] != "d" {							// default ?
+				ChannelSize, _ = strconv.Atoi( os.Args[2] )
+					if ChannelSize < 0 { usage(); }
+			} // if
+		fallthrough
+		case 2:
+			if os.Args[1] != "d" {							// default ?
+				Processors, _ = strconv.Atoi( os.Args[1] )
+				if Processors < 1 { usage(); }
+			} // if
+		case 1:											// use defaults
+		default:
+		usage();
+	} // switch
+	runtime.GOMAXPROCS( Processors );
+	Prods = Processors /2
+	Cons = Processors / 2
+
+	// fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize)
+	
+	chans := make( [] chan uint64, Channels )
+	for i := range chans {
+		chans[i] = make(chan uint64, ChannelSize)
+	}
+	for j := 0; j < Prods; j++ {
+		go producer( chans )
+	}
+
+	for j := 0; j < Cons; j++ {
+		go consumer( chans )
+	}
+
+	// wait 10 seconds
+	time.Sleep(time.Second * 10)
+	// fmt.Println("prod done\n")
+	prod_done = true
+	for j := 0; j < Prods; j++ {
+		<-prodJoin
+	}
+	// fmt.Println("cons done\n")
+	cons_done = true
+	for i := range chans {
+		close(chans[i])
+	}
+	
+	for j := 0; j < Cons; j++{
+		<-consJoin
+	}
+
+    fmt.Println(total_operations)
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend/go.mod
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,3 @@
+module contend
+
+go 1.18
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend2/contend.go
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend2/contend.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend2/contend.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,111 @@
+package main
+
+import (
+	"fmt"
+	"sync"
+	"time"
+	"runtime"
+	"os"
+	"strconv"
+)
+
+var Processors, Channels, Prods, Cons, ChannelSize int = 2, 2, 1, 1, 10
+var cons_done, prod_done bool = false, false;
+var total_operations, cons_check, prod_check uint64 = 0, 0, 0
+var m sync.Mutex
+
+var prodJoin chan int = make(chan int, Prods)
+var consJoin chan int = make(chan int, Cons)
+
+func consumer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if cons_done { break }
+		
+		select {
+			case <- chans[0]:
+			case <- chans[1]:
+		}
+		if ! prod_done { count++ }
+	}
+	m.Lock()
+	total_operations += count
+	m.Unlock()
+	consJoin <- 0
+}
+
+func producer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if prod_done { break }
+		select {
+			case chans[0] <- count:
+			case chans[1] <- count:
+		}
+		count++
+	}
+	prodJoin <- 0
+}
+
+func usage() {
+	fmt.Printf( "Usage: %v " +
+		"[ processors (> 0) | 'd' (default %v) ] " +
+		"[ ChannelSize (> 0) | 'd' (default %v) ]\n",
+		os.Args[0], Processors, ChannelSize );
+	os.Exit( 1 );
+}
+
+func main() {
+	switch len( os.Args ) {
+		case 3:
+			if os.Args[2] != "d" {							// default ?
+				ChannelSize, _ = strconv.Atoi( os.Args[2] )
+					if ChannelSize < 0 { usage(); }
+			} // if
+		fallthrough
+		case 2:
+			if os.Args[1] != "d" {							// default ?
+				Processors, _ = strconv.Atoi( os.Args[1] )
+				if Processors < 1 { usage(); }
+			} // if
+		case 1:											// use defaults
+		default:
+		usage();
+	} // switch
+	runtime.GOMAXPROCS( Processors );
+	Prods = Processors /2
+	Cons = Processors / 2
+
+	// fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize)
+	
+	chans := make( [] chan uint64, Channels )
+	for i := range chans {
+		chans[i] = make(chan uint64, ChannelSize)
+	}
+	for j := 0; j < Prods; j++ {
+		go producer( chans )
+	}
+
+	for j := 0; j < Cons; j++ {
+		go consumer( chans )
+	}
+
+	// wait 10 seconds
+	time.Sleep(time.Second * 10)
+	// fmt.Println("prod done\n")
+	prod_done = true
+	for j := 0; j < Prods; j++ {
+		<-prodJoin
+	}
+	// fmt.Println("cons done\n")
+	cons_done = true
+	for i := range chans {
+		close(chans[i])
+	}
+	
+	for j := 0; j < Cons; j++{
+		<-consJoin
+	}
+
+    fmt.Println(total_operations)
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend2/go.mod
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend2/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend2/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,3 @@
+module contend
+
+go 1.18
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend4/contend.go
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend4/contend.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend4/contend.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,115 @@
+package main
+
+import (
+	"fmt"
+	"sync"
+	"time"
+	"runtime"
+	"os"
+	"strconv"
+)
+
+var Processors, Channels, Prods, Cons, ChannelSize int = 2, 4, 1, 1, 10
+var cons_done, prod_done bool = false, false;
+var total_operations, cons_check, prod_check uint64 = 0, 0, 0
+var m sync.Mutex
+
+var prodJoin chan int = make(chan int, Prods)
+var consJoin chan int = make(chan int, Cons)
+
+func consumer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if cons_done { break }
+		
+		select {
+			case <- chans[0]:
+			case <- chans[1]:
+			case <- chans[2]:
+			case <- chans[3]:
+		}
+		if ! prod_done { count++ }
+	}
+	m.Lock()
+	total_operations += count
+	m.Unlock()
+	consJoin <- 0
+}
+
+func producer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if prod_done { break }
+		select {
+			case chans[0] <- count:
+			case chans[1] <- count:
+			case chans[2] <- count:
+			case chans[3] <- count:
+		}
+		count++
+	}
+	prodJoin <- 0
+}
+
+func usage() {
+	fmt.Printf( "Usage: %v " +
+		"[ processors (> 0) | 'd' (default %v) ] " +
+		"[ ChannelSize (> 0) | 'd' (default %v) ]\n",
+		os.Args[0], Processors, ChannelSize );
+	os.Exit( 1 );
+}
+
+func main() {
+	switch len( os.Args ) {
+		case 3:
+			if os.Args[2] != "d" {							// default ?
+				ChannelSize, _ = strconv.Atoi( os.Args[2] )
+					if ChannelSize < 0 { usage(); }
+			} // if
+		fallthrough
+		case 2:
+			if os.Args[1] != "d" {							// default ?
+				Processors, _ = strconv.Atoi( os.Args[1] )
+				if Processors < 1 { usage(); }
+			} // if
+		case 1:											// use defaults
+		default:
+		usage();
+	} // switch
+	runtime.GOMAXPROCS( Processors );
+	Prods = Processors /2
+	Cons = Processors / 2
+
+	// fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize)
+	
+	chans := make( [] chan uint64, Channels )
+	for i := range chans {
+		chans[i] = make(chan uint64, ChannelSize)
+	}
+	for j := 0; j < Prods; j++ {
+		go producer( chans )
+	}
+
+	for j := 0; j < Cons; j++ {
+		go consumer( chans )
+	}
+
+	// wait 10 seconds
+	time.Sleep(time.Second * 10)
+	// fmt.Println("prod done\n")
+	prod_done = true
+	for j := 0; j < Prods; j++ {
+		<-prodJoin
+	}
+	// fmt.Println("cons done\n")
+	cons_done = true
+	for i := range chans {
+		close(chans[i])
+	}
+	
+	for j := 0; j < Cons; j++{
+		<-consJoin
+	}
+
+    fmt.Println(total_operations)
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend4/go.mod
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend4/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend4/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,3 @@
+module contend
+
+go 1.18
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend8/contend.go
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend8/contend.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend8/contend.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,123 @@
+package main
+
+import (
+	"fmt"
+	"sync"
+	"time"
+	"runtime"
+	"os"
+	"strconv"
+)
+
+var Processors, Channels, Prods, Cons, ChannelSize int = 2, 8, 1, 1, 10
+var cons_done, prod_done bool = false, false;
+var total_operations, cons_check, prod_check uint64 = 0, 0, 0
+var m sync.Mutex
+
+var prodJoin chan int = make(chan int, Prods)
+var consJoin chan int = make(chan int, Cons)
+
+func consumer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if cons_done { break }
+		
+		select {
+			case <- chans[0]:
+			case <- chans[1]:
+			case <- chans[2]:
+			case <- chans[3]:
+			case <- chans[4]:
+			case <- chans[5]:
+			case <- chans[6]:
+			case <- chans[7]:
+		}
+		if ! prod_done { count++ }
+	}
+	m.Lock()
+	total_operations += count
+	m.Unlock()
+	consJoin <- 0
+}
+
+func producer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if prod_done { break }
+		select {
+			case chans[0] <- count:
+			case chans[1] <- count:
+			case chans[2] <- count:
+			case chans[3] <- count:
+			case chans[4] <- count:
+			case chans[5] <- count:
+			case chans[6] <- count:
+			case chans[7] <- count:
+		}
+		count++
+	}
+	prodJoin <- 0
+}
+
+func usage() {
+	fmt.Printf( "Usage: %v " +
+		"[ processors (> 0) | 'd' (default %v) ] " +
+		"[ ChannelSize (> 0) | 'd' (default %v) ]\n",
+		os.Args[0], Processors, ChannelSize );
+	os.Exit( 1 );
+}
+
+func main() {
+	switch len( os.Args ) {
+		case 3:
+			if os.Args[2] != "d" {							// default ?
+				ChannelSize, _ = strconv.Atoi( os.Args[2] )
+					if ChannelSize < 0 { usage(); }
+			} // if
+		fallthrough
+		case 2:
+			if os.Args[1] != "d" {							// default ?
+				Processors, _ = strconv.Atoi( os.Args[1] )
+				if Processors < 1 { usage(); }
+			} // if
+		case 1:											// use defaults
+		default:
+		usage();
+	} // switch
+	runtime.GOMAXPROCS( Processors );
+	Prods = Processors /2
+	Cons = Processors / 2
+
+	// fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize)
+	
+	chans := make( [] chan uint64, Channels )
+	for i := range chans {
+		chans[i] = make(chan uint64, ChannelSize)
+	}
+	for j := 0; j < Prods; j++ {
+		go producer( chans )
+	}
+
+	for j := 0; j < Cons; j++ {
+		go consumer( chans )
+	}
+
+	// wait 10 seconds
+	time.Sleep(time.Second * 10)
+	// fmt.Println("prod done\n")
+	prod_done = true
+	for j := 0; j < Prods; j++ {
+		<-prodJoin
+	}
+	// fmt.Println("cons done\n")
+	cons_done = true
+	for i := range chans {
+		close(chans[i])
+	}
+	
+	for j := 0; j < Cons; j++{
+		<-consJoin
+	}
+
+    fmt.Println(total_operations)
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend8/go.mod
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend8/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/contend8/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,3 @@
+module contend
+
+go 1.18
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/sidechan/go.mod
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/sidechan/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/sidechan/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,3 @@
+module sidechan
+
+go 1.18
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/sidechan/sidechan.go
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/sidechan/sidechan.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/sidechan/sidechan.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,136 @@
+package main
+
+import (
+	"fmt"
+	"sync"
+	"time"
+	"runtime"
+	"os"
+	"strconv"
+)
+
+var Sets, Channels, ChannelSize int = 1, 2, 100
+var cons_done, prod_done bool = false, false;
+var total_operations uint64 = 0
+var m sync.Mutex
+
+var prodJoin chan int = make(chan int)
+var consJoin chan int = make(chan int)
+
+func selectconsumer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if cons_done { break }		
+		select {
+			case <- chans[0]:
+			case <- chans[1]:
+		}
+		if ! prod_done { count++ }
+	}
+	m.Lock()
+	total_operations += count
+	m.Unlock()
+	consJoin <- 0
+}
+
+func consumer( channel chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if cons_done { break }
+		<-channel
+		if ! prod_done { count++ }
+	}
+	m.Lock()
+	total_operations += count
+	m.Unlock()
+	consJoin <- 0
+}
+
+func selectproducer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	var checksum uint64 = 0
+	for {
+		if prod_done { break }
+		checksum = checksum ^ count
+		select {
+			case chans[0] <- count:
+			case chans[1] <- count:
+		}
+		count++
+	}
+	prodJoin <- 0
+}
+
+func producer( channel chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if prod_done { break }
+		channel <- count
+		count++
+	}
+	prodJoin <- 0
+}
+
+func usage() {
+	fmt.Printf( "Usage: %v " +
+		"[ sets (> 0) | 'd' (default %v) ] " +
+		"[ ChannelSize (> 0) | 'd' (default %v) ]\n",
+		os.Args[0], Sets, ChannelSize );
+	os.Exit( 1 );
+}
+
+func main() {
+	switch len( os.Args ) {
+		case 3:
+			if os.Args[2] != "d" {							// default ?
+				ChannelSize, _ = strconv.Atoi( os.Args[2] )
+					if ChannelSize < 0 { usage(); }
+			} // if
+		fallthrough
+		case 2:
+			if os.Args[1] != "d" {							// default ?
+				Sets, _ = strconv.Atoi( os.Args[1] )
+				if Sets < 1 { usage(); }
+			} // if
+		case 1:											// use defaults
+		default:
+		usage();
+	} // switch
+	runtime.GOMAXPROCS( Sets * 2 + Sets * Channels * 2 );
+
+	// fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize)
+	
+	chans := make( [] chan uint64, Channels )
+	for i := range chans {
+		chans[i] = make(chan uint64, ChannelSize)
+	}
+
+	
+	for j := 0; j < Sets; j++ {
+		go selectproducer( chans )
+		go selectconsumer( chans )
+		for i := 0; i < Channels; i++ {
+			go producer( chans[i] )
+			go consumer( chans[i] )
+		}
+	}
+		
+
+	// wait 10 seconds
+	time.Sleep(time.Second * 10)
+	// fmt.Println("prod done\n")
+	prod_done = true
+	for j := 0; j < Sets + Sets * Channels; j++ {
+		<-prodJoin
+	}
+	// fmt.Println("cons done\n")
+	cons_done = true
+	for i := range chans {
+		close(chans[i])
+	}
+	
+	for j := 0; j < Sets + Sets * Channels; j++{
+		<-consJoin
+	}
+    fmt.Println(total_operations)
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin/go.mod
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,3 @@
+module spin
+
+go 1.18
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin/spin.go
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin/spin.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin/spin.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,133 @@
+package main
+
+import (
+	"fmt"
+	"sync"
+	"time"
+	"runtime"
+	"os"
+	"strconv"
+)
+
+var Processors, Channels, Prods, Cons, ChannelSize int = 2, 8, 1, 1, 10
+var cons_done, prod_done bool = false, false;
+var total_operations uint64 = 0
+var m sync.Mutex
+
+var prodJoin chan int = make(chan int)
+var consJoin chan int = make(chan int)
+
+func consumer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if cons_done { break }
+		
+		select {
+			case <- chans[0]:
+				if ! prod_done { count++ }
+			case <- chans[1]:
+				if ! prod_done { count++ }
+			case <- chans[2]:
+				if ! prod_done { count++ }
+			case <- chans[3]:
+				if ! prod_done { count++ }
+			case <- chans[4]:
+				if ! prod_done { count++ }
+			case <- chans[5]:
+				if ! prod_done { count++ }
+			case <- chans[6]:
+				if ! prod_done { count++ }
+			case <- chans[7]:
+				if ! prod_done { count++ }
+			default:
+		}
+	}
+	m.Lock()
+	total_operations += count
+	m.Unlock()
+	consJoin <- 0
+}
+
+func producer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if prod_done { break }
+		select {
+			case chans[0] <- count:
+			case chans[1] <- count:
+			case chans[2] <- count:
+			case chans[3] <- count:
+			case chans[4] <- count:
+			case chans[5] <- count:
+			case chans[6] <- count:
+			case chans[7] <- count:
+			default:
+		}
+		count++
+	}
+	prodJoin <- 0
+}
+
+func usage() {
+	fmt.Printf( "Usage: %v " +
+		"[ processors (> 0) | 'd' (default %v) ] " +
+		"[ ChannelSize (> 0) | 'd' (default %v) ]\n",
+		os.Args[0], Processors, ChannelSize );
+	os.Exit( 1 );
+}
+
+func main() {
+	switch len( os.Args ) {
+		case 3:
+			if os.Args[2] != "d" {							// default ?
+				ChannelSize, _ = strconv.Atoi( os.Args[2] )
+					if ChannelSize < 0 { usage(); }
+			} // if
+		fallthrough
+		case 2:
+			if os.Args[1] != "d" {							// default ?
+				Processors, _ = strconv.Atoi( os.Args[1] )
+				if Processors < 1 { usage(); }
+			} // if
+		case 1:											// use defaults
+		default:
+		usage();
+	} // switch
+	runtime.GOMAXPROCS( Processors );
+	Prods = Processors /2
+	Cons = Processors / 2
+
+	// fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize)
+	
+	chans := make( [] chan uint64, Channels )
+	for i := range chans {
+		chans[i] = make(chan uint64, ChannelSize)
+	}
+	for j := 0; j < Prods; j++ {
+		go producer( chans )
+	}
+
+	for j := 0; j < Cons; j++ {
+		go consumer( chans )
+	}
+		
+
+	// wait 10 seconds
+	time.Sleep(time.Second * 10)
+	// fmt.Println("prod done\n")
+	prod_done = true
+	for j := 0; j < Prods; j++ {
+		<-prodJoin
+	}
+	// fmt.Println("cons done\n")
+	cons_done = true
+	for i := range chans {
+		close(chans[i])
+	}
+	
+	for j := 0; j < Cons; j++{
+		<-consJoin
+	}
+
+    fmt.Println(total_operations)
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin2/go.mod
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin2/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin2/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,3 @@
+module spin
+
+go 1.18
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin2/spin.go
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin2/spin.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin2/spin.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,115 @@
+package main
+
+import (
+	"fmt"
+	"sync"
+	"time"
+	"runtime"
+	"os"
+	"strconv"
+)
+
+var Processors, Channels, Prods, Cons, ChannelSize int = 2, 2, 1, 1, 10
+var cons_done, prod_done bool = false, false;
+var total_operations uint64 = 0
+var m sync.Mutex
+
+var prodJoin chan int = make(chan int)
+var consJoin chan int = make(chan int)
+
+func consumer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if cons_done { break }
+		
+		select {
+			case <- chans[0]:
+				if ! prod_done { count++ }
+			case <- chans[1]:
+				if ! prod_done { count++ }
+			default:
+		}
+	}
+	m.Lock()
+	total_operations += count
+	m.Unlock()
+	consJoin <- 0
+}
+
+func producer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if prod_done { break }
+		select {
+			case chans[0] <- count:
+			case chans[1] <- count:
+			default:
+		}
+		count++
+	}
+	prodJoin <- 0
+}
+
+func usage() {
+	fmt.Printf( "Usage: %v " +
+		"[ processors (> 0) | 'd' (default %v) ] " +
+		"[ ChannelSize (> 0) | 'd' (default %v) ]\n",
+		os.Args[0], Processors, ChannelSize );
+	os.Exit( 1 );
+}
+
+func main() {
+	switch len( os.Args ) {
+		case 3:
+			if os.Args[2] != "d" {							// default ?
+				ChannelSize, _ = strconv.Atoi( os.Args[2] )
+					if ChannelSize < 0 { usage(); }
+			} // if
+		fallthrough
+		case 2:
+			if os.Args[1] != "d" {							// default ?
+				Processors, _ = strconv.Atoi( os.Args[1] )
+				if Processors < 1 { usage(); }
+			} // if
+		case 1:											// use defaults
+		default:
+		usage();
+	} // switch
+	runtime.GOMAXPROCS( Processors );
+	Prods = Processors /2
+	Cons = Processors / 2
+
+	// fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize)
+	
+	chans := make( [] chan uint64, Channels )
+	for i := range chans {
+		chans[i] = make(chan uint64, ChannelSize)
+	}
+	for j := 0; j < Prods; j++ {
+		go producer( chans )
+	}
+
+	for j := 0; j < Cons; j++ {
+		go consumer( chans )
+	}
+		
+
+	// wait 10 seconds
+	time.Sleep(time.Second * 10)
+	// fmt.Println("prod done\n")
+	prod_done = true
+	for j := 0; j < Prods; j++ {
+		<-prodJoin
+	}
+	// fmt.Println("cons done\n")
+	cons_done = true
+	for i := range chans {
+		close(chans[i])
+	}
+	
+	for j := 0; j < Cons; j++{
+		<-consJoin
+	}
+
+    fmt.Println(total_operations)
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin4/go.mod
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin4/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin4/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,3 @@
+module spin
+
+go 1.18
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin4/spin.go
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin4/spin.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin4/spin.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,120 @@
+package main
+
+import (
+	"fmt"
+	"sync"
+	"time"
+	"runtime"
+	"os"
+	"strconv"
+)
+
+var Processors, Channels, Prods, Cons, ChannelSize int = 2, 4, 1, 1, 10
+var cons_done, prod_done bool = false, false;
+var total_operations uint64 = 0
+var m sync.Mutex
+
+var prodJoin chan int = make(chan int)
+var consJoin chan int = make(chan int)
+
+func consumer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if cons_done { break }
+		
+		select {
+			case <- chans[0]:
+				if ! prod_done { count++ }
+			case <- chans[1]:
+				if ! prod_done { count++ }
+			case <- chans[2]:
+				if ! prod_done { count++ }
+			case <- chans[3]:
+			default:
+		}
+	}
+	m.Lock()
+	total_operations += count
+	m.Unlock()
+	consJoin <- 0
+}
+
+func producer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if prod_done { break }
+		select {
+			case chans[0] <- count:
+			case chans[1] <- count:
+			case chans[2] <- count:
+			case chans[3] <- count:
+			default:
+		}
+		count++
+	}
+	prodJoin <- 0
+}
+
+func usage() {
+	fmt.Printf( "Usage: %v " +
+		"[ processors (> 0) | 'd' (default %v) ] " +
+		"[ ChannelSize (> 0) | 'd' (default %v) ]\n",
+		os.Args[0], Processors, ChannelSize );
+	os.Exit( 1 );
+}
+
+func main() {
+	switch len( os.Args ) {
+		case 3:
+			if os.Args[2] != "d" {							// default ?
+				ChannelSize, _ = strconv.Atoi( os.Args[2] )
+					if ChannelSize < 0 { usage(); }
+			} // if
+		fallthrough
+		case 2:
+			if os.Args[1] != "d" {							// default ?
+				Processors, _ = strconv.Atoi( os.Args[1] )
+				if Processors < 1 { usage(); }
+			} // if
+		case 1:											// use defaults
+		default:
+		usage();
+	} // switch
+	runtime.GOMAXPROCS( Processors );
+	Prods = Processors /2
+	Cons = Processors / 2
+
+	// fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize)
+	
+	chans := make( [] chan uint64, Channels )
+	for i := range chans {
+		chans[i] = make(chan uint64, ChannelSize)
+	}
+	for j := 0; j < Prods; j++ {
+		go producer( chans )
+	}
+
+	for j := 0; j < Cons; j++ {
+		go consumer( chans )
+	}
+		
+
+	// wait 10 seconds
+	time.Sleep(time.Second * 10)
+	// fmt.Println("prod done\n")
+	prod_done = true
+	for j := 0; j < Prods; j++ {
+		<-prodJoin
+	}
+	// fmt.Println("cons done\n")
+	cons_done = true
+	for i := range chans {
+		close(chans[i])
+	}
+	
+	for j := 0; j < Cons; j++{
+		<-consJoin
+	}
+
+    fmt.Println(total_operations)
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin8/go.mod
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin8/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin8/go.mod	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,3 @@
+module spin
+
+go 1.18
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin8/spin.go
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin8/spin.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/go/spin8/spin.go	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,133 @@
+package main
+
+import (
+	"fmt"
+	"sync"
+	"time"
+	"runtime"
+	"os"
+	"strconv"
+)
+
+var Processors, Channels, Prods, Cons, ChannelSize int = 2, 8, 1, 1, 10
+var cons_done, prod_done bool = false, false;
+var total_operations uint64 = 0
+var m sync.Mutex
+
+var prodJoin chan int = make(chan int)
+var consJoin chan int = make(chan int)
+
+func consumer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if cons_done { break }
+		
+		select {
+			case <- chans[0]:
+				if ! prod_done { count++ }
+			case <- chans[1]:
+				if ! prod_done { count++ }
+			case <- chans[2]:
+				if ! prod_done { count++ }
+			case <- chans[3]:
+				if ! prod_done { count++ }
+			case <- chans[4]:
+				if ! prod_done { count++ }
+			case <- chans[5]:
+				if ! prod_done { count++ }
+			case <- chans[6]:
+				if ! prod_done { count++ }
+			case <- chans[7]:
+				if ! prod_done { count++ }
+			default:
+		}
+	}
+	m.Lock()
+	total_operations += count
+	m.Unlock()
+	consJoin <- 0
+}
+
+func producer( chans [] chan uint64 ) {
+	var count uint64 = 0
+	for {
+		if prod_done { break }
+		select {
+			case chans[0] <- count:
+			case chans[1] <- count:
+			case chans[2] <- count:
+			case chans[3] <- count:
+			case chans[4] <- count:
+			case chans[5] <- count:
+			case chans[6] <- count:
+			case chans[7] <- count:
+			default:
+		}
+		count++
+	}
+	prodJoin <- 0
+}
+
+func usage() {
+	fmt.Printf( "Usage: %v " +
+		"[ processors (> 0) | 'd' (default %v) ] " +
+		"[ ChannelSize (> 0) | 'd' (default %v) ]\n",
+		os.Args[0], Processors, ChannelSize );
+	os.Exit( 1 );
+}
+
+func main() {
+	switch len( os.Args ) {
+		case 3:
+			if os.Args[2] != "d" {							// default ?
+				ChannelSize, _ = strconv.Atoi( os.Args[2] )
+					if ChannelSize < 0 { usage(); }
+			} // if
+		fallthrough
+		case 2:
+			if os.Args[1] != "d" {							// default ?
+				Processors, _ = strconv.Atoi( os.Args[1] )
+				if Processors < 1 { usage(); }
+			} // if
+		case 1:											// use defaults
+		default:
+		usage();
+	} // switch
+	runtime.GOMAXPROCS( Processors );
+	Prods = Processors /2
+	Cons = Processors / 2
+
+	// fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize)
+	
+	chans := make( [] chan uint64, Channels )
+	for i := range chans {
+		chans[i] = make(chan uint64, ChannelSize)
+	}
+	for j := 0; j < Prods; j++ {
+		go producer( chans )
+	}
+
+	for j := 0; j < Cons; j++ {
+		go consumer( chans )
+	}
+		
+
+	// wait 10 seconds
+	time.Sleep(time.Second * 10)
+	// fmt.Println("prod done\n")
+	prod_done = true
+	for j := 0; j < Prods; j++ {
+		<-prodJoin
+	}
+	// fmt.Println("cons done\n")
+	cons_done = true
+	for i := range chans {
+		close(chans[i])
+	}
+	
+	for j := 0; j < Cons; j++{
+		<-consJoin
+	}
+
+    fmt.Println(total_operations)
+}
Index: doc/theses/colby_parsons_MMAth/benchmarks/waituntil/run
===================================================================
--- doc/theses/colby_parsons_MMAth/benchmarks/waituntil/run	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
+++ doc/theses/colby_parsons_MMAth/benchmarks/waituntil/run	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -0,0 +1,244 @@
+#!/bin/bash -
+
+false=0; true=1
+
+# Usage: arch [ hostname ] returns hostname, cores, startcore
+#
+#   Define machine architecture based on starting socket, CPUs (cores) per socket, number of
+#   sockets, has hyperthreading.
+
+start=0
+
+arch() {
+	hostname=${1:-`hostname`}			# return value
+	hashyper=${true}					# assume machine has hyperthreads
+	if [ "${hostname}" = "plg2" ] ; then
+		startsocket=${start}
+		cps=16							# coresPerSocket
+		sockets=2
+		hashyper=${false}				# has no hyperthreads
+	elif [ "${hostname}" = "nasus" ] ; then
+		startsocket=${start}
+		cps=64							# coresPerSocket
+		sockets=2
+	elif [ "${hostname}" = "pyke" ] ; then
+		startsocket=${start}
+		cps=24							# coresPerSocket
+		sockets=2
+	elif [ "${hostname}" = "jax" ] ; then
+		startsocket=${start}
+		cps=24							# coresPerSocket
+		sockets=4
+	else
+		echo "unsupported host" ${hostname}
+		exit 1
+	fi
+	cores=$(( ${cps} * ${sockets} ))
+	startcore=$(( ${startsocket} * ${cps} ))
+}
+
+# Usage: affinity (global cps, sockets, startsocket, hashyper, cores, startcore, wrap)
+#   returns taskset argument
+#
+#   This routine assumes hyperthreading has only 2 hyperthreads per core.
+#
+#   If hyperthread scanning is used: processor units are assigned across the low-number hyperthreads
+#   of the socket's cores. When the low-number hyperthreads are filled, the high-number hyperhtreads
+#   are assigned across the socket's cores. Then the next socket is assigned.
+#
+#   If hyperthread wrapping is used: processor units are assigned in low/high-number pairs of
+#   hyperthreads across the socket's cores. Then the next socket is assigned.
+
+wrap=${false}							# set to control hyperthread assignment across socket cores
+
+affinity() {
+	if [ ${wrap} -eq ${true} -a ${hashyper} -eq ${false} ] ; then
+		echo "architecture does not support hyperthreading for wrapping"
+		exit 1
+	fi
+	taskset=""							# return value
+	set -- $(( ${1} - 1 ))				# decrement $1
+	if [ ${1} -eq 0 ] ; then taskset="${startcore}-${startcore}"; return; fi
+	if [ ${1} -ge $(( ${cps} * ( ${sockets} - ${startsocket} ) * ( ${hashyper} + 1 ) )) ] ; then # error
+		echo "not enough cores $(( ${cores} * ${sockets} )) for $(( ${1} + 1 )) starting at ${startcore}"
+		exit 1
+	fi
+	if [ ${hashyper} -eq ${false} ] ; then taskset="${startcore}-$(( ${1} + ${startcore} ))"; return; fi # no hyperthreads
+	start2=$(( ${startcore} + ${cores} ))
+	if [ ${wrap} -eq ${true} ] ; then 	# hyperthread wrapping
+		end1=$(( ${1} / 2 + ${startcore} ))
+		end2=$(( ${end1} + ${cores} ))
+		if [ $(( ${1} % 2 )) -eq 0 ] ; then
+			end2=$(( ${end2} - 1 ))
+		fi
+		taskset="${startcore}-${end1},${start2}-${end2}"
+	else								# hyperthread scanning
+		if [ ${1} -lt ${cps} ] ; then taskset="${startcore}-$(( ${1} + ${startcore} ))"; return; fi
+		filled=$(( ${1} / ( ${cps} * 2 ) * ${cps} ))
+		modulus=$(( ${1} % ( ${cps} * 2 ) ))	# leftover cores added to saturated sockets
+		if [ ${modulus} -gt ${cps} ] ; then
+			taskset="${startcore}-$(( ${startcore} + ${filled} + ${cps} - 1 )),${start2}-$(( ${start2} + ${filled} + ${modulus} % ${cps} ))"
+		else
+			taskset="${startcore}-$(( ${startcore} + ${filled} + ${modulus} )),${start2}-$(( ${start2} + ${filled} - 1 ))"
+		fi
+	fi
+}
+
+# numtimes=5
+numtimes=1
+
+# num_threads='2 4 8 16 24 32'
+# side_chan_threads='6 12 18 24 30' # must be mults of 6
+num_threads='2'
+side_chan_threads='6'
+
+chan_size='10'
+
+# toggle benchmarks
+spin=${true}
+contend=${true}
+sidechan=${true}
+# spin=${false}
+# contend=${false}
+# sidechan=${false}
+
+runCFA=${true}
+runGO=${true}
+# runCFA=${false}
+# runGO=${false}
+
+cfa=~/cfa-cc/driver/cfa
+
+# Helpers to minimize code duplication
+
+# repeats a command ${numtimes}
+preprint=''
+repeat_command() {
+    t=1
+    while [ ${t} -le ${numtimes} ] ; do
+        echo -n -e ${preprint}
+        "${@}"
+        t=`expr ${t} + 1`
+    done
+}
+
+# prints the leading info for a given run of a variant
+print_header() {
+    echo ${1}':'
+    echo -e "cores\tthroughput (entries)"
+}
+
+# runs the current benchmark with provided args
+# only works for standard-run benchmarks (not Akka)
+# must split into pre and post args to be able to supply val of p
+pre_args=''
+post_args=''
+single_run() {
+    affinity ${1}
+    preprint="${1}\t"
+    repeat_command taskset -c ${taskset} ./a.${hostname} ${pre_args} ${1} ${post_args}
+}
+
+# runs the current bench for all processor vals
+# works for standard benchs that dont need to set a config file (not Akka or CAF)
+run_bench() {
+    for p in ${num_threads} ; do
+        single_run ${p}
+    done
+}
+
+run_side_chan() {
+    i=1
+    for p in ${side_chan_threads} ; do
+        affinity ${p}
+        preprint="${p}\t"
+        repeat_command taskset -c ${taskset} ./a.${hostname} ${pre_args} ${i} ${post_args}
+        i=`expr ${i} + 1`
+    done
+}
+
+arch # get hostname
+
+# set up leading info for python script
+echo $numtimes
+echo $num_threads
+echo $side_chan_threads
+
+if [ ${runCFA} -eq ${true} ]; then
+    echo -n 'CFA '
+fi
+if [ ${runGO} -eq ${true} ]; then
+    echo -n 'Go '
+fi
+echo ""
+
+# done printing header info for output
+
+# cfa flags
+cfa_flags='-quiet -O3 -nodebug -DNDEBUG'
+
+# run the benchmarks
+
+run_contend() {
+    post_args=${1}
+
+    if [ ${runCFA} -eq ${true} ] ; then
+        cd cfa # CFA RUN
+        print_header 'CFA'
+        ${cfa} ${cfa_flags} '-DNUM_CHANS='${3} ${2}.cfa -o a.${hostname} > /dev/null 2>&1
+        run_bench
+        rm a.${hostname}
+        cd - > /dev/null
+    fi # done CFA
+
+    if [ ${runGO} -eq ${true} ] ; then
+        cd go/${2}${3} # Go RUN
+        print_header 'Go'
+        go build -o a.${hostname} > /dev/null 2>&1
+        run_bench
+        rm a.${hostname}
+        cd - > /dev/null
+    fi # done Go
+}
+
+# /usr/bin/time -f "%Uu %Ss %Er %Mkb"
+if [ ${contend} -eq ${true} ] ; then
+    echo "contend2: "
+    run_contend ${chan_size} 'contend' '2'
+    echo "contend4: "
+    run_contend ${chan_size} 'contend' '4'
+    echo "contend8: "
+    run_contend ${chan_size} 'contend' '8'
+fi
+
+if [ ${spin} -eq ${true} ] ; then
+    echo "spin2: "
+    run_contend ${chan_size} 'spin' '2'
+    echo "spin4: "
+    run_contend ${chan_size} 'spin' '4'
+    echo "spin8: "
+    run_contend ${chan_size} 'spin' '8'
+fi
+
+if [ ${sidechan} -eq ${true} ] ; then
+    echo "sidechan: "
+    post_args=${chan_size}
+    if [ ${runCFA} -eq ${true} ] ; then
+        cd cfa # CFA RUN
+        print_header 'CFA'
+        ${cfa} ${cfa_flags} sidechan.cfa -o a.${hostname} > /dev/null 2>&1
+        run_side_chan
+        rm a.${hostname}
+        cd - > /dev/null
+    fi # done CFA
+
+    if [ ${runGO} -eq ${true} ] ; then
+        cd go/sidechan
+        print_header 'Go'
+        go build -o a.${hostname} > /dev/null 2>&1
+        run_side_chan
+        rm a.${hostname}
+        cd - > /dev/null
+    fi # done Go
+fi
+
Index: libcfa/src/concurrency/channel.hfa
===================================================================
--- libcfa/src/concurrency/channel.hfa	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ libcfa/src/concurrency/channel.hfa	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -62,5 +62,5 @@
     bool closed;                      // indicates channel close/open
     #ifdef CHAN_STATS
-    size_t blocks, operations;      // counts total ops and ops resulting in a blocked thd
+    size_t p_blocks, p_ops, c_blocks, c_ops;      // counts total ops and ops resulting in a blocked thd
     #endif
 };
@@ -75,6 +75,8 @@
     closed = false;
     #ifdef CHAN_STATS
-    blocks = 0;
-    operations = 0;
+    p_blocks = 0;
+    p_ops = 0;
+    c_blocks = 0;
+    c_ops = 0;
     #endif
 }
@@ -83,7 +85,10 @@
 static inline void ^?{}( channel(T) &c ) with(c) {
     #ifdef CHAN_STATS
-    printf("Channel %p Blocks: %lu, Operations: %lu, %.2f%% of ops blocked\n", &c, blocks, operations, ((double)blocks)/operations * 100);
-    #endif
-    verifyf( cons`isEmpty && prods`isEmpty, "Attempted to delete channel with waiting threads (Deadlock).\n" );
+    printf("Channel %p Blocks: %lu,\t\tOperations: %lu,\t%.2f%% of ops blocked\n", &c, p_blocks + c_blocks, p_ops + c_ops, ((double)p_blocks + c_blocks)/(p_ops + c_ops) * 100);
+    printf("Channel %p Consumer Blocks: %lu,\tConsumer Ops: %lu,\t%.2f%% of Consumer ops blocked\n", &c, p_blocks, p_ops, ((double)p_blocks)/p_ops * 100);
+    printf("Channel %p Producer Blocks: %lu,\tProducer Ops: %lu,\t%.2f%% of Producer ops blocked\n", &c, c_blocks, c_ops, ((double)c_blocks)/c_ops * 100);
+    #endif
+    verifyf( __handle_waituntil_OR( cons ) || __handle_waituntil_OR( prods ) || cons`isEmpty && prods`isEmpty, 
+        "Attempted to delete channel with waiting threads (Deadlock).\n" );
     if ( size != 0 ) delete( buffer );
 }
@@ -149,5 +154,5 @@
     lock( mutex_lock );
     #ifdef CHAN_STATS
-    operations++;
+    p_ops++;
     #endif
 
@@ -187,5 +192,5 @@
 
     #ifdef CHAN_STATS
-    if ( !closed ) operations++;
+    if ( !closed ) p_ops++;
     #endif
 
@@ -208,5 +213,5 @@
     if ( count == size ) {
         #ifdef CHAN_STATS
-        blocks++;
+        p_blocks++;
         #endif
 
@@ -237,5 +242,5 @@
     lock( mutex_lock );
     #ifdef CHAN_STATS
-    operations++;
+    c_ops++;
     #endif
 
@@ -285,5 +290,5 @@
 
     #ifdef CHAN_STATS
-    if ( !closed ) operations++;
+    if ( !closed ) c_ops++;
     #endif
 
@@ -305,5 +310,5 @@
     if ( count == 0 ) {
         #ifdef CHAN_STATS
-        blocks++;
+        c_blocks++;
         #endif
         // check for if woken due to close
@@ -323,10 +328,7 @@
 ///////////////////////////////////////////////////////////////////////////////////////////
 static inline bool unregister_chan( channel(T) & chan, select_node & node ) with(chan) {
-    // if ( !node`isListed && !node.park_counter ) return false; // handle special OR case C_TODO: try adding this back
+    if ( !node`isListed && !node.park_counter ) return false; // handle special OR case
     lock( mutex_lock );
     if ( node`isListed ) { // op wasn't performed
-        #ifdef CHAN_STATS
-        operations--;
-        #endif
         remove( node );
         unlock( mutex_lock );
@@ -362,5 +364,5 @@
 
     #ifdef CHAN_STATS
-    if ( !closed ) operations++;
+    if ( !closed ) c_ops++;
     #endif
 
@@ -407,5 +409,5 @@
     if ( count == 0 ) {
         #ifdef CHAN_STATS
-        blocks++;
+        c_blocks++;
         #endif
         
@@ -451,5 +453,5 @@
 
     #ifdef CHAN_STATS
-    if ( !closed ) operations++;
+    if ( !closed ) p_ops++;
     #endif
 
@@ -498,5 +500,5 @@
     if ( count == size ) {
         #ifdef CHAN_STATS
-        blocks++;
+        p_blocks++;
         #endif
 
Index: libcfa/src/concurrency/locks.hfa
===================================================================
--- libcfa/src/concurrency/locks.hfa	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ libcfa/src/concurrency/locks.hfa	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -176,8 +176,4 @@
 static inline void ?{}(mcs_spin_node & this) { this.next = 0p; this.locked = true; }
 
-static inline mcs_spin_node * volatile & ?`next ( mcs_spin_node * node ) {
-	return node->next;
-}
-
 struct mcs_spin_lock {
 	mcs_spin_queue queue;
@@ -185,9 +181,9 @@
 
 static inline void lock(mcs_spin_lock & l, mcs_spin_node & n) {
+    n.locked = true;
 	mcs_spin_node * prev = __atomic_exchange_n(&l.queue.tail, &n, __ATOMIC_SEQ_CST);
-	n.locked = true;
-	if(prev == 0p) return;
+	if( prev == 0p ) return;
 	prev->next = &n;
-	while(__atomic_load_n(&n.locked, __ATOMIC_RELAXED)) Pause();
+	while( __atomic_load_n(&n.locked, __ATOMIC_RELAXED) ) Pause();
 }
 
@@ -195,5 +191,5 @@
 	mcs_spin_node * n_ptr = &n;
 	if (__atomic_compare_exchange_n(&l.queue.tail, &n_ptr, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) return;
-	while (__atomic_load_n(&n.next, __ATOMIC_RELAXED) == 0p) {}
+	while (__atomic_load_n(&n.next, __ATOMIC_RELAXED) == 0p) Pause();
 	n.next->locked = false;
 }
Index: src/AST/Pass.impl.hpp
===================================================================
--- src/AST/Pass.impl.hpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/AST/Pass.impl.hpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -20,4 +20,5 @@
 #include <unordered_map>
 
+#include "AST/Copy.hpp"
 #include "AST/TranslationUnit.hpp"
 #include "AST/TypeSubstitution.hpp"
Index: src/AST/Print.cpp
===================================================================
--- src/AST/Print.cpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/AST/Print.cpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -16,12 +16,13 @@
 #include "Print.hpp"
 
+#include "Attribute.hpp"
 #include "Decl.hpp"
 #include "Expr.hpp"
+#include "Init.hpp"
 #include "Stmt.hpp"
 #include "Type.hpp"
 #include "TypeSubstitution.hpp"
 #include "CompilationState.h"
-
-#include "Common/utility.h" // for group_iterate
+#include "Common/Iterate.hpp"
 
 using namespace std;
Index: src/AST/SymbolTable.cpp
===================================================================
--- src/AST/SymbolTable.cpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/AST/SymbolTable.cpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -18,4 +18,5 @@
 #include <cassert>
 
+#include "Copy.hpp"
 #include "Decl.hpp"
 #include "Expr.hpp"
Index: src/AST/TypeSubstitution.cpp
===================================================================
--- src/AST/TypeSubstitution.cpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/AST/TypeSubstitution.cpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -10,15 +10,14 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Andrew Beach
-// Last Modified On : Mon Jun  3 13:26:00 2017
-// Update Count     : 5
-//
+// Last Modified On : Thr May 25 11:24:00 2023
+// Update Count     : 6
+//
+
+#include "TypeSubstitution.hpp"
 
 #include "Type.hpp"   // for TypeInstType, Type, StructInstType, UnionInstType
-#include "TypeSubstitution.hpp"
+#include "Pass.hpp"   // for Pass, PureVisitor, WithGuards, WithVisitorRef
 
 namespace ast {
-
-
-// size_t TypeSubstitution::Substituter::traceId = Stats::Heap::new_stacktrace_id("TypeSubstitution");
 
 TypeSubstitution::TypeSubstitution() {
@@ -119,4 +118,29 @@
 }
 
+// definitition must happen after PassVisitor is included so that WithGuards can be used
+struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter>, public PureVisitor {
+	//static size_t traceId;
+
+	Substituter( const TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {}
+
+	const Type * postvisit( const TypeInstType * aggregateUseType );
+
+	/// Records type variable bindings from forall-statements
+	void previsit( const FunctionType * type );
+	/// Records type variable bindings from forall-statements and instantiations of generic types
+	// void handleAggregateType( const BaseInstType * type );
+
+	// void previsit( const StructInstType * aggregateUseType );
+	// void previsit( const UnionInstType * aggregateUseType );
+
+	const TypeSubstitution & sub;
+	int subCount = 0;
+	bool freeOnly;
+	typedef std::unordered_set< TypeEnvKey > BoundVarsType;
+	BoundVarsType boundVars;
+};
+
+// size_t TypeSubstitution::Substituter::traceId = Stats::Heap::new_stacktrace_id("TypeSubstitution");
+
 void TypeSubstitution::normalize() {
 	Pass<Substituter> sub( *this, true );
@@ -128,4 +152,12 @@
 		}
 	} while ( sub.core.subCount );
+}
+
+TypeSubstitution::ApplyResult<Node> TypeSubstitution::applyBase(
+		const Node * input, bool isFree ) const {
+	assert( input );
+	Pass<Substituter> sub( *this, isFree );
+	const Node * output = input->accept( sub );
+	return { output, sub.core.subCount };
 }
 
Index: src/AST/TypeSubstitution.hpp
===================================================================
--- src/AST/TypeSubstitution.hpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/AST/TypeSubstitution.hpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Apr 30 22:52:47 2019
-// Update Count     : 9
+// Last Modified By : Andrew Beach
+// Last Modified On : Thr May 25 12:31:00 2023
+// Update Count     : 10
 //
 
@@ -46,26 +46,33 @@
 	TypeSubstitution &operator=( const TypeSubstitution &other );
 
-	template< typename SynTreeClass >
+	template< typename node_t >
 	struct ApplyResult {
-		ast::ptr<SynTreeClass> node;
+		ast::ptr<node_t> node;
 		int count;
 	};
 
-	template< typename SynTreeClass > ApplyResult<SynTreeClass> apply( const SynTreeClass * input ) const;
-	template< typename SynTreeClass > ApplyResult<SynTreeClass> applyFree( const SynTreeClass * input ) const;
+	template< typename node_t >
+	ApplyResult<node_t> apply( const node_t * input ) const {
+		ApplyResult<Node> ret = applyBase( input, false );
+		return { ret.node.strict_as<node_t>(), ret.count };
+	}
 
 	template< typename node_t, enum Node::ref_type ref_t >
 	int apply( ptr_base< node_t, ref_t > & input ) const {
-		const node_t * p = input.get();
-		auto ret = apply(p);
-		input = ret.node;
+		ApplyResult<Node> ret = applyBase( input.get(), false );
+		input = ret.node.strict_as<node_t>();
 		return ret.count;
+	}
+
+	template< typename node_t >
+	ApplyResult<node_t> applyFree( const node_t * input ) const {
+		ApplyResult<Node> ret = applyBase( input, true );
+		return { ret.node.strict_as<node_t>(), ret.count };
 	}
 
 	template< typename node_t, enum Node::ref_type ref_t >
 	int applyFree( ptr_base< node_t, ref_t > & input ) const {
-		const node_t * p = input.get();
-		auto ret = applyFree(p);
-		input = ret.node;
+		ApplyResult<Node> ret = applyBase( input.get(), true );
+		input = ret.node.strict_as<node_t>();
 		return ret.count;
 	}
@@ -97,4 +104,5 @@
 	// Mutator that performs the substitution
 	struct Substituter;
+	ApplyResult<Node> applyBase( const Node * input, bool isFree ) const;
 
 	// TODO: worry about traversing into a forall-qualified function type or type decl with assertions
@@ -158,53 +166,4 @@
 } // namespace ast
 
-// include needs to happen after TypeSubstitution is defined so that both TypeSubstitution and
-// PassVisitor are defined before PassVisitor implementation accesses TypeSubstitution internals.
-#include "Pass.hpp"
-#include "Copy.hpp"
-
-namespace ast {
-
-// definitition must happen after PassVisitor is included so that WithGuards can be used
-struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter>, public PureVisitor {
-		static size_t traceId;
-
-		Substituter( const TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {}
-
-		const Type * postvisit( const TypeInstType * aggregateUseType );
-
-		/// Records type variable bindings from forall-statements
-		void previsit( const FunctionType * type );
-		/// Records type variable bindings from forall-statements and instantiations of generic types
-		// void handleAggregateType( const BaseInstType * type );
-
-		// void previsit( const StructInstType * aggregateUseType );
-		// void previsit( const UnionInstType * aggregateUseType );
-
-		const TypeSubstitution & sub;
-		int subCount = 0;
-		bool freeOnly;
-		typedef std::unordered_set< TypeEnvKey > BoundVarsType;
-		BoundVarsType boundVars;
-
-};
-
-template< typename SynTreeClass >
-TypeSubstitution::ApplyResult<SynTreeClass> TypeSubstitution::apply( const SynTreeClass * input ) const {
-	assert( input );
-	Pass<Substituter> sub( *this, false );
-	input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) );
-	return { input, sub.core.subCount };
-}
-
-template< typename SynTreeClass >
-TypeSubstitution::ApplyResult<SynTreeClass> TypeSubstitution::applyFree( const SynTreeClass * input ) const {
-	assert( input );
-	Pass<Substituter> sub( *this, true );
-	input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) );
-	return { input, sub.core.subCount };
-}
-
-} // namespace ast
-
 // Local Variables: //
 // tab-width: 4 //
Index: src/Concurrency/Waituntil.cpp
===================================================================
--- src/Concurrency/Waituntil.cpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/Concurrency/Waituntil.cpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -14,7 +14,9 @@
 //
 
+#include "Waituntil.hpp"
+
 #include <string>
 
-#include "Waituntil.hpp"
+#include "AST/Copy.hpp"
 #include "AST/Expr.hpp"
 #include "AST/Pass.hpp"
Index: src/ControlStruct/ExceptDeclNew.cpp
===================================================================
--- src/ControlStruct/ExceptDeclNew.cpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/ControlStruct/ExceptDeclNew.cpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -18,4 +18,5 @@
 #include <sstream>
 
+#include "AST/Copy.hpp"
 #include "AST/Decl.hpp"
 #include "AST/Pass.hpp"
Index: src/GenPoly/SpecializeNew.cpp
===================================================================
--- src/GenPoly/SpecializeNew.cpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/GenPoly/SpecializeNew.cpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -16,4 +16,5 @@
 #include "Specialize.h"
 
+#include "AST/Copy.hpp"                  // for deepCopy
 #include "AST/Inspect.hpp"               // for isIntrinsicCallExpr
 #include "AST/Pass.hpp"                  // for Pass
Index: src/MakeLibCfaNew.cpp
===================================================================
--- src/MakeLibCfaNew.cpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/MakeLibCfaNew.cpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -16,4 +16,5 @@
 #include "MakeLibCfa.h"
 
+#include "AST/Copy.hpp"
 #include "AST/Fwd.hpp"
 #include "AST/Pass.hpp"
Index: src/ResolvExpr/CommonType.cc
===================================================================
--- src/ResolvExpr/CommonType.cc	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/ResolvExpr/CommonType.cc	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -21,4 +21,5 @@
 
 #include "AST/Decl.hpp"
+#include "AST/Pass.hpp"
 #include "AST/Type.hpp"
 #include "Common/PassVisitor.h"
Index: src/ResolvExpr/PolyCost.cc
===================================================================
--- src/ResolvExpr/PolyCost.cc	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/ResolvExpr/PolyCost.cc	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -15,4 +15,5 @@
 
 #include "AST/SymbolTable.hpp"
+#include "AST/Pass.hpp"
 #include "AST/Type.hpp"
 #include "AST/TypeEnvironment.hpp"
Index: src/Tuples/Explode.cc
===================================================================
--- src/Tuples/Explode.cc	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/Tuples/Explode.cc	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -17,4 +17,5 @@
 #include <list>                  // for list
 
+#include "AST/Pass.hpp"          // for Pass
 #include "SynTree/Mutator.h"     // for Mutator
 #include "Common/PassVisitor.h"  // for PassVisitor
Index: src/Validate/Autogen.cpp
===================================================================
--- src/Validate/Autogen.cpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/Validate/Autogen.cpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -25,4 +25,5 @@
 
 #include "AST/Attribute.hpp"
+#include "AST/Copy.hpp"
 #include "AST/Create.hpp"
 #include "AST/Decl.hpp"
Index: src/Validate/FixQualifiedTypes.cpp
===================================================================
--- src/Validate/FixQualifiedTypes.cpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/Validate/FixQualifiedTypes.cpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -16,4 +16,5 @@
 #include "Validate/FixQualifiedTypes.hpp"
 
+#include "AST/Copy.hpp"
 #include "AST/LinkageSpec.hpp"             // for Linkage
 #include "AST/Pass.hpp"
Index: src/Validate/GenericParameter.cpp
===================================================================
--- src/Validate/GenericParameter.cpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/Validate/GenericParameter.cpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -16,4 +16,5 @@
 #include "GenericParameter.hpp"
 
+#include "AST/Copy.hpp"
 #include "AST/Decl.hpp"
 #include "AST/Expr.hpp"
Index: src/Validate/ReplaceTypedef.cpp
===================================================================
--- src/Validate/ReplaceTypedef.cpp	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/Validate/ReplaceTypedef.cpp	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -16,4 +16,5 @@
 #include "ReplaceTypedef.hpp"
 
+#include "AST/Copy.hpp"
 #include "AST/Pass.hpp"
 #include "Common/ScopedMap.h"
Index: src/Virtual/ExpandCasts.cc
===================================================================
--- src/Virtual/ExpandCasts.cc	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/Virtual/ExpandCasts.cc	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -20,4 +20,5 @@
 #include <string>                  // for string, allocator, operator==, ope...
 
+#include "AST/Copy.hpp"
 #include "AST/Decl.hpp"
 #include "AST/Expr.hpp"
Index: src/main.cc
===================================================================
--- src/main.cc	(revision 42468693de700fc817ab7892fc8bd114feaa45f7)
+++ src/main.cc	(revision a5294af49383d5a6eddb1fcb3c988239fda953fb)
@@ -32,4 +32,6 @@
 
 #include "AST/Convert.hpp"
+#include "AST/Pass.hpp"                     // for pass_visitor_stats
+#include "AST/TranslationUnit.hpp"          // for TranslationUnit
 #include "AST/Util.hpp"                     // for checkInvariants
 #include "CompilationState.h"
