Index: benchmark/Makefile.am
===================================================================
--- benchmark/Makefile.am	(revision 49ce636652362da1d31dc2b47d57ed426e0d1a5a)
+++ benchmark/Makefile.am	(revision 751e2eb2bf51e83011e451db92ec43f64afe1afc)
@@ -525,5 +525,5 @@
 ## =========================================================================================================
 
-%-tokio$(EXEEXT): $(srcdir)/readyQ/%.rs
+%-tokio$(EXEEXT): $(srcdir)/readyQ/%.rs $(srcdir)/bench.rs
 	cd $(builddir) && cargo build --release
 	cp $(builddir)/target/release/$(basename $@) $@
Index: benchmark/bench.rs
===================================================================
--- benchmark/bench.rs	(revision 751e2eb2bf51e83011e451db92ec43f64afe1afc)
+++ benchmark/bench.rs	(revision 751e2eb2bf51e83011e451db92ec43f64afe1afc)
@@ -0,0 +1,70 @@
+use std::io::{self, Write};
+use std::sync::atomic::{AtomicU64, AtomicBool, Ordering};
+use std::time::{Instant,Duration};
+
+use clap::{Arg, ArgMatches};
+use isatty::stdout_isatty;
+
+use tokio::time;
+
+
+// ==================================================
+pub fn args<'a, 'b>() -> [Arg<'a, 'b>; 4] {[
+	Arg::with_name("duration")  .short("d").long("duration")  .takes_value(true).default_value("5").help("Duration of the experiments in seconds"),
+	Arg::with_name("iterations").short("i").long("iterations").takes_value(true).conflicts_with("duration").help("Number of iterations of the experiments"),
+	Arg::with_name("nthreads")  .short("t").long("nthreads")  .takes_value(true).default_value("1").help("Number of threads to use"),
+	Arg::with_name("nprocs")    .short("p").long("nprocs")    .takes_value(true).default_value("1").help("Number of processors to use")
+]}
+
+pub struct BenchData {
+	pub clock_mode: bool,
+	pub stop: AtomicBool,
+	pub stop_count: u64,
+	pub duration: f64,
+	pub threads_left: AtomicU64,
+	is_tty: bool,
+}
+
+impl BenchData {
+	pub fn new(options: ArgMatches, nthreads: usize) -> BenchData {
+		let (clock_mode, stop_count, duration) = if options.is_present("iterations") {
+			(false,
+			options.value_of("iterations").unwrap().parse::<u64>().unwrap(),
+			-1.0)
+		} else {
+			(true,
+			std::u64::MAX,
+			options.value_of("duration").unwrap().parse::<f64>().unwrap())
+		};
+
+		BenchData{
+			clock_mode: clock_mode,
+			stop: AtomicBool::new(false),
+			stop_count: stop_count,
+			duration: duration,
+			threads_left: AtomicU64::new(nthreads as u64),
+			is_tty: stdout_isatty(),
+		}
+	}
+
+	pub async fn wait(&self, start: &Instant) -> Duration{
+		loop {
+			time::sleep(Duration::from_micros(100000)).await;
+			let delta = start.elapsed();
+			if self.is_tty {
+				print!(" {:.1}\r", delta.as_secs_f32());
+				io::stdout().flush().unwrap();
+			}
+			if self.clock_mode && delta >= Duration::from_secs_f64(self.duration)  {
+				break;
+			}
+			else if !self.clock_mode && self.threads_left.load(Ordering::Relaxed) == 0 {
+				break;
+			}
+		}
+
+		self.stop.store(true, Ordering::SeqCst);
+		return start.elapsed();
+	}
+}
+
Index: benchmark/readyQ/cycle.rs
===================================================================
--- benchmark/readyQ/cycle.rs	(revision 49ce636652362da1d31dc2b47d57ed426e0d1a5a)
+++ benchmark/readyQ/cycle.rs	(revision 751e2eb2bf51e83011e451db92ec43f64afe1afc)
@@ -1,64 +1,16 @@
-#[cfg(any(
-	feature = "sync time rt-threaded",
-  ))]
-
-extern crate tokio;
-
-use std::io::{self, Write};
 use std::sync::Arc;
-use std::sync::atomic::{AtomicU64, AtomicBool,Ordering};
-use std::time::{Instant,Duration};
+use std::sync::atomic::Ordering;
+use std::time::Instant;
 
 use tokio::runtime::Builder;
 use tokio::sync;
-use tokio::time;
 
-use isatty::stdout_isatty;
-
+use clap::{Arg, App};
 use num_format::{Locale, ToFormattedString};
 
