在tasklet_action例程中-处理来自tasklet_vec列表的条目时
核心,我们正在原子读取计数(&t->atomic_read),我看不到
它在日常生活中的任何用法,它的意义是什么?
if (tasklet_trylock(t)) { // check is it is not already being executed
if (!atomic_read(&t->count)) {
if (!test_and_clear_bit(TASKLET_STATE_SCHED, &t->state))
BUG();
t->func(t->data); // call tasklet action routine
tasklet_unlock(t);
continue;
}
tasklet_unlock(t);
}发布于 2015-10-21 00:40:12
如果计数不等于零,则将微线程视为停用/禁用。
在某些体系结构中,读操作不会发生在单个汇编指令中。例如,如果您正在读取64位值,编译器可能会使用汇编的两个加载指令来实现读取,以便第一条指令读取较低的32位,第二条指令读取较高的32位。这反过来会导致竞争条件。因此,原子读取是首选。
https://stackoverflow.com/questions/33166750
复制相似问题