Re: [Kernel-janitors] Re: Add msleep_interruptible() function to kernel/timer.c

From: Nishanth Aravamudan
Date: Mon Aug 16 2004 - 15:02:21 EST


On Sun, Aug 15, 2004 at 03:25:48PM +0200, maximilian attems wrote:
> On Sun, 15 Aug 2004, Alan Cox wrote:
>
> > On Sul, 2004-08-15 at 13:18, maximilian attems wrote:
> > > + * msleep_interruptible - sleep waiting for waitqueue interruptions
> > > + * @msecs: Time in milliseconds to sleep for
> > > + */
> > > +void msleep_interruptible(unsigned int msecs)
> > > +{
> > > + unsigned long timeout = msecs_to_jiffies(msecs);
> > > +
> > > + while (timeout) {
> >
> > You want to have while(timeout && !signal_pending(current))
> >
> > A signal will wake the timeout which will then loop. It might also
> > be good to add
> >
> > > + set_current_state(TASK_INTERRUPTIBLE);
> > > + timeout = schedule_timeout(timeout);
> > > + }
> >
> > return timeout;
> >
> > so that the caller knows more about how long the timer ran for before
> > the interrupt and if it was interrupted.
>
> belows patches returns timeout in msecs
> as the function is also called with that unit,
> added definition in include/linux/delay.h

<snip>

An entry could be added to the TODO to do what I had done but with
long delays in TASK_INTERRUPTIBLE (which there probably should not be
many of). It would also probably be useful to verify that any drivers
sleeping for times measurable in msecs while INTERRUPTIBLE actually intend
to do so (as I tried to do in some cases).

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