Re: schedule_timeout() semantics/usage?

David Hinds (dhinds@varesearch.com)
Wed, 20 Oct 1999 17:17:43 -0700


On Thu, Oct 21, 1999 at 01:13:00AM +0200, Andrea Arcangeli wrote:
>
> NOTENOTE: when you return from schedule_timeout you _always_ are in
> TASK_RUNNING state.

Ok...

> So the right way to unconditionally wait for 5 sec _if_ you are not
> registered in any waitqueue and so if you can't be wakenup from a kernel
> event (that is not a signal) is:
>
> __set_current_state(TASK_UNINTERRUPTIBLE);
> schedule_timeout(5*HZ);

Ok, that makes sense...

> >- Something like 95% of callers of schedule_timeout() ignore the
> > return value. Many seem to expect it to not return early: it is
> > used for timed delays in many drivers. Are these all bugs?
>
> They are not buggy if they are using TASK_UNINTERRUPTIBLE and they can't
> be wakenup by _hand_ from a wake_up_process() somewhere.
>
> They are not buggy if they are using TASK_INTERRUPTIBLE and they are
> expecting to return early in case of a signal and they can't be wakenup by
> some lowlevel kernel code.

Look at net/irda/*.c or isdn/hisax/*.c, for example.

-- Dave

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/