void __tasklet_hi_schedule(struct tasklet_struct *t),函数的主要作用是将参数t代表的软中断
添加到向量tasklet_hi_vec的尾部,并触发一个软中断.
其使用的例程如下:
static inline void tasklet_hi_schedule(struct tasklet_struct *t)
{
//检查这个tasklet是否正在被调度,如果没有被调用才能被加入到tasklet_hi_vec 尾部.
if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
__tasklet_hi_schedule(t);
}
其源码分析如下:
void __tasklet_hi_schedule(struct tasklet_struct *t)
{
unsigned long flags;
//在当前cpu上禁止中断
local_irq_save(flags);
t->next = NULL;
//通过__this_cpu_read 读取tasklet_hi_vec.tail的值。此时值是null,然后把t赋值给tasklet_hi_vec.tail
*__this_cpu_read(tasklet_hi_vec.tail) = t;
// 把t->next 赋值给tasklet_hi_vec.tail。所以tasklet_hi_vec.tail得最后一个元素是null
__this_cpu_write(tasklet_hi_vec.tail, &(t->next));
//触发一个HI_SOFTIRQ的软件中断
raise_softirq_irqoff(HI_SOFTIRQ);
//使能当前cpu上的中断
local_irq_restore(flags);
}
中断API之__tasklet_hi_schedule
最新推荐文章于 2023-11-28 18:00:22 发布