On 12/27/2013 07:14:40 PM, Richard Braun wrote:
> +void futex_cross_address_space_wake(futex_t futex, boolean_t
wake_all)
> +{
> + #define min(x, y) (x <= y ? x : y)
> +
> + queue_iterate(&futex->chain, futex, futex_t, chain) {
> +
> + simple_lock(&futex->futex_wait_lock);
> +
> + int i;
> +
> + for (i = 0; i < min(futex->num_futexed_threads,
> +
((futex_t)futex->chain.next)->num_futexed_threads); i++) {
If you have a list, you just walk it, there is no need to count the
number of items.
Threads are not in a list and I need to count the number of threads
to use indexes for comparison of offsets.
> +void futex_wake_threads(futex_t futex, boolean_t wake_all)
> +{
> + if (wake_all) {
> + int i;
> + for (i = 0; i < futex->num_futexed_threads; i++)
> + futex_wake_one_thread(futex, i);
> + } else
> + futex_wake_one_thread(futex,
futex->num_futexed_threads-1);
> +}
What's the difference between this and futex_cross_address_space_wake
??
futex_cross_address_space_wake() wakes all threads with the same
offset. It
doesn't matter in which futex they are in. This function is just for one
futex, it doesn't matter which offsets the threads have.