Index: doc/theses/thierry_delisle_PhD/code/readQ_example/Makefile
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/Makefile	(revision b9537e6e28ae020f54097b3d63e5a8bebeaf1cde)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/Makefile	(revision 72b1800836927a601b620714ee761a5c73e44dfa)
@@ -1,6 +1,18 @@
-all: gui-proto
+all: gui-proto-pthread gui-proto-fibre gui-proto-cforall
+
+PRECIOUS: thrdlib/libthrd-pthread.so thrdlib/libthrd-fibre.so thrdlib/libthrd-cforall.so
 
 CXXFLAGS = -fpic -g -O0 -I.
 
-gui-proto: proto-gui/main.o thrdlib/thread.o
-	$(CXX) -pthread -ldl -o ${@} ${^} -ftls-model=initial-exec
+thrdlib/libthrd-%.so:
+	+${MAKE} -C thrdlib libthrd-$*.so
+
+gui-proto-%: proto-gui/main.o thrdlib/libthrd-%.so Makefile
+	$(CXX) -Lthrdlib -Wl,--rpath,thrdlib -pthread -o $@ $< -lthrd-$*
+
+CFAINC=${HOME}/local/include/cfa-dev
+CFALIB=${HOME}/local/lib/cfa-dev/x64-debug
+CFAFLAGS=-z execstack -ftls-model=initial-exec -L${CFALIB} -Wl,-rpath,${CFALIB}
+
+gui-proto-cforall: proto-gui/main.o thrdlib/libthrd-cforall.so Makefile
+	$(CXX) -Lthrdlib -Wl,--rpath,thrdlib ${CFAFLAGS} -pthread -o $@ $< -lthrd-cforall -Wl,--push-state,--no-as-needed -lcfathread -lcfa -ldl -lm -Wl,--pop-state
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/proto-gui/main.cpp
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/proto-gui/main.cpp	(revision b9537e6e28ae020f54097b3d63e5a8bebeaf1cde)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/proto-gui/main.cpp	(revision 72b1800836927a601b620714ee761a5c73e44dfa)
@@ -11,27 +11,4 @@
 #include <getopt.h>
 using thrdlib::thread_t;
-
-
-extern __attribute__((aligned(128))) thread_local struct {
-	void * volatile this_thread;
-	void * volatile this_processor;
-	void * volatile this_stats;
-
-	struct {
-		volatile unsigned short disable_count;
-		volatile bool enabled;
-		volatile bool in_progress;
-	} preemption_state;
-
-	#if defined(__SIZEOF_INT128__)
-		__uint128_t rand_seed;
-	#else
-		uint64_t rand_seed;
-	#endif
-	struct {
-		uint64_t fwd_seed;
-		uint64_t bck_seed;
-	} ready_rng;
-} kernelTLS __attribute__ ((tls_model ( "initial-exec" )));
 
 //--------------------
@@ -148,4 +125,15 @@
 }
 
