What are bottom halves?
Interrupt handling is divided into two parts viz. Top Half and Bottom Half. In top half we do do only those works that require immediate attention.In bottom half we do rest of the work. Some bottom halves do run in interrupt context but all interrupts lines are enabled while executing the bottom halves.
Why do we need it?
- B'coz we want our Interrupt handler to do only the time critical stuffs and return back to the process context .
- B'coz we don't want to keep the interrupt lines busy.
What are the bottom halves being used in the present linux kernels?
1.SoftIrqs
2. Tasklets
3. WorkQueues
Tasklets Vs SoftIrqs1.SoftIrqs
2. Tasklets
3. WorkQueues
Tasklets and SoftIrqs are two ways to implement bottom halves ( and definitely not the only two ways).Tasklets are dynamically created and are simpler to use. So while deciding upon which one to use , go for tasklets unless the work is time critical. Networking and Block devices, whose work is time critical use SoftIrqs.
SoftIrqs Vs Tasklets Vs WorkQueues
- Deferred work runs in Interrupt context in case of SoftIrqs and Tasklets while it runs in process context in case of workqueues.
- SoftIrqs(same or different) can run run simulatenously on different processor cores ; same Tasklets can't run simultaneously on different CPU cores but different Tasklets definitely can; workqueues can run of different CPU cores simultaneously.
- As SoftIrqs and Tasklets run in interrupt context they can't sleep while workqueues can sleep as they run in the process context.
- Both SoftIrqs and Tasklets can't be preempted or scheduled while Workqueues can be.
- SoftIrqs are not easy to use while Tasklets and WorkQueues are easy to use.
- If the code in question is highly threaded( too many subroutines) for ex. Networking applications then SoftIrq is the best bet as they are the fastest.
- If the code is not highly threaded then the device driver developer must go for Tasklets as they have the simplest interface.
- If the deferred work has to run in the process context then WorkQueues is the only option.
- So, in general if your bottom halve can sleep then use WorkQueues else use Tasklets.
- When it comes to ease of use WorkQueues are the best then comes tasklets and in the end comes softirqs as they have to be statically created and require proper thinking before implementing.
I got this web page from my buddy who shared with me concerning this web site and at the moment this time I am
ReplyDeletevisitiong this web page and reading very informative articles at this time.
My homepage; marathon bracelet
when to choose which bottom halves?
ReplyDeleteIf the code in question is highly threaded( too many subroutines) for ex. Networking applications then SoftIrq is the best bet as they are the fastest.
ReplyDeleteIf the code is not highly threaded then the device driver developer must go for Tasklets as they have the simplest interface.
If the deferred work has to run in the process context then WorkQueues is the only option.
So, in general if your bottom halve can sleep then use WorkQueues else use Tasklets.
When it comes to ease of use WorkQueues are the best then comes tasklets and in the end comes softirqs as they have to be statically created and require proper thinking before implementing.