-use clap::{Arg, App};
+#[path = "../bench.rs"]
+mod bench;
 
-use std::cell::UnsafeCell;
-use std::mem::MaybeUninit;
-use std::ops;
-
-pub struct InitializeCell<T> {
-    inner: UnsafeCell<MaybeUninit<T>>,
-}
-
-unsafe impl<T> Sync for InitializeCell<T> {}
-
-impl<T> InitializeCell<T> {
-    pub const unsafe fn new_uninitialized() -> InitializeCell<T> {
-	  InitializeCell {
-		inner: UnsafeCell::new(MaybeUninit::uninit()),
-	  }
-    }
-    pub const fn new(init: T) -> InitializeCell<T> {
-	  InitializeCell {
-		inner: UnsafeCell::new(MaybeUninit::new(init)),
-	  }
-    }
-    pub unsafe fn init(&self, init: T) {
-	  (*self.inner.get()) = MaybeUninit::new(init);
-    }
-}
-
-impl<T> ops::Deref for InitializeCell<T> {
-    type Target = T;
-    fn deref(&self) -> &T {
-	  unsafe {
-		&*(*self.inner.get()).as_ptr()
-	  }
-    }
-}
-
-static CLOCK_MODE: InitializeCell<bool> = unsafe { InitializeCell::new_uninitialized() };
-static STOP_COUNT: InitializeCell<u64>  = unsafe { InitializeCell::new_uninitialized() };
-static DURATION: InitializeCell<f64>    = unsafe { InitializeCell::new_uninitialized() };
-static STOP         : AtomicBool = AtomicBool::new(false);
-static THREADS_LEFT : AtomicU64  = AtomicU64 ::new(10);
-
+// ==================================================
 struct Partner {
 	sem: sync::Semaphore,
@@ -66,5 +18,5 @@
 }
 
-async fn partner_main(result: sync::oneshot::Sender<u64>, idx: usize, others: Arc<Vec<Arc<Partner>>> ) {
+async fn partner_main(idx: usize, others: Arc<Vec<Arc<Partner>>>, exp: Arc<bench::BenchData> ) -> u64 {
 	let this = &others[idx];
 	let mut count:u64 = 0;
@@ -74,47 +26,16 @@
 		count += 1;
 
-		if  *CLOCK_MODE && STOP.load(Ordering::Relaxed) { break; }
-		if !*CLOCK_MODE && count >= *STOP_COUNT { break; }
+		if  exp.clock_mode && exp.stop.load(Ordering::Relaxed) { break; }
+		if !exp.clock_mode && count >= exp.stop_count { break; }
 	}
 
-	THREADS_LEFT.fetch_sub(1, Ordering::SeqCst);
-	result.send( count ).unwrap();
+	exp.threads_left.fetch_sub(1, Ordering::SeqCst);
+	count
 }
 
