- 论坛徽章:
- 0
|
今天无意中看了下tasklet的原代码
void __tasklet_schedule(struct tasklet_struct *t)
{
unsigned long flags;
local_irq_save(flags);
t->next = NULL;
*__this_cpu_read(tasklet_vec.tail) = t;
__this_cpu_write(tasklet_vec.tail, &(t->next));
raise_softirq_irqoff(TASKLET_SOFTIRQ);
local_irq_restore(flags);
}
这里的tasklet_vec是一个单向的链表,head用来遍历,tail用来添加元素。
但是
t->next = NULL;
*__this_cpu_read(tasklet_vec.tail) = t;
__this_cpu_write(tasklet_vec.tail, &(t->next));
这怎么能实现添加新成员的功能,
还有t应该是和&(t->next)相等的,
那上面两句是一样的功能。
我觉得要这样写才能实现
t->next = NULL;
(*__this_cpu_read(tasklet_vec.tail) ).next= t;
__this_cpu_write(tasklet_vec.tail, t);
希望哪位大牛能解释下。 |
|