Re: kthread or tasklet in driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 14:30 Mon 15 Sep     , jasjit singh wrote:
> Hi
> 
> I'm implementing interrupt handling routine for my driver. In servicing the interrupt, some important work needs to be done. However that is not more important than avoiding of interrupt disabling. So I would prefer to do the work later(In bottom half). Presently I am thinking of two solutions. First is tasklet based. Every time an interrupt is there, it will schedule the tasklet that will perform the desired work. Other is spawning a kernel thread that will sleep indefinitely. It will be woken up whenever there is an interrupt so that it can perform the desired operation. Both methods seem feasible. But I am still looking for the various pros and cons of the two solutions. Can you suggest which would be better. Or rather what factors do I need to consider to choose between the two.
> 
> Also there is no mention of kernel threads in "LDD 3rd edition". Is it that kernel threads are not used (or not recommended) in the drivers.

I would prefer workqueues over tasklets. See
http://lwn.net/Articles/239633/

pros/cons interrupt handler/workqueues:
- Interrupt routines block everything else while they are running. Long
  routines easily make the system unresponsive. The real-time linux patchset
  contains code which lets all interrupt routines run as some kind of
  workqueue.
- Putting the handler in a workqueue means that its exeuction is delayed. In
  cases requireing immediate response this can be a problem.
- Some functions cannot be called from interrupt context.

Threads are usually only used, if the amount of work is large. Doing this in
workqueues will slow down other parts of the system much more than doing it in
threads.
	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux