Index: libcfa/src/concurrency/locks.cfa
===================================================================
--- libcfa/src/concurrency/locks.cfa	(revision 2ed32fa79f48cc64f2de86bc0262f9ee73af2f0c)
+++ libcfa/src/concurrency/locks.cfa	(revision 4e83bb73307a616bea9e819e1d7680a4fff893e1)
@@ -237,5 +237,4 @@
 		// This pthread_cond_var member is called from the kernel, and therefore, cannot block, but it can spin.
 		lock( cond->lock __cfaabi_dbg_ctx2 );
-
 		// this check is necessary to avoid a race condition since this timeout handler
 		// 	may still be called after a thread has been removed from the queue but
@@ -347,6 +346,8 @@
 		size_t recursion_count = queue_and_get_recursion(this, &info);
 		alarm_node_wrap(L) node_wrap = { t, 0`s, callback, &this, &info };
+		unlock( lock );
+
+		// registers alarm outside cond lock to avoid deadlock
 		register_self( &node_wrap.alarm_node );
-		unlock( lock );
 
 		// blocks here
@@ -437,4 +438,5 @@
 		if ( ret ) {
 			info_thread(L) & popped = try_pop_front( blocked_threads );
+			popped.signalled = true;
 			on_notify(*popped.lock, popped.t);
 		}
@@ -448,4 +450,5 @@
 		while( ! blocked_threads`isEmpty ) {
 			info_thread(L) & popped = try_pop_front( blocked_threads );
+			popped.signalled = true;
 			on_notify(*popped.lock, popped.t);
 		}
@@ -469,6 +472,8 @@
 		size_t recursion_count = queue_and_get_recursion(this, &info);
 		pthread_alarm_node_wrap(L) node_wrap = { t, 0`s, callback, &this, &info };
+		unlock( lock );
+
+		// registers alarm outside cond lock to avoid deadlock
 		register_self( &node_wrap.alarm_node );
-		unlock( lock );
 
 		// blocks here
@@ -500,12 +505,20 @@
 		return i.signalled;
 
+	Duration getDuration(timespec t) {
+		timespec currTime;
+		clock_gettime(CLOCK_REALTIME, &currTime);
+		Duration waitUntil = { t };
+		Duration currDur = { currTime };
+		if ( currDur >= waitUntil ) return currDur - waitUntil;
+		Duration zero = { 0 };
+		return zero;
+	}
+
 	bool wait( pthread_cond_var(L) & this, L & l, timespec t ) {
-		Duration d = { t };
-		WAIT_TIME( 0, &l , d )
+		PTHREAD_WAIT_TIME( 0, &l , getDuration( t ) )
 	}
 	
 	bool wait( pthread_cond_var(L) & this, L & l, uintptr_t info, timespec t  ) {
-		Duration d = { t };
-		WAIT_TIME( info, &l , d )
+		PTHREAD_WAIT_TIME( info, &l , getDuration( t ) )
 	}
 }
