Index: doc/theses/thierry_delisle_PhD/code/relaxed_list.hpp
===================================================================
--- doc/theses/thierry_delisle_PhD/code/relaxed_list.hpp	(revision 95cb63bcaff9c78188bff94b95ea03df8fccfd9c)
+++ doc/theses/thierry_delisle_PhD/code/relaxed_list.hpp	(revision 8f4f3e011b82e24cb29298d4c287f628022b4126)
@@ -5,4 +5,5 @@
 #endif
 
+#include <cmath>
 #include <memory>
 #include <mutex>
@@ -56,6 +57,6 @@
 	  	: lists(new intrusive_queue_t[numLists])
 		, numLists(numLists)
-		#if defined(SIMPLE_SNZI)
-			, snzi(4)
+		#if defined(SIMPLE_SNZI) || defined(DISCOVER_BITMASK)
+			, snzi( std::log2( numLists / 8 ) )
 		#endif
 	{
@@ -89,5 +90,5 @@
 			if( !lists[i].lock.try_lock() ) continue;
 
-			#if !defined(SIMPLE_SNZI)
+			#if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
 				__attribute__((unused)) int num = numNonEmpty;
 			#endif
@@ -100,4 +101,5 @@
 					assert(qword == 0);
 					bts(tls.mask, bit);
+					snzi.arrive(i);
 				#elif defined(SIMPLE_SNZI)
 					snzi.arrive(i);
@@ -114,5 +116,5 @@
 				#endif
 			}
-			#if !defined(SIMPLE_SNZI)
+			#if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
 				assert(numNonEmpty <= (int)numLists);
 			#endif
@@ -123,5 +125,5 @@
 			#ifndef NO_STATS
 				tls.pick.push.success++;
-				#if !defined(SIMPLE_SNZI)
+				#if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
 					tls.empty.push.value += num;
 					tls.empty.push.count += 1;
@@ -135,11 +137,8 @@
 		#if defined(DISCOVER_BITMASK)
 			assert(numLists <= 64);
-			while(true) {
+			while(snzi.query()) {
 				tls.pick.pop.mask_attempt++;
 				unsigned i, j;
 				{
-					// Pick two lists at random
-					unsigned num = ((numLists - 1) >> 6) + 1;
-
 					// Pick first list totally randomly
 					i = tls.rng.next() % numLists;
@@ -245,5 +244,5 @@
 		if( !list.lock.try_lock() ) return nullptr;
 
-		#if !defined(SIMPLE_SNZI)
+		#if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
 			__attribute__((unused)) int num = numNonEmpty;
 		#endif
@@ -267,4 +266,5 @@
 				assert(qword == 0);
 				__attribute__((unused)) bool ret = btr(tls.mask, bit);
+				snzi.depart(w);
 			#elif defined(SIMPLE_SNZI)
 				snzi.depart(w);
@@ -284,10 +284,10 @@
 		// Unlock and return
 		list.lock.unlock();
-		#if !defined(SIMPLE_SNZI)
+		#if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
 			assert(numNonEmpty >= 0);
 		#endif
 		#ifndef NO_STATS
 			tls.pick.pop.success++;
-			#if !defined(SIMPLE_SNZI)
+			#if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
 				tls.empty.pop.value += num;
 				tls.empty.pop.count += 1;
@@ -435,5 +435,5 @@
 	const unsigned numLists;
 private:
-	#if defined(SIMPLE_SNZI)
+	#if defined(SIMPLE_SNZI) || defined(DISCOVER_BITMASK)
 		snzi_t snzi;
 	#else
