On Tue, 17 Aug 1999, Linus Torvalds wrote:

>However, often the mb()'s really aren't needed due to being implicit in
>something else you do, so I don't know..

Notably when you know that after the first wakeup you'll get the condition
true (nobody can get the resource before you). In such case you can do:

        current->state = TASK_INTERRUPTIBLE;
        add_wait_queue(&wqhead, &current_wait);
        if (!got_resource())
                schedule();
        if (!got_resource())
                goto kind_of_panic;
        remove_wait_queue(&wqhead, &current_wait);

Lots of code is doing that (grep drivers/sound/*.c for
TASK_.*INTERRUPTIBLE).

The add_wait_queue placed between the TASK_INTERRUPTIBLE setting and the
resource checking, will serialize the instructions in the above case, so
there's no need of mb() there.

Since the developer must be aware of these issues anyway in order to
choose between _set_state() and set_state() I can't see a big difference
in adding the mb() in the right place by hand.

If you think that I should hide the mb() inside a macro just ask for that
and I'll redo the patch. Linus?

Andrea

-
Linux SMP list: FIRST see FAQ at http://www.irisa.fr/prive/mentre/smp-faq/
To Unsubscribe: send "unsubscribe linux-smp" to [EMAIL PROTECTED]

Reply via email to