bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] kern: simple futex for gnumach


From: Samuel Thibault
Subject: Re: [RFC] kern: simple futex for gnumach
Date: Sun, 22 Sep 2013 01:01:31 +0200
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Marin Ramesa, le Sat 21 Sep 2013 08:56:42 +0200, a écrit :
> +             case FUTEX_WAIT:
> +                     return futex_wait(address);
> +                     break;


> +     /* Save the value at the address. */
> +     int temp = *address;
> +
> +     simple_lock(&futex_wait_lock);
> +
> +     /* If the value after the lock is still the same. */
> +     if (temp == *address) {

You have missed an important thing here: it's userland which provides
the value we are supposed to check for. The idea is that there is a
window between when userland sees the futex as seeming locked, and here.
In the meanwhile some other thread might have unlocked the futex. And we
don't want to hardcode in the kernel what a "locked futex" means. That's
why it's userland which provides the value the kernel should check for.

You can read "futexes are tricky" from Ulrich Drepper, for more details.

> +             /* Check if there is an existing futex at the address given. */

Better use a hash table :)

Samuel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]