中断API之__tasklet_hi_schedule

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);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值