Re: [PATCH] Use msleep_interruptible for therm_adt7467.c kernel thread

From: Herbert Xu
Date: Tue Sep 28 2004 - 21:00:13 EST


On Mon, Sep 27, 2004 at 01:51:42PM +0100, Alan Cox wrote:
> On Llu, 2004-09-27 at 11:25, Herbert Xu wrote:
> > The continue is just paranoia in case something relies on the sleep
> > to take 2 seconds or more.
>
> If the signal occurs then you'll spin for 2 seconds because the signal
> is still waiting to be serviced. This therefore looks broken

Yes you're right. However I'd say that msleep_interruptible should
mirror the behaviour of schedule_timeout and at least sleep once.

BTW, msleep_interruptible() is white-space damaged. Can someone please
fix it up?

> A more interesting question is why this isn't being driven off a
> timer ?

It probably could if the stuff afterwards doesn't sleep.

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
===== kernel/timer.c 1.93 vs edited =====
--- 1.93/kernel/timer.c 2004-09-17 17:07:06 +10:00
+++ edited/kernel/timer.c 2004-09-29 11:48:06 +10:00
@@ -1626,10 +1626,10 @@
{
unsigned long timeout = msecs_to_jiffies(msecs);

- while (timeout && !signal_pending(current)) {
+ do {
set_current_state(TASK_INTERRUPTIBLE);
timeout = schedule_timeout(timeout);
- }
+ } while (timeout && !signal_pending(current));
return jiffies_to_msecs(timeout);
}