- 论坛徽章:
- 0
|
回复 32# MagicBoy2010
经MagicBoy2010 兄提醒,又翻了下书《Professional Linux Kernel Architecture》
参考:http://blog.chinaunix.net/space. ... o=blog&id=92384
把我自己理解的说一下,大家看看是否有出入。
spin_lock(及其变种)
preempt_enable
preempt_check_resched
preempt_schedule
add_preempt_count_notrace(PREEMPT_ACTIVE);
__schedule();
sub_preempt_count_notrace(PREEMPT_ACTIVE);
中断返回会调用到:
preempt_schedule_irq
add_preempt_count(PREEMPT_ACTIVE);
local_irq_enable();
__schedule();
local_irq_disable();
sub_preempt_count(PREEMPT_ACTIVE);
可见中断返回或者自旋锁解锁调度__schedule()之前都需要给preempt_count加上PREEMPT_ACTIVE。
__schedule
if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
deactivate_task(rq, prev, DEQUEUE_SLEEP);
}
当前进程非TASK_RUNNING(运行的话,当然无须移除),并且非PREEMPT_ACTIVE状态,才可以从运行队列移除。
|
|