Index: src/Concurrency/Keywords.cc
===================================================================
--- src/Concurrency/Keywords.cc	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ src/Concurrency/Keywords.cc	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -246,4 +246,5 @@
 	//=============================================================================================
 	void ConcurrentSueKeyword::visit(StructDecl * decl) {
+		Visitor::visit(decl);
 		if( decl->get_name() == type_name ) {
 			assert( !type_decl );
@@ -385,4 +386,6 @@
 	//=============================================================================================
 	void MutexKeyword::visit(FunctionDecl* decl) {
+		Visitor::visit(decl);		
+
 		std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl );
 		if( mutexArgs.empty() ) return;
@@ -402,4 +405,6 @@
 
 	void MutexKeyword::visit(StructDecl* decl) {
+		Visitor::visit(decl);
+
 		if( decl->get_name() == "monitor_desc" ) {
 			assert( !monitor_decl );
@@ -504,4 +509,6 @@
 	//=============================================================================================
 	void ThreadStarter::visit(FunctionDecl * decl) {
+		Visitor::visit(decl);
+		
 		if( ! InitTweak::isConstructor(decl->get_name()) ) return;
 
Index: src/benchmark/CorCtxSwitch.c
===================================================================
--- src/benchmark/CorCtxSwitch.c	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ src/benchmark/CorCtxSwitch.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -3,23 +3,5 @@
 #include <thread>
 
-#include <unistd.h>					// sysconf
-#include <sys/times.h>					// times
-#include <time.h>
-
-inline unsigned long long int Time() {
-    timespec ts;
-    clock_gettime(
-#if defined( __linux__ )
-	 CLOCK_THREAD_CPUTIME_ID,
-#elif defined( __freebsd__ )
-	 CLOCK_PROF,
-#elif defined( __solaris__ )
-	 CLOCK_HIGHRES,
-#else
-    #error uC++ : internal error, unsupported architecture
-#endif
-	 &ts );
-    return 1000000000LL * ts.tv_sec + ts.tv_nsec;
-} // Time
+#include "bench.h"
 
 coroutine GreatSuspender {};
@@ -42,8 +24,4 @@
 }
 
-#ifndef N
-#define N 100000000
-#endif
-
 int main() {
 	const unsigned int NoOfTimes = N;
Index: src/benchmark/Makefile.am
===================================================================
--- src/benchmark/Makefile.am	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ src/benchmark/Makefile.am	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -44,4 +44,18 @@
 	@rm -f ./a.out
 
+sched-int:
+	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 SchedInt.c
+	@for number in 1 2 3 4 5 6 7 8 9 10; do \
+                ./a.out ; \
+        done
+	@rm -f ./a.out
+
+monitor:
+	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 Monitor.c
+	@for number in 1 2 3 4 5 6 7 8 9 10; do \
+                ./a.out ; \
+        done
+	@rm -f ./a.out
+
 csv-data:
 	@${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -quiet -DN=10000000 csv-data.c
Index: src/benchmark/Makefile.in
===================================================================
--- src/benchmark/Makefile.in	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ src/benchmark/Makefile.in	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -492,4 +492,18 @@
 	@rm -f ./a.out
 
+sched-int:
+	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 SchedInt.c
+	@for number in 1 2 3 4 5 6 7 8 9 10; do \
+                ./a.out ; \
+        done
+	@rm -f ./a.out
+
+monitor:
+	${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 Monitor.c
+	@for number in 1 2 3 4 5 6 7 8 9 10; do \
+                ./a.out ; \
+        done
+	@rm -f ./a.out
+
 csv-data:
 	@${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -quiet -DN=10000000 csv-data.c
Index: src/benchmark/Monitor.c
===================================================================
--- src/benchmark/Monitor.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
+++ src/benchmark/Monitor.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -0,0 +1,32 @@
+#include <fstream>
+#include <stdlib>
+#include <thread>
+
+#include "bench.h"
+
+monitor mon_t {};
+
+mon_t mon1, mon2;
+
+void dummy( mon_t * mutex a ) {}
+void dummy( mon_t * mutex a, mon_t * mutex b ) {}
+
+int main() {
+	long long int StartTime, EndTime;
+
+	StartTime = Time();
+	for( int i = 0; i < N; i++ ) {
+		dummy( &mon1 );
+	}
+	EndTime = Time();
+
+	sout | ( EndTime - StartTime ) / N;
+
+	StartTime = Time();
+	for( int i = 0; i < N; i++ ) {
+		dummy( &mon1, &mon2 );
+	}
+	EndTime = Time();
+
+	sout | ( EndTime - StartTime ) / N | endl;
+}
Index: src/benchmark/SchedInt.c
===================================================================
--- src/benchmark/SchedInt.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
+++ src/benchmark/SchedInt.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -0,0 +1,83 @@
+#include <fstream>
+#include <stdlib>
+#include <thread>
+
+#include "bench.h"
+
+condition condA; 
+condition condB;
+condition condC;
+condition condD;
+
+monitor mon_t {};
+
+mon_t mon1, mon2;
+
+thread thrdA {};
+thread thrdB {};
+thread thrdC {};
+thread thrdD {};
+
+//-------------------------------------------------------------------
+// 1 monitor signal cycle
+void sideA( mon_t * mutex a ) {
+	long long int StartTime, EndTime;
+
+	StartTime = Time();
+	for( int i = 0;; i++ ) {
+		signal(&condA);
+		if( i > N ) break;
+		wait(&condB);
+	}
+	EndTime = Time();
+
+	sout | ( EndTime - StartTime ) / N;
+}
+
+void sideB( mon_t * mutex a ) {
+	for( int i = 0;; i++ ) {
+		signal(&condB);
+		if( i > N ) break;
+		wait(&condA);
+	}
+}
+
+//-------------------------------------------------------------------
+// 2 monitor signal cycle
+void sideC( mon_t * mutex a, mon_t * mutex b ) {
+	long long int StartTime, EndTime;
+
+	StartTime = Time();
+	for( int i = 0;; i++ ) {
+		signal(&condC);
+		if( i > N ) break;
+		wait(&condD);
+	}
+	EndTime = Time();
+
+	sout | ( EndTime - StartTime ) / N | endl;
+}
+
+void sideD( mon_t * mutex a, mon_t * mutex b ) {
+	for( int i = 0;; i++ ) {
+		signal(&condD);
+		if( i > N ) break;
+		wait(&condC);
+	}
+}
+
+void main( thrdA * this ) { sideA( &mon1 ); }
+void main( thrdB * this ) { sideB( &mon1 ); }
+void main( thrdC * this ) { sideC( &mon1, &mon2 ); }
+void main( thrdD * this ) { sideD( &mon1, &mon2 ); }
+
+int main() {
+	{
+		thrdA a;
+		thrdB b;
+	}
+	{
+		thrdC c;
+		thrdD d;
+	}
+}
Index: src/benchmark/ThrdCtxSwitch.c
===================================================================
--- src/benchmark/ThrdCtxSwitch.c	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ src/benchmark/ThrdCtxSwitch.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -3,27 +3,5 @@
 #include <thread>
 
-#include <unistd.h>					// sysconf
-#include <sys/times.h>					// times
-#include <time.h>
-
-inline unsigned long long int Time() {
-    timespec ts;
-    clock_gettime(
-#if defined( __linux__ )
-	 CLOCK_THREAD_CPUTIME_ID,
-#elif defined( __freebsd__ )
-	 CLOCK_PROF,
-#elif defined( __solaris__ )
-	 CLOCK_HIGHRES,
-#else
-    #error uC++ : internal error, unsupported architecture
-#endif
-	 &ts );
-    return 1000000000LL * ts.tv_sec + ts.tv_nsec;
-} // Time
- 
-#ifndef N
-#define N 100000000
-#endif
+#include "bench.h"
 
 int main() {
Index: src/benchmark/bench.c
===================================================================
--- src/benchmark/bench.c	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ src/benchmark/bench.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -4,23 +4,5 @@
 #include <thread>
 
-#include <unistd.h>					// sysconf
-#include <sys/times.h>					// times
-#include <time.h>
-
-inline unsigned long long int Time() {
-    timespec ts;
-    clock_gettime(
-#if defined( __linux__ )
-	 CLOCK_THREAD_CPUTIME_ID,
-#elif defined( __freebsd__ )
-	 CLOCK_PROF,
-#elif defined( __solaris__ )
-	 CLOCK_HIGHRES,
-#else
-    #error uC++ : internal error, unsupported architecture
-#endif
-	 &ts );
-    return 1000000000LL * ts.tv_sec + ts.tv_nsec;
-} // Time
+#include "bench.h"
 
 //=======================================
Index: src/benchmark/bench.h
===================================================================
--- src/benchmark/bench.h	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
+++ src/benchmark/bench.h	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -0,0 +1,27 @@
+#pragma once
+
+extern "C" {
+	#include <unistd.h>					// sysconf
+	#include <sys/times.h>					// times
+	#include <time.h>
+}
+
+inline unsigned long long int Time() {
+    timespec ts;
+    clock_gettime(
+#if defined( __linux__ )
+	 CLOCK_THREAD_CPUTIME_ID,
+#elif defined( __freebsd__ )
+	 CLOCK_PROF,
+#elif defined( __solaris__ )
+	 CLOCK_HIGHRES,
+#else
+    #error uC++ : internal error, unsupported architecture
+#endif
+	 &ts );
+    return 1000000000LL * ts.tv_sec + ts.tv_nsec;
+} // Time
+
+#ifndef N
+#define N 10000000
+#endif
Index: src/benchmark/csv-data.c
===================================================================
--- src/benchmark/csv-data.c	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ src/benchmark/csv-data.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -1,27 +1,8 @@
 #include <fstream>
+#include <monitor>
 #include <stdlib>
 #include <thread>
 
-extern "C" {
-#include <unistd.h>					// sysconf
-#include <sys/times.h>					// times
-#include <time.h>
-}
-
-inline unsigned long long int Time() {
-    timespec ts;
-    clock_gettime(
-#if defined( __linux__ )
-	 CLOCK_THREAD_CPUTIME_ID,
-#elif defined( __freebsd__ )
-	 CLOCK_PROF,
-#elif defined( __solaris__ )
-	 CLOCK_HIGHRES,
-#else
-    #error uC++ : internal error, unsupported architecture
-#endif
-	 &ts );
-    return 1000000000LL * ts.tv_sec + ts.tv_nsec;
-} // Time
+#include "bench.h"
 
 coroutine GreatSuspender {};
@@ -48,6 +29,6 @@
 #endif
 
-
-
+//-----------------------------------------------------------------------------
+// coroutine context switch
 long long int measure_coroutine() {
 	const unsigned int NoOfTimes = N;
@@ -67,4 +48,6 @@
 }
 
+//-----------------------------------------------------------------------------
+// thread context switch
 long long int measure_thread() {
 	const unsigned int NoOfTimes = N;
@@ -80,6 +63,47 @@
 }
 
+//-----------------------------------------------------------------------------
+// single monitor entry
+monitor mon_t {};
+void dummy( mon_t * mutex m ) {}
+
+long long int measure_1_monitor_entry() {
+	const unsigned int NoOfTimes = N;
+	long long int StartTime, EndTime;
+	mon_t mon;
+
+	StartTime = Time();
+	for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) {
+		dummy( &mon );
+	}
+	EndTime = Time();
+
+	return ( EndTime - StartTime ) / NoOfTimes;
+}
+
+//-----------------------------------------------------------------------------
+// multi monitor entry
+void dummy( mon_t * mutex m1,  mon_t * mutex m2 ) {}
+
+long long int measure_2_monitor_entry() {
+	const unsigned int NoOfTimes = N;
+	long long int StartTime, EndTime;
+	mon_t mon1, mon2;
+
+	StartTime = Time();
+	for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) {
+		dummy( &mon1, &mon2 );
+	}
+	EndTime = Time();
+
+	return ( EndTime - StartTime ) / NoOfTimes;
+}
+
 int main()
 {
-	sout | time(NULL) | ',' | measure_coroutine() | ',' | measure_thread() | endl;
+	sout | time(NULL) | ',';
+	sout | measure_coroutine() | ',';
+	sout | measure_thread() | ',';
+	sout | measure_1_monitor_entry() | ',';
+	sout | measure_2_monitor_entry() | endl;
 }
Index: src/libcfa/concurrency/thread.c
===================================================================
--- src/libcfa/concurrency/thread.c	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ src/libcfa/concurrency/thread.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -40,6 +40,6 @@
 	this->next = NULL;
 
-	this->current_monitors      = NULL;
-	this->current_monitor_count = 0;
+	this->current_monitors      = &this->mon;
+	this->current_monitor_count = 1;
 }
 
Index: src/tests/.expect/concurrent/sched-int-barge.txt
===================================================================
--- src/tests/.expect/concurrent/sched-int-barge.txt	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
+++ src/tests/.expect/concurrent/sched-int-barge.txt	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -0,0 +1,100 @@
+1000
+2000
+3000
+4000
+5000
+6000
+7000
+8000
+9000
+10000
+11000
+12000
+13000
+14000
+15000
+16000
+17000
+18000
+19000
+20000
+21000
+22000
+23000
+24000
+25000
+26000
+27000
+28000
+29000
+30000
+31000
+32000
+33000
+34000
+35000
+36000
+37000
+38000
+39000
+40000
+41000
+42000
+43000
+44000
+45000
+46000
+47000
+48000
+49000
+50000
+51000
+52000
+53000
+54000
+55000
+56000
+57000
+58000
+59000
+60000
+61000
+62000
+63000
+64000
+65000
+66000
+67000
+68000
+69000
+70000
+71000
+72000
+73000
+74000
+75000
+76000
+77000
+78000
+79000
+80000
+81000
+82000
+83000
+84000
+85000
+86000
+87000
+88000
+89000
+90000
+91000
+92000
+93000
+94000
+95000
+96000
+97000
+98000
+99000
+100000
Index: src/tests/.expect/concurrent/sched-int-disjoint.txt
===================================================================
--- src/tests/.expect/concurrent/sched-int-disjoint.txt	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
+++ src/tests/.expect/concurrent/sched-int-disjoint.txt	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -0,0 +1,101 @@
+1000
+2000
+3000
+4000
+5000
+6000
+7000
+8000
+9000
+10000
+11000
+12000
+13000
+14000
+15000
+16000
+17000
+18000
+19000
+20000
+21000
+22000
+23000
+24000
+25000
+26000
+27000
+28000
+29000
+30000
+31000
+32000
+33000
+34000
+35000
+36000
+37000
+38000
+39000
+40000
+41000
+42000
+43000
+44000
+45000
+46000
+47000
+48000
+49000
+50000
+51000
+52000
+53000
+54000
+55000
+56000
+57000
+58000
+59000
+60000
+61000
+62000
+63000
+64000
+65000
+66000
+67000
+68000
+69000
+70000
+71000
+72000
+73000
+74000
+75000
+76000
+77000
+78000
+79000
+80000
+81000
+82000
+83000
+84000
+85000
+86000
+87000
+88000
+89000
+90000
+91000
+92000
+93000
+94000
+95000
+96000
+97000
+98000
+99000
+100000
+All waiter done
Index: src/tests/.expect/concurrent/sched-int-multi.txt
===================================================================
--- src/tests/.expect/concurrent/sched-int-multi.txt	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ 	(revision )
@@ -1,100 +1,0 @@
-1000
-2000
-3000
-4000
-5000
-6000
-7000
-8000
-9000
-10000
-11000
-12000
-13000
-14000
-15000
-16000
-17000
-18000
-19000
-20000
-21000
-22000
-23000
-24000
-25000
-26000
-27000
-28000
-29000
-30000
-31000
-32000
-33000
-34000
-35000
-36000
-37000
-38000
-39000
-40000
-41000
-42000
-43000
-44000
-45000
-46000
-47000
-48000
-49000
-50000
-51000
-52000
-53000
-54000
-55000
-56000
-57000
-58000
-59000
-60000
-61000
-62000
-63000
-64000
-65000
-66000
-67000
-68000
-69000
-70000
-71000
-72000
-73000
-74000
-75000
-76000
-77000
-78000
-79000
-80000
-81000
-82000
-83000
-84000
-85000
-86000
-87000
-88000
-89000
-90000
-91000
-92000
-93000
-94000
-95000
-96000
-97000
-98000
-99000
-100000
Index: src/tests/.expect/concurrent/sched-int-multi2.txt
===================================================================
--- src/tests/.expect/concurrent/sched-int-multi2.txt	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ 	(revision )
@@ -1,12 +1,0 @@
-Waiting 1
-Waiting 2
-Waiting 3
-Waiting 4
-Signaling ABC
-Signaling AB
-Signaling BC
-Signaling AC
-Waking 4
-Waking 3
-Waking 2
-Waking 1
Index: src/tests/.expect/concurrent/sched-int.txt
===================================================================
--- src/tests/.expect/concurrent/sched-int.txt	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ 	(revision )
@@ -1,3 +1,0 @@
-Step 1
-Step 2
-Step 3
Index: src/tests/Makefile.am
===================================================================
--- src/tests/Makefile.am	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ src/tests/Makefile.am	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -22,5 +22,5 @@
 concurrent=yes
 quick_test+= coroutine thread monitor
-concurrent_test=coroutine thread monitor multi-monitor sched-int sched-int-multi sched-int-multi2 sched-ext sched-ext-multi preempt
+concurrent_test=coroutine thread monitor multi-monitor sched-int-disjoint sched-int-barge sched-int-wait sched-ext sched-ext-multi preempt
 else
 concurrent=no
Index: src/tests/Makefile.in
===================================================================
--- src/tests/Makefile.in	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ src/tests/Makefile.in	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -230,5 +230,5 @@
 @BUILD_CONCURRENCY_TRUE@concurrent = yes
 @BUILD_CONCURRENCY_FALSE@concurrent_test = 
-@BUILD_CONCURRENCY_TRUE@concurrent_test = coroutine thread monitor multi-monitor sched-int sched-int-multi sched-int-multi2 sched-ext sched-ext-multi preempt
+@BUILD_CONCURRENCY_TRUE@concurrent_test = coroutine thread monitor multi-monitor sched-int-disjoint sched-int-barge sched-int-wait sched-ext sched-ext-multi preempt
 
 # applies to both programs
Index: src/tests/sched-int-barge.c
===================================================================
--- src/tests/sched-int-barge.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
+++ src/tests/sched-int-barge.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -0,0 +1,97 @@
+#include <fstream>
+#include <kernel>
+#include <monitor>
+#include <stdlib>
+#include <thread>
+
+enum state_t { WAIT, SIGNAL, BARGE };
+
+monitor global_t {};
+
+monitor global_data_t {
+	bool done;
+	int counter;
+	state_t state;
+
+	unsigned short do_signal;
+	unsigned short do_wait2;
+	unsigned short do_wait1;
+};
+
+void ?{} ( global_data_t * this ) {
+	this->done = false;
+	this->counter = 0;
+	this->state = BARGE;
+
+	this->do_signal = 6;
+	this->do_wait1  = 1;
+	this->do_wait2  = 3;
+}
+
+void ^?{} ( global_data_t * this ) {}
+
+global_t globalA;
+global_t globalB;
+global_data_t globalC;
+
+condition cond;
+
+thread Threads {};
+
+bool logicC( global_t * mutex a, global_t * mutex b, global_data_t * mutex c ) {
+	c->counter++;
+
+	if( (c->counter % 1000) == 0 ) sout | c->counter | endl;
+
+	int action = c->counter % 10;
+
+	if( action == 0 ) {
+		c->do_signal = max( ((unsigned)rand48()) % 10, 1);
+		c->do_wait1 = ((unsigned)rand48()) % (c->do_signal);
+		c->do_wait2 = ((unsigned)rand48()) % (c->do_signal);
+
+		// if(c->do_wait1 == c->do_wait2) sout | "Same" | endl;
+	}
+
+	if( action == c->do_wait1 || action == c->do_wait2 ) {
+		c->state = WAIT;
+		wait( &cond );
+
+		if(c->state != SIGNAL) {
+			sout | "ERROR Barging detected" | c->counter | endl;
+			abort();
+		}
+	}
+	else if( action == c->do_signal ) {
+		c->state = SIGNAL;
+
+		signal( &cond );
+		signal( &cond );
+	}
+	else {
+		c->state = BARGE;
+	}
+
+	if( c->counter >= 100_000 ) c->done = true;
+	return !c->done;
+}
+
+bool logicB( global_t * mutex a, global_t * mutex b ) {
+	return logicC(a, b, &globalC);
+}
+
+bool logicA( global_t * mutex a ) {
+	return logicB(a, &globalB);
+}
+
+void main( Threads* this ) {
+	while( logicA(&globalA) ) { yield(); };
+}
+
+int main(int argc, char* argv[]) {
+	rand48seed(0);
+	processor p;
+	{
+		Threads t[17];
+	}
+}
Index: src/tests/sched-int-disjoint.c
===================================================================
--- src/tests/sched-int-disjoint.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
+++ src/tests/sched-int-disjoint.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -0,0 +1,115 @@
+#include <fstream>
+#include <kernel>
+#include <monitor>
+#include <thread>
+
+#define N 100_000
+
+enum state_t { WAIT, SIGNAL, BARGE };
+
+monitor global_t {};
+global_t mut;
+
+monitor global_data_t;
+void ?{}( global_data_t * this );
+void ^?{} ( global_data_t * this );
+
+monitor global_data_t {
+	int counter;
+	state_t state;
+} data;
+
+condition cond;
+
+volatile bool all_done;
+
+void ?{}( global_data_t * this ) {
+	this->counter == 0;
+	this->state = BARGE;
+}
+
+void ^?{} ( global_data_t * this ) {}
+
+//------------------------------------------------------------------------------
+// Barging logic
+void barge( global_data_t * mutex d ) {
+	d->state = BARGE;
+}
+
+thread Barger {};
+
+void main( Barger * this ) {
+	while( !all_done ) { 
+		barge( &data );
+		yield(); 
+	}
+}
+
+//------------------------------------------------------------------------------
+// Waiting logic
+bool wait( global_t * mutex m, global_data_t * mutex d ) {
+	wait( &cond );
+	if( d->state != SIGNAL ) {
+		sout | "ERROR barging!" | endl; 
+	}
+
+	d->counter++;
+
+	if( (d->counter % 1000) == 0 ) sout | d->counter | endl;
+
+	return d->counter < N;
+}
+
+thread Waiter {};
+
+void main( Waiter * this ) {
+	while( wait( &mut, &data ) ) { yield(); }
+}
+
+
+//------------------------------------------------------------------------------
+// Signalling logic
+void signal( condition * cond, global_t * mutex a, global_data_t * mutex b ) {
+	b->state = SIGNAL;
+	signal( cond );
+}
+
+void logic( global_t * mutex a ) {
+	signal( &cond, a, &data );
+
+	int pauses = (unsigned)rand48() % 10;
+	for(int i = 0; i < pauses; i++) {
+		yield();
+	}
+
+	//This is technically a mutual exclusion violation but the mutex monitor protects us
+	bool running = data.counter < N && data.counter > 0;
+	if( data.state != SIGNAL && running ) {
+		sout | "ERROR Eager signal" | data.state | endl; 
+	}
+}
+
+thread Signaller {};
+
+void main( Signaller * this ) {
+	while( !all_done ) { 
+		logic( &mut );
+		yield(); 
+	}
+}
+
+//------------------------------------------------------------------------------
+// Main loop
+int main(int argc, char* argv[]) {
+	all_done = false;
+	processor p;
+	{
+		Signaller s;
+		Barger b[17];
+		{
+			Waiter w[4];
+		}
+		sout | "All waiter done" | endl;
+		all_done = true;
+	}	
+}
Index: src/tests/sched-int-multi.c
===================================================================
--- src/tests/sched-int-multi.c	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ 	(revision )
@@ -1,88 +1,0 @@
-#include <fstream>
-#include <kernel>
-#include <monitor>
-#include <thread>
-
-enum state_t { WAIT, SIGNAL, BARGE };
-
-monitor global_t {};
-
-monitor global_data_t {
-	bool done;
-	int counter;
-	state_t state;
-};
-
-void ?{} ( global_data_t * this ) {
-	this->done = false;
-	this->counter = 0;
-	this->state = BARGE;
-}
-
-void ^?{} ( global_data_t * this ) {}
-
-global_t globalA;
-global_t globalB;
-global_data_t globalC;
-
-condition cond;
-
-thread Threads {};
-
-bool logicC( global_t * mutex a, global_t * mutex b, global_data_t * mutex c ) {
-	c->counter++;
-
-	int action = c->counter % 10;
-
-	if( action == 1 || action == 3 ) {
-		if(c->state != BARGE) {
-			sout | "ERROR Mutual exclusion is inconsistent for wait" | endl;
-			abort();
-		}
-
-		c->state = WAIT;
-		wait( &cond );
-
-		if(c->state != SIGNAL) {
-			sout | "ERROR Barging detected" | endl;
-			abort();
-		}
-	}
-	else if( action == 6 ) {
-		if(c->state != BARGE) {
-			sout | "ERROR Mutual exclusion is inconsistent for signal" | endl;
-			abort();
-		}
-
-		c->state = SIGNAL;
-
-		signal( &cond );
-		signal( &cond );
-	}
-	else {
-		c->state = BARGE;
-	}
-
-	if( (c->counter % 1000) == 0 ) sout | c->counter | endl;
-	if( c->counter == 100_000 ) c->done = true;
-	return !c->done;
-}
-
-bool logicB( global_t * mutex a, global_t * mutex b ) {
-	return logicC(a, b, &globalC);
-}
-
-bool logicA( global_t * mutex a ) {
-	return logicB(a, &globalB);
-}
-
-void main( Threads* this ) {
-	while( logicA(&globalA) ) { yield(); };
-}
-
-int main(int argc, char* argv[]) {
-	processor p[3];
-	{
-		Threads t[20];
-	}
-}
Index: src/tests/sched-int-multi2.c
===================================================================
--- src/tests/sched-int-multi2.c	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ 	(revision )
@@ -1,119 +1,0 @@
-#include <fstream>
-#include <kernel>
-#include <monitor>
-#include <thread>
-
-monitor global_t {};
-
-global_t globalA;
-global_t globalB;
-global_t globalC;
-
-condition condAB, condAC, condBC, condABC;
-
-thread Signaler {};
-thread WaiterAB {};
-thread WaiterAC {};
-thread WaiterBC {};
-thread WaiterABC{};
-
-int state;
-
-/*
-multi phase
-*/
-
-//----------------------------------------------------------------------------------------------------
-// Tools
-void signal( condition * cond, global_t * mutex a, global_t * mutex b ) {
-	signal( cond );
-}
-
-void signal( condition * cond, global_t * mutex a, global_t * mutex b, global_t * mutex c ) {
-	signal( cond );
-}
-
-void wait( condition * cond, global_t * mutex a, global_t * mutex b ) {
-	state++;
-	sout | "Waiting" | state | endl;
-	wait( cond );
-	sout | "Waking" | state | endl;
-	state--;
-}
-
-void wait( condition * cond, global_t * mutex a, global_t * mutex b, global_t * mutex c ) {
-	state++;
-	sout | "Waiting" | state | endl;
-	wait( cond );
-	sout | "Waking" | state | endl;
-	state--;
-}
-
-//----------------------------------------------------------------------------------------------------
-// Signaler
-// signals respectively AB, AC, BC, ABC
-void signalerABC( global_t * mutex a, global_t * mutex b, global_t * mutex c ) {
-	sout | "Signaling ABC" | endl;
-	signal( &condABC, a, b, c );
-	sout | "Signaling AB" | endl;
-	signal( &condAB , a, b );
-	sout | "Signaling BC" | endl;
-	signal( &condBC , b, c );
-	sout | "Signaling AC" | endl;
-	signal( &condAC , a, c );
-}
-
-void signalerAB( global_t * mutex a, global_t * mutex b, global_t * c ) {
-	signalerABC(a, b, c);
-}
-
-void signalerA( global_t * mutex a, global_t * b, global_t * c ) {
-	signalerAB (a, b, c);
-}
-
-void main( Signaler* this ) {
-	while( state != 4 ) { yield(); }
-	signalerA( &globalA, &globalB, &globalC );
-}
-
-//----------------------------------------------------------------------------------------------------
-// Waiter ABC
-void main( WaiterABC* this ) {
-	while( state != 0 ) { yield(); }
-	wait( &condABC, &globalA, &globalB, &globalC );
-}
-
-//----------------------------------------------------------------------------------------------------
-// Waiter AB
-void main( WaiterAB* this ) {
-	while( state != 1 ) { yield(); }
-	wait( &condAB , &globalA, &globalB );
-}
-
-//----------------------------------------------------------------------------------------------------
-// Waiter AC
-void main( WaiterAC* this ) {
-	while( state != 2 ) { yield(); }
-	wait( &condAC , &globalA, &globalC );
-}
-
-//----------------------------------------------------------------------------------------------------
-// Waiter BC
-void main( WaiterBC* this ) {
-	while( state != 3 ) { yield(); }
-	wait( &condBC , &globalB, &globalC );
-}
-
-//----------------------------------------------------------------------------------------------------
-// Main
-int main(int argc, char* argv[]) {
-	state = 0;
-	processor p;
-	{
-		WaiterABC a;
-		WaiterAB  b;
-		WaiterBC  c;
-		WaiterAC  d;
-		Signaler  e;
-	}
-}
Index: src/tests/sched-int-wait.c
===================================================================
--- src/tests/sched-int-wait.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
+++ src/tests/sched-int-wait.c	(revision 4f9636f7e4799b02b05a1d87290145d4349d1bb7)
@@ -0,0 +1,145 @@
+#include <fstream>
+#include <kernel>
+#include <monitor>
+#include <stdlib>
+#include <thread>
+
+monitor global_t {};
+
+global_t globalA;
+global_t globalB;
+global_t globalC;
+
+condition condAB, condAC, condBC, condABC;
+
+thread Signaler {
+	int signals[4];
+};
+
+void ?{}( Signaler * this ){
+	this->signals[0] = 0;
+	this->signals[1] = 0;
+	this->signals[2] = 0;
+	this->signals[3] = 0;
+}
+
+thread WaiterAB {};
+thread WaiterAC {};
+thread WaiterBC {};
+thread WaiterABC{};
+
+volatile bool done;
+
+//----------------------------------------------------------------------------------------------------
+// Tools
+void signal( condition * cond, global_t * mutex a, global_t * mutex b ) {
+	signal( cond );
+}
+
+void signal( condition * cond, global_t * mutex a, global_t * mutex b, global_t * mutex c ) {
+	signal( cond );
+}
+
+void wait( condition * cond, global_t * mutex a, global_t * mutex b ) {
+	wait( cond );
+}
+
+void wait( condition * cond, global_t * mutex a, global_t * mutex b, global_t * mutex c ) {
+	wait( cond );
+}
+
+//----------------------------------------------------------------------------------------------------
+// Signaler
+void main( Signaler* this ) {
+
+	while( true ) {
+		int action = (unsigned)rand48() % 4;
+		bool finished = true;
+
+		for(int i = 0; i < 4; i++) {
+			if( this->signals[action] < 10_000 ) {
+				finished = false;
+				break;
+			}
+			else {
+				action = (action + 1) % 4;
+			}
+		}
+
+		this->signals[action]++;
+		if( finished ) break;
+
+		//sout | action | this->signals[0] | this->signals[1] | this->signals[2] | this->signals[3] | endl;
+
+		switch( action ) {
+			case 0: 
+				signal( &condABC, &globalA, &globalB, &globalC );
+				break;
+			case 1: 
+				signal( &condAB , &globalA, &globalB );
+				break;
+			case 2: 
+				signal( &condBC , &globalB, &globalC );
+				break;
+			case 3: 
+				signal( &condAC , &globalA, &globalC );
+				break;
+			default:
+				sout | "Something went wrong" | endl;
+				abort();
+		}
+	}	
+}
+
+//----------------------------------------------------------------------------------------------------
+// Waiter ABC
+void main( WaiterABC* this ) {
+	while( !done ) {
+		wait( &condABC, &globalA, &globalB, &globalC );
+	}
+}
+
+//----------------------------------------------------------------------------------------------------
+// Waiter AB
+void main( WaiterAB* this ) {
+	while( !done ) {
+		wait( &condAB , &globalA, &globalB );
+	}
+}
+
+//----------------------------------------------------------------------------------------------------
+// Waiter AC
+void main( WaiterAC* this ) {
+	while( !done ) {
+		wait( &condAC , &globalA, &globalC );
+	}
+}
+
+//----------------------------------------------------------------------------------------------------
+// Waiter BC
+void main( WaiterBC* this ) {
+	while( !done ) {
+		wait( &condBC , &globalB, &globalC );
+	}
+}
+
+//----------------------------------------------------------------------------------------------------
+// Main
+int main(int argc, char* argv[]) {
+	done = false;
+	processor p;
+	{
+		WaiterABC a;
+		WaiterAB  b;
+		WaiterBC  c;
+		WaiterAC  d;
+		{
+			Signaler  e;
+		}
+		done = true;
+		signal( &condABC, &globalA, &globalB, &globalC );
+		signal( &condAB , &globalA, &globalB );
+		signal( &condBC , &globalB, &globalC );
+		signal( &condAC , &globalA, &globalC );
+	}
+}
Index: src/tests/sched-int.c
===================================================================
--- src/tests/sched-int.c	(revision 45a4ea7b4ffa6e127cea953d9ecb169b80daa761)
+++ 	(revision )
@@ -1,60 +1,0 @@
-#include <fstream>
-#include <kernel>
-#include <monitor>
-#include <thread>
-
-monitor global_t {
-	int value;
-};
-
-global_t global;
-
-condition cond;
-
-thread Signalee {};
-thread Signaler {};
-
-void step1( global_t * mutex this ) {
-	sout | "Step 1" | endl;
-	this->value = 1;
-	wait( &cond );
-}
-
-void step2( global_t * mutex this ) {
-	if( this->value != 1) abort();
-
-	sout | "Step 2" | endl;
-	this->value = 2;
-	signal( &cond );
-}
-
-void step3( global_t * mutex this ) {
-	if( this->value != 2) abort();
-
-	sout | "Step 3" | endl;
-	this->value = 3;
-	signal( &cond );
-}
-
-void main( Signalee* this ) {
-	step1( &global );
-	step3( &global );
-}
-
-void main( Signaler* this ) {
-	for(int i = 0; i < 10_000; i++) {
-		asm volatile ("" : : : "memory");
-	}
-
-	step2( &global );
-}
-
-int main(int argc, char* argv[]) {
-	assert( global.__mon.entry_queue.tail != NULL );
-	processor p;
-	{
-		Signalee a;
-		Signaler b;
-	}
-	if( global.value != 3) abort();
-}
