// 打断后该时钟中断不应该继续减少该进程的时间片,因为这会造成该进程在后续的调底中少了实际的运行时间
if (1 == current->need_resched) {
// 这种情况必然已经发生了该时钟中断打断了下半部处理程序
+ // 反之时钟中断打断了下半部处理程序不一定need_resched就为1
return;
}
assert(current->ticks >= 0); // 防止ticks被减到0后再减溢出
- add_irq_bh_handler(clk_bh_handler, NULL);
+ if (reenter == 0) {
+ add_irq_bh_handler(clk_bh_handler, NULL);
+ }
}
// 开中断执行这个函数
void irq_bh_handler();
void schedule();
+volatile int reenter_count = 0;
+
__attribute__((regparm(1))) void irq_handler(pt_regs_t *regs) {
unsigned int irq = regs->irq;
if (irq >= NR_IRQS) {
irq_desc_t *p = irq_desc + irq;
irq_action_t *action = p->action;
- assert(irq_disabled());
reenter++;
+ reenter_count += reenter == 0 ? 0 : 1;
+ assert(irq_disabled());
+ assert(reenter >= 0);
+ assert(reenter <= 1);
// 屏蔽当前中断
p->chip->disable(irq);
#if 1
unsigned long esp;
asm("movl %%esp, %%eax" : "=a"(esp));
- printl(MPL_CURRENT, "current %08x %-6s cr3 %08x reenter %d esp %08x ticks %u", current, current->name, current->cr3,
- reenter, esp, current->ticks);
+ printl(MPL_CURRENT, "current %08x %-6s cr3 %08x reenter %d:%u esp %08x ticks %u", current, current->name,
+ current->cr3, reenter, reenter_count, esp, current->ticks);
#endif
while (action && action->handler) {