in tasklet_action routine - while handling an entry from tasklet_vec list of
core , we are atomically reading atomic_read(&t->count), i dont see
any of its uses through out the routine, what is its significant ?
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);
}
The tasklet is regarded as deactivated/disabled if the count is not equal to zero.
In some architectures, the read operation does not happen in single assembly instruction. For example, if you are reading 64 bit value, the compiler might implement the read using two load instructions of assembly such that the 1st instruction reads the lower 32 bits and the 2nd instruction reads the higher 32 bits. This in turn can lead to race condition. So, atomic reads are preferred.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.