lkml.org 
[lkml]   [1999]   [Dec]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: sleep_on, wake_up question
"Richard B. Johnson" wrote:
>
> Mark,
> I checked a later kernel and it can get stuck. However, you can
> use sleep_on_timeout() to make sure you do get awakened.

Ha? Do you really suggest adding a timeout to recover from the lock-up?
You should _remove_ the lock-up instead of hiding it.

Just copy the code from interruptible_sleep_on(), and add
spin_unlock_irq()/spin_lock_irq() around the schedule() call.

You must unlock _after_ you have set "current->state =
TASK_INTERRUPTIBLE", then the lock-up is gone.
[or you could set current->state before you can cause the interrupt, but
this is extremely dangerous on SMP - the cpu's could reorder the memory
accesses.]


spin_lock_irq(&device_lock);
play_with_the_hardware();

while(!command_finished) {
current->state = TASK_INTERRUPTIBLE;
spin_unlock_irq(&device_lock);
schedule();
spin_lock_irq(&device_lock);
if(signal_pending(current)) {
cancel_command();
goto out_unlock;
}
}
store_the_result_from_the_hardware();
out_unlock:
spin_unlock_irq(&device_lock);

isr()
{
spin_lock_irqsave(&device_lock,flags);
command_finished = 1;
wake_up_interruptible(&wait);
spin_unlock_irqrestore(&device_lock,flags);
}

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

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