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 (version 6)


From: Marin Ramesa
Subject: Re: [RFC] kern: simple futex for gnumach (version 6)
Date: Sat, 28 Dec 2013 02:30:01 +0100

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.


reply via email to

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