关闭中断后调用可能引起堵塞的函数后,切换函数会唤醒新进程,打开中断。
但是关闭中断的的初衷是保护临界区,切换出去违背初衷
define might_sleep() do { might_resched(); } while (0)
=>might_resched()
=># define might_resched() cond_resched()
=>__cond_resched();
=>do {
add_preempt_count(PREEMPT_ACTIVE);
schedule();
=>context_switch(rq, prev, next);
=>switch_to(prev, next, prev);
=>((last) = __switch_to((prev), (next)))//MSR替换,会打开中断
sub_preempt_count(PREEMPT_ACTIVE);
} while (need_resched());
有趣的是,中断上下文与进程上下文有类似的地方
union irq_ctx *hardirq_ctx[NR_CPUS] __read_mostly;
union irq_ctx {
struct thread_info tinfo;
u32 stack[THREAD_SIZE/sizeof(u32)];
};
中断栈可以依附于内核栈;也可以是独立的。取决于内核配置。
如果中断栈非独立,那么A进程运行时出现中断,那么这时中断栈就在A的内核栈。中断如果堵塞,就乱套了。
通过CONFIG_IRQSTACKS可以使能独立中断栈。
irq_desc {
irq_chip;抽象不同种类的中断控制器PIC
irqaction *action
}
内核随记(一)——理解中断(1)
http://www.cnblogs.com/hustcat/archive/2009/08/11/1543889.html
为什么中断不能睡眠
http://blog.csdn.net/mihouge/article/details/44198375