Re: sleep_on, wake_up question

Richard B. Johnson (root@chaos.analogic.com)
Thu, 30 Dec 1999 09:41:23 -0500 (EST)


On Thu, 30 Dec 1999, Mark Mokryn wrote:

> I'm working on a module, in which my ioctl function fuction needs to
> block, waiting for the hardware to do its work (in an ISR/bottom half).
> Code looks like:
> my_ioctl()
> {
> ...
> // prepare work for adapter, and interrupt it
> interruptible_sleep_on(&wq);
> ...
> }
>
> adapter_isr()
> {
> // do some work
> wake_up_interruptible(&wq);
> ...
> }
>
> It's possible that the PC will be interrupted (by anything) just prior to
> the sleep_on call in my_ioctl, and eventually, the adapter may even
> complete its work (and call wake_up) before the sleep_on function was even
> reached. In a heavily loaded system, this possibility is more than
> theoretical. In this case, it appears that the calling process may forever
> hang in sleep_on. Help? Am I missing something here?

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.

Cheers,
Dick Johnson

Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : The end of the world as we know it requires a new calendar.
Seconds : 137917 (until Y2K)

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