[lkml]   [2001]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: IRQ and sleep_on
christophe barbe wrote:
> I've missed the thread "avoiding bad sleeps" last week. I've had a similar problem
> and I would like to discuss the solution I've used to avoid it.
> I want to wake up a sleeping process from an IRQ handler. In the process, if I use
> a interruptible_sleep_on(), I need first to restore flags (otherwise the process
> will sleep forever).
> restore_flags(flags);
> // <<== here IRQ handler possibly call wake_up()
> interruptible_sleep_on(&my_queue);
> [...]
> I've written a modified version of interruptible_sleep_on which takes an
> additionnal argument : flags to be restored.

That's possible, but it will crash on Sparc: you cannot restore the
interrupt flag saved in one function in another function.

The solution is very simple: do not call restore_flags() before
interruptible_sleep_on(), the schedule internally reenables interrupts.

for(;;) {
if(condition) {
sti(); /* required! */

But if you are writing new code, then DO NOT USE sleep_on(), use
add_wait_queue(), and a spinlock instead of cli().
Look at wait_event_irq in <linux/raid/md_k.h> from the 2.4 kernel as an

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:17    [W:0.063 / U:0.332 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site