lkml.org 
[lkml]   [1999]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Scheduling inside bottom-half
On Thu, 30 Sep 1999, Linux Lists wrote:

>
> Hello,
>
> I'm trying to solve a driver problem where an interrupt happens, but the
> kernel doesn't have space in its buffers to copy data from the device. As
> this interrupt was serviced, it will never occur again, and the data will
> remain in the device forever.
>
> The solution I found is to detect the condition and then signal an event
> to the bottom-half. Once this event occurs, the bottom-half will then
> "sleep" (using current->timeout / schedule) for one jiffy and then
> generate the interrupt again.
>
> It's something like this:
>
> intr_handler()
> {
> (...)
> if (no_space_in_kbuf) {
> sched_event(KBUF_FULL);
> }
> (...)
> }
>
> do_softint() /* bottom-half */
> {
> (...)
> if (event == KBUF_FULL) {
> current->state = TASK_INTERRUPTIBLE;
> current->timeout = jiffies + 1;
> schedule();
> generate_intr();
> }
> (...)
> }
>
> The code works (i.e., it does what it's supposed to do), BUT:
>
> Aiee: scheduling in interrupt 108440cc
> idle task may not sleep
> Aiee: scheduling in interrupt 108440cc
> idle task may not sleep
> Aiee: scheduling in interrupt 108440cc
> idle task may not sleep

Sure. Do not attempt to schedule in an interrupt. Further, you need
to do dynamic memory allocation in your ISR `kmalloc(size, GFP_ATOMIC)`.
That way, since there is most always some time between interrupts, the
kernel gets a chance to make new pages available for the next interrupt
use. Remember to free memory after your current task has read its
contents.

In the unlikely event that you run out of dynamic pages, just dump
the device data on the floor so your device can interrupt again later.
All word ports can be read as:

while(word_count--)
i = impw(data_port);

... to throw away data.

The same idea works for ports of other widths.

Cheers,
Dick Johnson
**** FILE SYSTEM WAS MODIFIED ****
Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.


-
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:54    [W:0.047 / U:11.460 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site