This problem is usually handled by keeping a count of the the number of
interrupts that have arrived. If multiple interrupts arrive before the tasklet
is scheduled then; when the tasklet is scheduled the tasklet looks at the interrupt
count and reschedules itself until all the pending interrupts are processed.
A simple algorithm for this is as follows,
int int_count = 0;
void int_handler(int irq, void *device, struct pt_regs *regs) { ... int_count++; tasklet_schedule(&my_tasklet); ... }
void my_tasklet_function (unsigned long temp) { unsigned long save; /* Process the interrupt */
local_irq_save(flags);
int_count--; if (int_count > 0) tasklet_schedule(&my_tasklet);
local_irq_restore(flags); }
Of course, this will work only if there is an upper bound on the number of interrupts that will be generated by the device, before the interrupts are processed!, or this will become a virtual free run, with the interrupt count increasing uncontrollably.
regards, john
On Tue, 11 Nov 2003 15:52:39 -0800, Eric Lin <qlyz@sbcglobal.net> wrote:
As we know that tasklet is used to be scheduled in interrupt handler to perform bottom half. To schedule a tasklet, its TASKLET_STATE_SCHED bit is checked to see if the same tasklet already been scheduled and has not yet been "consumed". This guarantees that the same tasklet will be scheduled only once. This is intended for preventing tasklet-list from being corrupted. What we can expect in the real world is "missing" tasklet: the tasklets scheduled are often less than the interrupts occured. That means something get missed.
For network driver, raising interrupt often indicates readiness of data. but missing tasklet does not necessary mean missing data, because buffer can always be used in interrupt handler to store the data.
For those where interrupt represents an externel event, we are not lucky because we do miss the one immediatly followed.
This may be common, but beside buffer, I could not think of other solution. Can someone contribute ?
Eric
-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/
-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/