Interrupt context bottom half (Softirq or tasklets)
Softirqs /tasklets are said to be executed in interrupt context I have below question with respect to interrupt context bottoms half.
Q1) What happen if we try to put sleep in tasklet (interrupt context Bottom half) ( consider that tasklet is scheduled by interrupt handler).
[My understanding] As I know while coming out of interrupt handler when tasklet_schedule is called it will get get tasklet_vec structure pointer and if currently no other interrupt / high priority softirq in progress it will schedule ksoftirqd which will run handler (tasklet handler) and if a tall that tasklet handler uses sleep in that case ksoftirqd will move to wait_queue and unless and until another tasklet_schdule is called my interrupted tasklet hander will be continue on that point onwards.
We say "Interrupt context code must not sleep" ( What are consequence if I use sleep in interrupt handler, considering I have not used spint lock OR I have not disabled timer interrupt )
(Please correct me if my understanding is wrong)
Sleep works only in process context not in interrupt context. In interrupt context, "current" is not a valid task so we can put it in sleep and wake it up later. Use threads if u wanna sleep
If you try to sleep in tasklet, there would be a kernel bug indicating context switching in atomic context. In bottom half, it is interrupt context, and is process context in ksoftirqd. Regardless of processing tasklet in bottom half or ksoftirqd, thread_info->preempt_count
is not zero, which meaning atomic context.
上一篇: 如何在linux上调度tasklet?