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 d035cf7ae13a327669561d011224e0ae270d5ee5)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/proto-gui/main.cpp	(revision 29185fc0ff744b0a61a984c92e468727a9c9bf75)
@@ -1,3 +1,3 @@
-#include "thrdlib/thread.h"
+#include "thrdlib/thread.hpp"
 
 #include <cassert>
@@ -10,4 +10,6 @@
 
 #include <getopt.h>
+using thrdlib::thread_t;
+
 
 //--------------------
@@ -37,5 +39,5 @@
 			assert( expected == reset );
 			if( std::atomic_compare_exchange_strong( &state, &expected, self) ) {
-				thrdlib_park( self );
+				thrdlib::park( self );
 				ret = true;
 				goto END;
@@ -55,5 +57,5 @@
 		if( got == reset ) return false;
 
-		thrdlib_unpark( got );
+		thrdlib::unpark( got );
 		return true;
 	}
@@ -110,5 +112,5 @@
 	the_stats_thread = self;
 	fence();
-	thrdlib_park( self );
+	thrdlib::park( self );
 
 	std::vector<bool> seen;
@@ -116,5 +118,5 @@
 
 	while(last_produced < nproduce) {
-		thrdlib_yield();
+		thrdlib::yield();
 		thrd_stats.stats.ran++;
 		if( last_produced > 0 ) seen.at(last_produced - 1) = true;
@@ -148,5 +150,5 @@
 
 void Renderer( thread_t self ) {
-	thrdlib_unpark( the_stats_thread );
+	thrdlib::unpark( the_stats_thread );
 	for(unsigned i = 0; i < nproduce; i++) {
 		auto & frame = frames[i % nframes];
@@ -247,21 +249,21 @@
 	std::cout << "(Buffering " << nframes << ")" << std::endl;
 
-	thrdlib_init( 2 );
-
-	thread_t stats     = thrdlib_create( Stats     );
+	thrdlib::init( "fibre", 2 );
+
+	thread_t stats     = thrdlib::create( Stats );
 	std::cout << "Created Stats Thread" << std::endl;
-	while( the_stats_thread == nullptr ) thrdlib_yield();
+	while( the_stats_thread == nullptr ) thrdlib::yield();
+
 	std::cout << "Creating Main Threads" << std::endl;
-	thread_t renderer  = thrdlib_create( Renderer  );
-	// while(true);
-	thread_t simulator = thrdlib_create( Simulator );
+	thread_t renderer  = thrdlib::create( Renderer  );
+	thread_t simulator = thrdlib::create( Simulator );
 
 	std::cout << "Running" << std::endl;
 
-	thrdlib_join( simulator );
-	thrdlib_join( renderer  );
-	thrdlib_join( stats     );
-
-	thrdlib_clean();
+	thrdlib::join( simulator );
+	thrdlib::join( renderer  );
+	thrdlib::join( stats     );
+
+	thrdlib::clean();
 
 	std::cout << "----------" << std::endl;
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/Makefile
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/Makefile	(revision 29185fc0ff744b0a61a984c92e468727a9c9bf75)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/Makefile	(revision 29185fc0ff744b0a61a984c92e468727a9c9bf75)
@@ -0,0 +1,10 @@
+all: fibre.so pthread.so
+
+clean:
+	rm -rf fibre.so pthread.so
+
+pthread.so: pthread.cpp Makefile
+	$(CXX) -Wall -Wextra -O3 -g -shared -o ${@} -pthread -fpic ${<}
+
+fibre.so: fibre.cpp Makefile
+	$(CXX) -Wall -Wextra -O3 -g -shared -o ${@} -pthread -fpic ${<} -lfibre
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/fibre.cpp
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/fibre.cpp	(revision 29185fc0ff744b0a61a984c92e468727a9c9bf75)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/fibre.cpp	(revision 29185fc0ff744b0a61a984c92e468727a9c9bf75)
@@ -0,0 +1,48 @@
+#include <cassert>
+#include <libfibre/cfibre.h>
+
+typedef cfibre_t thread_t;
+static_assert(sizeof(thread_t) == sizeof(void*), "thread_t musst be of same size as void*");
+
+void * fibre_runner(void * arg) {
+	auto the_main = (void (*)( thread_t ))arg;
+	the_main( cfibre_self() );
+	return nullptr;
+}
+
+extern "C" {
+	//--------------------
+	// Basic thread support
+	thread_t thrdlib_create( void (*the_main)( thread_t ) ) {
+		thread_t fibre;
+		cfibre_create( &fibre, nullptr, fibre_runner, (void*)the_main );
+		return fibre;
+	}
+
+	void thrdlib_join( thread_t handle ) {
+		cfibre_join( handle, nullptr );
+	}
+
+	void thrdlib_park( thread_t handle ) {
+		assert( handle == cfibre_self() );
+		cfibre_park();
+	}
+
+	void thrdlib_unpark( thread_t handle ) {
+		cfibre_unpark( handle );
+	}
+
+	void thrdlib_yield( void ) {
+		cfibre_yield();
+	}
+
+	//--------------------
+	// Basic kernel features
+	void thrdlib_init( int procs ) {
+		cfibre_init_n(1, procs );
+	}
+
+	void thrdlib_clean( void ) {
+
+	}
+}
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/pthread.cpp
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/pthread.cpp	(revision 29185fc0ff744b0a61a984c92e468727a9c9bf75)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/pthread.cpp	(revision 29185fc0ff744b0a61a984c92e468727a9c9bf75)
@@ -0,0 +1,99 @@
+#include <pthread.h>
+#include <errno.h>
+#include <cstring>
+#include <cstdio>
+#include <iostream>
+
+#define CHECKED(x) { int err = x; if( err != 0 ) { std::cerr << "KERNEL ERROR: Operation \"" #x "\" return error " << err << " - " << strerror(err) << std::endl; std::abort(); } }
+
+struct __bin_sem_t {
+	pthread_mutex_t 	lock;
+	pthread_cond_t  	cond;
+	int     		val;
+
+	__bin_sem_t() {
+		// Create the mutex with error checking
+		pthread_mutexattr_t mattr;
+		pthread_mutexattr_init( &mattr );
+		pthread_mutexattr_settype( &mattr, PTHREAD_MUTEX_ERRORCHECK_NP);
+		pthread_mutex_init(&lock, &mattr);
+
+		pthread_cond_init (&cond, nullptr);
+		val = 0;
+	}
+
+	~__bin_sem_t() {
+		CHECKED( pthread_mutex_destroy(&lock) );
+		CHECKED( pthread_cond_destroy (&cond) );
+	}
+
+	void wait() {
+		CHECKED( pthread_mutex_lock(&lock) );
+			while(val < 1) {
+				pthread_cond_wait(&cond, &lock);
+			}
+			val -= 1;
+		CHECKED( pthread_mutex_unlock(&lock) );
+	}
+
+	bool post() {
+		bool needs_signal = false;
+
+		CHECKED( pthread_mutex_lock(&lock) );
+			if(val < 1) {
+				val += 1;
+				pthread_cond_signal(&cond);
+				needs_signal = true;
+			}
+		CHECKED( pthread_mutex_unlock(&lock) );
+
+		return needs_signal;
+	}
+};
+
+#undef CHECKED
+
+//--------------------
+// Basic types
+struct pthread_runner_t {
+	pthread_t handle;
+	__bin_sem_t sem;
+};
+typedef pthread_runner_t * thread_t;
+
+static_assert(sizeof(thread_t) == sizeof(void*), "thread_t musst be of same size as void*");
+
+extern "C" {
+	//--------------------
+	// Basic thread support
+	thread_t thrdlib_create( void (*main)( thread_t ) ) {
+		thread_t thrd = new pthread_runner_t();
+		int r = pthread_create( &thrd->handle, nullptr, (void *(*)(void *))main, thrd );
+		if( r != 0 ) std::abort();
+		return thrd;
+	}
+
+	void thrdlib_join( thread_t handle ) {
+		void * ret;
+		int r = pthread_join( handle->handle, &ret );
+		if( r != 0 ) std::abort();
+		delete handle;
+	}
+
+	void thrdlib_park( thread_t handle ) {
+		handle->sem.wait();
+	}
+
+	void thrdlib_unpark( thread_t handle ) {
+		handle->sem.post();
+	}
+
+	void thrdlib_yield( void ) {
+		int r = pthread_yield();
+		if( r != 0 ) std::abort();
+	}
+
+	//--------------------
+	// Basic kernel features
+	void thrdlib_init( int ) {}
+}
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.cpp
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.cpp	(revision 29185fc0ff744b0a61a984c92e468727a9c9bf75)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.cpp	(revision 29185fc0ff744b0a61a984c92e468727a9c9bf75)
@@ -0,0 +1,68 @@
+#include "thread.hpp"
+
+#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
+}
+
+#include <iostream>
+#include <string>
+
+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 ( 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();
+}
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.h
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.h	(revision d035cf7ae13a327669561d011224e0ae270d5ee5)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#pragma once
-
-// #include "thread_pthread.h"
-
-#include "thread_libfibre.h"
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.hpp
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.hpp	(revision 29185fc0ff744b0a61a984c92e468727a9c9bf75)
+++ doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread.hpp	(revision 29185fc0ff744b0a61a984c92e468727a9c9bf75)
@@ -0,0 +1,18 @@
+#pragma once
+
+namespace thrdlib {
+	typedef void * thread_t;
+
+	//--------------------
+	// 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 ) ;
+
+	//--------------------
+	// Basic kernel features
+	extern void init( const char * name, int procs );
+	extern void clean( void );
+};
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread_libfibre.h
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread_libfibre.h	(revision d035cf7ae13a327669561d011224e0ae270d5ee5)
+++ 	(revision )
@@ -1,57 +1,0 @@
-#pragma once
-
-#include <cassert>
-#include <libfibre/cfibre.h>
-
-#if defined(__cforall) || defined(__cpluplus)
-extern "C" {
-#endif
-	//--------------------
-	// Basic types
-	typedef cfibre_t thread_t;
-
-	void * fibre_runner(void * arg) {
-		auto the_main = (void (*)( thread_t ))arg;
-		the_main( cfibre_self() );
-		return nullptr;
-	}
-
-	//--------------------
-	// Basic thread support
-	thread_t thrdlib_create( void (*the_main)( thread_t ) ) {
-		thread_t fibre;
-		cfibre_create( &fibre, nullptr, fibre_runner, (void*)the_main );
-		return fibre;
-	}
-
-	void thrdlib_join( thread_t handle ) {
-		cfibre_join( handle, nullptr );
-	}
-
-	void thrdlib_park( thread_t handle ) {
-		assert( handle == cfibre_self() );
-		cfibre_park();
-	}
-
-	void thrdlib_unpark( thread_t handle ) {
-		cfibre_unpark( handle );
-	}
-
-	void thrdlib_yield( void ) {
-		cfibre_yield();
-	}
-
-	//--------------------
-	// Basic kernel features
-	void thrdlib_init( int procs ) {
-		cfibre_init_n(1, procs );
-	}
-
-	void thrdlib_clean( void ) {
-
-	}
-
-
-#if defined(__cforall) || defined(__cpluplus)
-}
-#endif
Index: doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread_pthread.h
===================================================================
--- doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/thread_pthread.h	(revision d035cf7ae13a327669561d011224e0ae270d5ee5)
+++ 	(revision )
@@ -1,106 +1,0 @@
-#pragma once
-
-#include <pthread.h>
-#include <errno.h>
-#include <cstring>
-#include <cstdio>
-#include <iostream>
-
-#define CHECKED(x) { int err = x; if( err != 0 ) { std::cerr << "KERNEL ERROR: Operation \"" #x "\" return error " << err << " - " << strerror(err) << std::endl; std::abort(); } }
-
-struct __bin_sem_t {
-	pthread_mutex_t 	lock;
-	pthread_cond_t  	cond;
-	int     		val;
-
-	__bin_sem_t() {
-		// Create the mutex with error checking
-		pthread_mutexattr_t mattr;
-		pthread_mutexattr_init( &mattr );
-		pthread_mutexattr_settype( &mattr, PTHREAD_MUTEX_ERRORCHECK_NP);
-		pthread_mutex_init(&lock, &mattr);
-
-		pthread_cond_init (&cond, nullptr);
-		val = 0;
-	}
-
-	~__bin_sem_t() {
-		CHECKED( pthread_mutex_destroy(&lock) );
-		CHECKED( pthread_cond_destroy (&cond) );
-	}
-
-	void wait() {
-		CHECKED( pthread_mutex_lock(&lock) );
-			while(val < 1) {
-				pthread_cond_wait(&cond, &lock);
-			}
-			val -= 1;
-		CHECKED( pthread_mutex_unlock(&lock) );
-	}
-
-	bool post() {
-		bool needs_signal = false;
-
-		CHECKED( pthread_mutex_lock(&lock) );
-			if(val < 1) {
-				val += 1;
-				pthread_cond_signal(&cond);
-				needs_signal = true;
-			}
-		CHECKED( pthread_mutex_unlock(&lock) );
-
-		return needs_signal;
-	}
-};
-
-#undef CHECKED
-
-#if defined(__cforall) || defined(__cpluplus)
-extern "C" {
-#endif
-	//--------------------
-	// Basic types
-	struct pthread_runner_t {
-		pthread_t handle;
-		__bin_sem_t sem;
-	};
-	typedef pthread_runner_t * thread_t;
-
-	//--------------------
-	// Basic thread support
-	thread_t thrdlib_create( void (*main)( thread_t ) ) {
-		thread_t thrd = new pthread_runner_t();
-		int r = pthread_create( &thrd->handle, nullptr, (void *(*)(void *))main, thrd );
-		if( r != 0 ) std::abort();
-		return thrd;
-	}
-
-	void thrdlib_join( thread_t handle ) {
-		void * ret;
-		int r = pthread_join( handle->handle, &ret );
-		if( r != 0 ) std::abort();
-		delete handle;
-	}
-
-	void thrdlib_park( thread_t handle ) {
-		handle->sem.wait();
-	}
-
-	void thrdlib_unpark( thread_t handle ) {
-		handle->sem.post();
-	}
-
-	void thrdlib_yield( void ) {
-		int r = pthread_yield();
-		if( r != 0 ) std::abort();
-	}
-
-	//--------------------
-	// Basic kernel features
-	void thrdlib_init( int ) {}
-	void thrdlib_clean( void ) {}
-
-
-#if defined(__cforall) || defined(__cpluplus)
-}
-#endif