-fn prep(nthreads: usize, tthreads: usize) -> Vec<Arc<Partner>> {
-	let mut thddata = Vec::with_capacity(tthreads);
-	for i in 0..tthreads {
-		let pi = (i + nthreads) % tthreads;
-		thddata.push(Arc::new(Partner{
-			sem: sync::Semaphore::new(0),
-			next: pi,
-		}));
-	}
-	return thddata;
-}
-
-async fn wait(start: &Instant, is_tty: bool) {
-	loop {
-		time::sleep(Duration::from_micros(100000)).await;
-		let delta = start.elapsed();
-		if is_tty {
-			print!(" {:.1}\r", delta.as_secs_f32());
-			io::stdout().flush().unwrap();
-		}
-		if *CLOCK_MODE && delta >= Duration::from_secs_f64(*DURATION)  {
-			break;
-		}
-		else if !*CLOCK_MODE && THREADS_LEFT.load(Ordering::Relaxed) == 0 {
-			break;
-		}
-	}
-}
-
+// ==================================================
 fn main() {
 	let options = App::new("Cycle Tokio")
-		.arg(Arg::with_name("duration")  .short("d").long("duration")  .takes_value(true).default_value("5").help("Duration of the experiments in seconds"))
-		.arg(Arg::with_name("iterations").short("i").long("iterations").takes_value(true).conflicts_with("duration").help("Number of iterations of the experiments"))
-		.arg(Arg::with_name("nthreads")  .short("t").long("nthreads")  .takes_value(true).default_value("1").help("Number of threads to use"))
-		.arg(Arg::with_name("nprocs")    .short("p").long("nprocs")    .takes_value(true).default_value("1").help("Number of processors to use"))
+		.args(&bench::args())
 		.arg(Arg::with_name("ringsize")  .short("r").long("ringsize")  .takes_value(true).default_value("1").help("Number of threads in a cycle"))
 		.get_matches();
@@ -124,24 +45,19 @@
 	let nprocs    = options.value_of("nprocs").unwrap().parse::<usize>().unwrap();
 
-	if options.is_present("iterations") {
-		unsafe{
-			CLOCK_MODE.init( false );
-			STOP_COUNT.init( options.value_of("iterations").unwrap().parse::<u64>().unwrap() );
-		}
-	}
-	else {
-		unsafe{
-			CLOCK_MODE.init(true);
-			DURATION  .init(options.value_of("duration").unwrap().parse::<f64>().unwrap());
-		}
-	}
+	let tthreads = nthreads * ring_size;
+	let exp = Arc::new(bench::BenchData::new(options, tthreads));
 
 	let s = (1000000 as u64).to_formatted_string(&Locale::en);
 	assert_eq!(&s, "1,000,000");
 
-
-	let tthreads = nthreads * ring_size;
-	THREADS_LEFT.store(tthreads as u64, Ordering::SeqCst);
-	let thddata = Arc::new(prep(nthreads, tthreads));
+	let thddata : Arc<Vec<Arc<Partner>>> = Arc::new(
+		(0..tthreads).map(|i| {
+			let pi = (i + nthreads) % tthreads;
+			Arc::new(Partner{
+				sem: sync::Semaphore::new(0),
+				next: pi,
+			})
+		}).collect()
+	);
 
 	let mut global_counter :u64 = 0;
@@ -154,35 +70,25 @@
 
 	runtime.block_on(async {
-		let mut result  : Vec<sync::oneshot::Receiver::<u64>> = Vec::with_capacity(tthreads);
-		{
-			let mut threads = Vec::with_capacity(tthreads);
-			for i in 0..tthreads {
-				let (s, r) = sync::oneshot::channel::<u64>();
-				result.push(r);
-				threads.push(tokio::spawn(partner_main(s, i, thddata.clone())));
-			}
-			println!("Starting");
+		let threads: Vec<_> = (0..tthreads).map(|i| {
+			tokio::spawn(partner_main(i, thddata.clone(), exp.clone()))
+		}).collect();
+		println!("Starting");
 
-			let is_tty = stdout_isatty();
-			let start = Instant::now();
+		let start = Instant::now();
 
-			for i in 0..nthreads {
-				thddata[i].sem.add_permits(1);
-			}
+		for i in 0..nthreads {
+			thddata[i].sem.add_permits(1);
+		}
 
-			wait(&start, is_tty).await;
+		duration = exp.wait(&start).await;
 
-			STOP.store(true, Ordering::SeqCst);
-			duration = start.elapsed();
+		println!("\nDone");
 
-			println!("\nDone");
+		for i in 0..tthreads {
+			thddata[i].sem.add_permits(1);
+		}
 
-			for i in 0..tthreads {
-				thddata[i].sem.add_permits(1);
-			}
-
-			for _ in 0..tthreads {
-				global_counter += result.pop().unwrap().await.unwrap();
-			}
+		for t in threads {
+			global_counter += t.await.unwrap();
 		}
 	});
Index: benchmark/readyQ/locality.rs
===================================================================
--- benchmark/readyQ/locality.rs	(revision 49ce636652362da1d31dc2b47d57ed426e0d1a5a)
+++ benchmark/readyQ/locality.rs	(revision 751e2eb2bf51e83011e451db92ec43f64afe1afc)
@@ -1,65 +1,17 @@
-use std::io::{self, Write};
 use std::ptr;
 use std::sync::Arc;
-use std::sync::atomic::{AtomicU64, AtomicBool, Ordering};
-use std::time::{Instant,Duration};
+use std::sync::atomic::{AtomicU64, Ordering};
+use std::time::Instant;
 use std::thread::{self, ThreadId};
 
 use tokio::runtime::Builder;
 use tokio::sync;
-use tokio::time;
-
-use clap::{Arg, App, ArgMatches};
-use isatty::stdout_isatty;
+
+use clap::{App, Arg};
 use num_format::{Locale, ToFormattedString};
 use rand::Rng;
 
-// ==================================================
-struct BenchData {
-	clock_mode: bool,
-	stop: AtomicBool,
-	stop_count: u64,
-	duration: f64,
-	threads_left: AtomicU64,
-}
-
-impl BenchData {
-	fn new(options: ArgMatches, nthreads: usize) -> BenchData {
-		let (clock_mode, stop_count, duration) = if options.is_present("iterations") {
-			(false,
-			options.value_of("iterations").unwrap().parse::<u64>().unwrap(),
-			-1.0)
-		} else {
-			(true,
-			std::u64::MAX,
-			options.value_of("duration").unwrap().parse::<f64>().unwrap())
-		};
-
-		BenchData{
-			clock_mode: clock_mode,
-			stop: AtomicBool::new(false),
-			stop_count: stop_count,
-			duration: duration,
-			threads_left: AtomicU64::new(nthreads as u64),
-		}
-	}
-}
-
-async fn wait(bench: &BenchData, start: &Instant, is_tty: bool) {
-	loop {
-		time::sleep(Duration::from_micros(100000)).await;
-		let delta = start.elapsed();
-		if is_tty {
-			print!(" {:.1}\r", delta.as_secs_f32());
-			io::stdout().flush().unwrap();
-		}
-		if bench.clock_mode && delta >= Duration::from_secs_f64(bench.duration)  {
-			break;
-		}
-		else if !bench.clock_mode && bench.threads_left.load(Ordering::Relaxed) == 0 {
-			break;
-		}
-	}
-}
+#[path = "../bench.rs"]
+mod bench;
 
 // ==================================================
@@ -240,5 +192,5 @@
 }
 
-async fn local(start: Arc<sync::Barrier>, idata: MyDataPtr, spots : Arc<Vec<MySpot>>, cnt: u64, share: bool, id: usize, bench: Arc<BenchData>) -> Result{
+async fn local(start: Arc<sync::Barrier>, idata: MyDataPtr, spots : Arc<Vec<MySpot>>, cnt: u64, share: bool, id: usize, exp: Arc<bench::BenchData>) -> Result{
 	let mut state = rand::thread_rng().gen::<u64>();
 	let mut data = idata;
@@ -267,6 +219,6 @@
 		// Check if the experiment is over
 		if closed { break }                                                   // yes, spot was closed
-		if  bench.clock_mode && bench.stop.load(Ordering::Relaxed) { break }  // yes, time's up
-		if !bench.clock_mode && r.count >= bench.stop_count { break }         // yes, iterations reached
+		if  exp.clock_mode && exp.stop.load(Ordering::Relaxed) { break }  // yes, time's up
+		if !exp.clock_mode && r.count >= exp.stop_count { break }         // yes, iterations reached
 
 		assert_ne!(data.ptr as *const MyData, ptr::null());
@@ -284,5 +236,5 @@
 	}
 
-	bench.threads_left.fetch_sub(1, Ordering::SeqCst);
+	exp.threads_left.fetch_sub(1, Ordering::SeqCst);
 	r
 }
@@ -292,8 +244,5 @@
 fn main() {
 	let options = App::new("Locality Tokio")
-		.arg(Arg::with_name("duration")  .short("d").long("duration")  .takes_value(true).default_value("5").help("Duration of the experiments in seconds"))
-		.arg(Arg::with_name("iterations").short("i").long("iterations").takes_value(true).conflicts_with("duration").help("Number of iterations of the experiments"))
-		.arg(Arg::with_name("nthreads")  .short("t").long("nthreads")  .takes_value(true).default_value("1").help("Number of threads to use"))
-		.arg(Arg::with_name("nprocs")    .short("p").long("nprocs")    .takes_value(true).default_value("1").help("Number of processors to use"))
+		.args(&bench::args())
 		.arg(Arg::with_name("size")      .short("w").long("worksize")  .takes_value(true).default_value("2").help("Size of the array for each threads, in words (64bit)"))
 		.arg(Arg::with_name("work")      .short("c").long("workcnt")   .takes_value(true).default_value("2").help("Number of words to touch when working (random pick, cells can be picked more than once)"))
@@ -315,5 +264,5 @@
 	assert_eq!(&s, "1,000,000");
 
-	let bench = Arc::new(BenchData::new(options, nprocs));
+	let exp = Arc::new(bench::BenchData::new(options, nprocs));
 	let mut results = Result::new();
 
@@ -342,5 +291,5 @@
 					share,
 					i,
-					bench.clone(),
+					exp.clone(),
 				))
 			}).collect();
@@ -349,12 +298,8 @@
 			println!("Starting");
 
-			let is_tty = stdout_isatty();
 			let start = Instant::now();
 			barr.wait().await;
 
-			wait(&bench, &start, is_tty).await;
-
-			bench.stop.store(true, Ordering::SeqCst);
-			elapsed = start.elapsed();
+			elapsed = exp.wait(&start).await;
 
 			println!("\nDone");
