Re: sleep_on, wake_up question

Manfred Spraul (manfreds@colorfullife.com)
Thu, 30 Dec 1999 16:17:18 +0100


From: "Richard B. Johnson" <root@chaos.analogic.com>
>
> There is more at work than your code implies. If the interrupt occurs
> instantly, before your call to interruptible_sleep_on(), the call will
> return immediately. It works. I have many drivers using this technique
> and they have never missed a beat.
>
No. Do not use sleep_on() in new drivers. sleep_on() can miss interrupts
unless you own the global interrupt lock(*). Your driver could fail on SMP.

Please use either wait_event() [only possible if you don't use spinlocks],
or manually implement sleep_on(): [wait_event() + spin_unlock_irq() just
before schedule() + spin_lock_irq() just behind schedule()].

It's implemented in <linux/sched.h> for both 2.2 and 2.3

(*) or lock_kernel(), but this is only possible from outside interrupt
contexts.

--
    Manfred

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