comment added
This commit is contained in:
@@ -76,13 +76,18 @@ usertrap(void)
|
||||
if(killed(p))
|
||||
exit(-1);
|
||||
|
||||
// give up the CPU if this is a timer interrupt.
|
||||
// 如果这是一个定时器中断,则让出CPU。
|
||||
if(which_dev == 2){
|
||||
// 当前进程的中断计数器加一。
|
||||
p->inter_cnt++;
|
||||
// 如果中断计数器达到设定的报警计数,并且报警计数大于0。
|
||||
if (p->inter_cnt == p->alarm_cnt && 0 < p->alarm_cnt) {
|
||||
// 备份当前trapframe到pre_trapframe,用于后续恢复。
|
||||
*p->pre_trapframe = *p->trapframe;
|
||||
// 将epc设置为用户定义的handler函数地址,返回用户态时会跳转到handler执行。
|
||||
p->trapframe->epc = p->handler;
|
||||
} else {
|
||||
// 否则让出CPU,进行进程调度。
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user