> I agree. But your "Applied" EMail rushed me into posting it.
The normal way to use multithreading under UNIX is the pthread
library. Here the condition variables are the equivalent to kernel
wait queues. So I think to really implement a fast pthread lib based
on futexes one needs some means to implement condition variables
(with synchronous futex release to implement pthread_cond_wait(..)!).
This could either be done with the exported waitqueue approach or a bit
easier (but less general) by associating a second hashed waitqueue with
each futex (maybe marked by the odd offset+1?). Then we would have two
additional variants of sys_futex (with parameters FUTEX_WAIT,
FUTEX_SIGNAL).
The principle implementation is:
FUTEX_WAIT:
add_to_cond_queue
current->state=INTERRUPTIBLE
futex_up
schedule
remove_from_cond_queue
futex_down
FUTEX_SIGNAL
wake_up_all on cond_queue
Later we may also want FUTEX_SIGNAL_ONE and FUTEX_WAIT_TIMEOUT.
The user space code for pthread_cond_wait then of course needs a
chaining of the protecting pthread_mutex and the futex used as condition
variable.
Martin
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/