Re: Problems with wait queues

Oliver.Neukum@lrz.uni-muenchen.de
Thu, 27 Jun 2002 14:36:24 +0200 (MET DST)


> > Do not ever use sleep_on() and friends. Almost all usage of these
> > functions will be buggy.
> >
>
> Whatever your message means; perhaps it was a way of saying "Hello"
> to an old friend?
>
> Attached is a file showing about 485 usages of 'sleep_on' in the
> kernel drivers. If this usage is, as you say, buggy then will you
> please inform us unwashed hordes what we should use to replace these?

The simplest way is with the wait_event[_interruptible] macros.
In newer versions of the USB drivers, you'll find examples.
You may also set your task's state and put yourself on a waitqueue,
before you do something that will cause you to be woken up.

And yes, most examples you found are buggy, as they can miss
a wakeup.
To use sleep_on safely you must make sure that you cannot be woken up
before you begin to sleep.

Regards
Oliver

-
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/