tasklet, taskqueue, work-queue -- which to use?

user2090434 picture user2090434 · Feb 20, 2013 · Viewed 12.6k times · Source

I am going through ldd3 for last few months. I read first few chapters many times.

These two links are using diffrent way, one is using work queue other is using task-queue. To implement a bottom half.
http://www.tldp.org/LDP/lkmpg/2.4/html/x1210.html http://www.linuxtopia.org/online_books/linux_kernel/linux_kernel_module_programming_2.6/x1256.html

I have some doubt about tasklet, taskqueue, work-queue all seems to be doing some task at free time :--

a) What exactly the diffrence between these three ?

b) Which should be used for interrupt handler bottom half ?

confused ...???

Answer

duck picture duck · Mar 5, 2013

Tasklet and work-queue are normally used in bottom half but they can be used anywhere, their is no limitation on them

Regarding the difference.

1) The Tasklet are used in interrupt context. All the tasklet code must be atomic,so all rules that are applied on atomic context are applied to it. For eg. They cannot sleep(as they cannot be reschecduled) or hold a lock for long time.

2) Unlike Tasklet work-queue executes is in process context means they can sleep and hold the lock for longtime.

In short tasklet are used for fast execution as they cannot sleep where as workqueue are used in case of normal execution of bottom half. Both are executed at later time by the kernel.