+typedef uint64_t __wyhash64_state_t;
+static inline uint64_t __wyhash64( __wyhash64_state_t & state ) {
+	state += 0x60bee2bee120fc15;
+	__uint128_t tmp;
+	tmp = (__uint128_t) state * 0xa3b195354a39b70d;
+	uint64_t m1 = (tmp >> 64) ^ tmp;
+	tmp = (__uint128_t)m1 * 0x1b03738712fad5c9;
+	uint64_t m2 = (tmp >> 64) ^ tmp;
+	return m2;
+}
+
 void Simulator( thread_t self ) {
 	for(unsigned i = 0; i < nproduce; i++) {
@@ -156,8 +144,10 @@
 		}
 
+		__wyhash64_state_t state = 0;
+
 		// Write the frame information
 		frame.number = i;
 		for( unsigned x = 0; x < fsize; x++ ) {
-			frame.data[x] = i;
+			frame.data[x] = __wyhash64(state);
 		}
 		std::cout << "Simulated " << i << std::endl;
@@ -187,5 +177,5 @@
 
 		std::cout << "Rendered " << i << std::endl;
-		assert(total == i * fsize);
+		// assert(total == i * fsize);
 
 		// Release
@@ -201,8 +191,6 @@
 int main(int argc, char * argv[]) {
 	nframes  = 3;
-	fsize    = 1000;
+	fsize    = 3840 * 2160 * 4 * 4;
 	nproduce = 60;
-
-	const char * framework;
 
 	for(;;) {
@@ -222,11 +210,4 @@
 			// Exit Case
 			case -1:
-				/* paranoid */ assert(optind <= argc);
-				if( optind == argc ) {
-					std::cerr << "Must specify a framework" << std::endl;
-					goto usage;
-
-				}
-				framework = argv[optind];
 				goto run;
 			case 'b':
@@ -261,5 +242,5 @@
 				std::cerr << opt << std::endl;
 			usage:
-				std::cerr << "Usage: " << argv[0] << " [options] framework" << std::endl;
+				std::cerr << "Usage: " << argv[0] << " [options]" << std::endl;
 				std::cerr << std::endl;
 				std::cerr << "  -b, --buff=COUNT    Number of frames to buffer" << std::endl;
@@ -270,6 +251,4 @@
 	}
 	run:
-	assert( framework );
-
 	frames.reset(new Frame[nframes]);
 	for(unsigned i = 0; i < nframes; i++) {
@@ -280,5 +259,5 @@
 	std::cout << "(Buffering " << nframes << ")" << std::endl;
 
-	thrdlib::init( framework, 2 );
+	thrdlib::init( 2 );
 
 	thread_t stats     = thrdlib::create( Stats );
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/Makefile
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/Makefile	(revision b9537e6e28ae020f54097b3d63e5a8bebeaf1cde)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/Makefile	(revision 72b1800836927a601b620714ee761a5c73e44dfa)
@@ -1,14 +1,14 @@
-all: fibre.so pthread.so cforall.so
+all: fibre.so libthrd-pthread.so.so cforall.so
 
 clean:
-	rm -rf fibre.so pthread.so
+	rm -rf fibre.so libthrd-pthread.so.so cforall.so
 
 CXXFLAGS=-Wall -Wextra -O3 -g -fpic -std=c++17 -pthread -ftls-model=initial-exec
 
-pthread.so: pthread.cpp Makefile
-	$(CXX) $(CXXFLAGS) -shared -o ${@} ${<}
+libthrd-pthread.so: thread.cpp thread.hpp Makefile
+	$(CXX) $(CXXFLAGS) -shared -o $@ $< -DWITH_PTHREADS
 
-fibre.so: fibre.cpp Makefile
-	$(CXX) $(CXXFLAGS) -shared -o ${@} ${<} -lfibre
+libthrd-fibre.so: thread.cpp thread.hpp Makefile
+	$(CXX) $(CXXFLAGS) -shared -o $@ $< -DWITH_LIBFIBRE -lfibre
 
 CFAINC=${HOME}/local/include/cfa-dev
@@ -16,4 +16,4 @@
 CFAFLAGS=-z execstack -I${CFAINC} -I${CFAINC}/concurrency -L${CFALIB} -Wl,-rpath,${CFALIB}
 
-cforall.so: cforall.cpp Makefile
-	$(CXX) $(CXXFLAGS) $(CFAFLAGS) -shared -o ${@} ${<} -lcfathread -lcfa -ldl -lm
+libthrd-cforall.so: thread.cpp thread.hpp Makefile
+	$(CXX) $(CXXFLAGS) $(CFAFLAGS) -shared -o $@ $< -DWITH_CFORALL -Wl,--push-state,--no-as-needed -lcfathread -lcfa -ldl -lm -Wl,--pop-state
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/pthread.hpp
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/pthread.hpp	(revision b9537e6e28ae020f54097b3d63e5a8bebeaf1cde)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/pthread.hpp	(revision 72b1800836927a601b620714ee761a5c73e44dfa)
@@ -1,2 +1,4 @@
+#pragma once
+
 #include <pthread.h>
 #include <errno.h>
@@ -97,3 +99,4 @@
 	// Basic kernel features
 	void thrdlib_init( int ) {}
+	void thrdlib_clean( void ) {}
 }
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.cpp
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.cpp	(revision b9537e6e28ae020f54097b3d63e5a8bebeaf1cde)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.cpp	(revision 72b1800836927a601b620714ee761a5c73e44dfa)
@@ -1,68 +1,28 @@
-#include "thread.hpp"
+#if !defined(WITH_PTHREADS) && !defined(WITH_LIBFIBRE) && !defined(WITH_CFORALL)
+#error must define WITH_PTHREADS, WITH_LIBFIBRE or WITH_CFORALL
+#endif
 
-#include <cstdarg>										// va_start, va_end
-#include <cstdio>
-#include <cstring>										// strlen
-extern "C" {
-	#include <unistd.h>										// _exit, getpid
-	#include <signal.h>
-	#include <dlfcn.h>										// dlopen, dlsym
-	#include <execinfo.h>									// backtrace, messages
-}
+#ifdef WITH_PTHREADS
+#include "pthread.hpp"
+#endif
+#ifdef WITH_LIBFIBRE
+#include "fibre.hpp"
+#endif
+#ifdef WITH_CFORALL
+#include "cforall.hpp"
+#endif
 
-#include <iostream>
-#include <string>
+namespace thrdlib {
+	//--------------------
+	// Basic thread support
+	void * create( void (*main)( void * ) ) { return (thread_t)thrdlib_create(  (void (*)( thread_t )) main ); }
+	void join  ( void * handle ) { thrdlib_join  ((thread_t)handle); }
+	void park  ( void * handle ) { thrdlib_park  ((thread_t)handle); }
+	void unpark( void * handle ) { thrdlib_unpark((thread_t)handle); }
+	void yield( void )  { thrdlib_yield(); }
 
-using thrdlib::thread_t;
-
-thread_t (*thrdlib::create)( void (*main)( thread_t ) ) = nullptr;
-void (*thrdlib::join)( thread_t handle ) = nullptr;
-void (*thrdlib::park)( thread_t handle ) = nullptr;
-void (*thrdlib::unpark)( thread_t handle ) = nullptr;
-void (*thrdlib::yield)( void ) = nullptr;
-void (*lib_clean)(void) = nullptr;
-
-typedef void (*fptr_t)();
-static fptr_t open_symbol( void * library, const char * symbol, bool required ) {
-	void * ptr = dlsym( library, symbol );
-
-	const char * error = dlerror();
-	if ( required && error ) {
-		std::cerr << "Fetching symbol '" << symbol << "' failed with error '" << error << "'\n";
-		std::abort();
-	}
-
-	return (fptr_t)ptr;
-}
-
-//--------------------
-// Basic kernel features
-void thrdlib::init( const char * name, int procs ) {
-	std::string file = __FILE__;
-	std::size_t found = file.find_last_of("/");
-  	std::string libname = file.substr(0,found+1) + name + ".so";
-
-	std::cout << "Use framework " << name << "(" << libname << ")\n";
-
-	void * library = dlopen( libname.c_str(), RTLD_NOW );
-	if ( const char * error = dlerror() ) {
-		std::cerr << "Could not open library '" << libname << "' from name '" << name <<"'\n";
-		std::cerr << "Error was : '" << error << "'\n";
-		std::abort();
-	}
-
-	void (*lib_init)( int ) = (void (*)( int ))open_symbol( library, "thrdlib_init", false );
-	lib_clean = open_symbol( library, "thrdlib_clean" , false );
-
-	thrdlib::create = (typeof(thrdlib::create))open_symbol( library, "thrdlib_create", true  );
-	thrdlib::join   = (typeof(thrdlib::join  ))open_symbol( library, "thrdlib_join"  , true  );
-	thrdlib::park   = (typeof(thrdlib::park  ))open_symbol( library, "thrdlib_park"  , true  );
-	thrdlib::unpark = (typeof(thrdlib::unpark))open_symbol( library, "thrdlib_unpark", true  );
-	thrdlib::yield  = (typeof(thrdlib::yield ))open_symbol( library, "thrdlib_yield" , true  );
-
-	lib_init( procs );
-}
-
-void thrdlib::clean( void ) {
-	if(lib_clean) lib_clean();
-}
+	//--------------------
+	// Basic kernel features
+	void init( int procs ) { thrdlib_init(procs); }
+	void clean( void ) { thrdlib_clean(); }
+};
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.hpp
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.hpp	(revision b9537e6e28ae020f54097b3d63e5a8bebeaf1cde)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.hpp	(revision 72b1800836927a601b620714ee761a5c73e44dfa)
@@ -6,13 +6,13 @@
 	//--------------------
 	// Basic thread support
-	extern thread_t (*create)( void (*main)( thread_t ) );
-	extern void (*join)( thread_t handle );
-	extern void (*park)( thread_t handle );
-	extern void (*unpark)( thread_t handle );
-	extern void (*yield)( void ) ;
+	extern thread_t create( void (*main)( thread_t ) );
+	extern void join( thread_t handle );
+	extern void park( thread_t handle );
+	extern void unpark( thread_t handle );
+	extern void yield( void ) ;
 
 	//--------------------
 	// Basic kernel features
-	extern void init( const char * name, int procs );
+	extern void init( int procs );
 	extern void clean( void );
 };
