我在 c 中从头开始制作内核(不是 linux。完全从头开始),我遇到了一些问题。我有这个代码:
#include "timer.h"
int ms = 0;
void timer_handler(struct regs *r){
ms++;
println("I print every tick");
}
void sleep(int ticks){
unsigned long eticks;
eticks = ms + ticks;
while(ms < eticks);
}
并且 timer_handler 连接到 IRQ0(PIT)并且工作得很好。说“我打印每个刻度”的 println 工作得很好,如果我在我的代码中打印 ms 变量,它会打印正确的数量。但是,如果我调用 sleep 函数,timer_handler 会停止触发并陷入无限循环。有什么办法可以让中断在while循环中触发?