- 论坛徽章:
- 4
|
10可用积分
__mod_timer() from 3.6.10
- new_base = per_cpu(tvec_bases, cpu);
- if (base != new_base) {
- /*
- * We are trying to schedule the timer on the local CPU.
- * However we can't change timer's base while it is running,
- * otherwise del_timer_sync() can't detect that the timer's
- * handler yet has not finished. This also guarantees that
- * the timer is serialized wrt itself.
- */
- if (likely(base->running_timer != timer)) {
- /* See the comment in lock_timer_base() */
- timer_set_base(timer, NULL);
- spin_unlock(&base->lock);
- base = new_base;
- spin_lock(&base->lock);
- timer_set_base(timer, base);<-----------------------------------切换
- }
- }
复制代码 cpu迁移时的场景:
想不明白为何在修改timer做修改时, 要根据当前cpu去切换base?
不切换, 并在原有base上做修改不是更快么?
请指点, 谢谢!
|
最佳答案
查看完整内容
回复 3# chishanmingshen 当然得等待timer不在运行的时候,你才可以把它调度到本地cpu的时钟管理队列,如果该timer已经在其他cpu上运行了,你当然就不能调度了。至于为何要迁移,楼上给出的说法,呵呵最极端的就是cpu还有支持hotplug的,所以迁移是正常的,不然这个定时器很可能就再也无法调度了。
|