﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	field_blocks	field_dependson	field_seealso
154	Futexes are broken	Jakub Jermář	Jakub Jermář	"Tomas Brambora wrote:
>Consider the following scenario:
>Threads A, B. missed_wakeups == 0 && futex_counter == -1; A in crit.
>sec., B sleeping on the futex with timeout.
>1) A leaves crit. section => calls futex_wakeup and changes futex_counter to 0;
>2) B times out and is removed from the waitq, but gets preempted
>before returning to userspace.
>3) A find empty waitq and increments the missed_wakeup count.
>4) A returns to userspace and before getting preempted calls futex_down.
>5) futex_counter == 0 => A decrements it to -1 and calls futex_sleep.
>Return ESYNCH_OK_ATOMIC because missed_wakeups ==1 => calls
>futex_sleep again and gets blocked there. Now futex_counter == -1 and
>missed_wakeups == 0.
>6) B is scheduled, returns to userspace with ESYNCH_TIMEOUT and
>increments futex_counter.
>
>So we have futex_counter == 0 and missed_wakeups == 0. While there is
>NO THREAD in the critical section (A is sleeping on the futex, B has
>timed out while sleeping).
>
>Ergo, it is broken."	defect	closed	major	0.4.2	helenos/lib/c	mainline	fixed	futex	jakub@…			
