Generally speaking, softirqs are re-entrant functions and must explicitly protect their data structures with spin locks. Tasklets differ from softirqs because a tasklet is always serialized with respect to itself; in other words, a tasklet cannot be executed by two CPUs at the same time.
This means that the same code can be used inside an hard irq handler (where interrupts are already off) and in softirqs (where the irq disabling is required). Note that softirqs (and hence tasklets and timers) are run on return from hardware interrupts, so spin_lock_irq() also stops these.
Workqueue functions run in the context of a kernel process, but tasklet functions run in the software interrupt context. This means that workqueue functions must not be atomic as tasklet functions. Tasklets always run on the processor from which they were originally submitted.
Tasklets are a deferral scheme that you can schedule for a registered function to run later. The top half (the interrupt handler) performs a small amount of work, and then schedules the tasklet to execute later at the bottom half.
I know that there are process context and interrupt context but I don't understand when executing softirq or tasklet, which context is it run under.
I have seen some people use the term "bottom-halves context", if there's such term, what's the difference comparing with the others.
Another question to softirq and tasklet is that why sleep are not allowed during execution??
Can anyone help me identify these questions, thanks!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With