Browse Source

完成了计时器的实时更新。

x86-32
423A35C7 9 months ago
parent
commit
08a0e08f4d
1 changed files with 9 additions and 8 deletions
  1. +9
    -8
      labcodes_answer/lab1_result/kern/trap/trap.c

+ 9
- 8
labcodes_answer/lab1_result/kern/trap/trap.c View File

@ -166,11 +166,15 @@ trap_dispatch(struct trapframe *tf) {
*/
switch (state) {
case STARTED:
milliseconds += mode;
// 0
// mode之后至少为1所以不会转换状态
// 使000
state = READY_TO_OUTPUT * (milliseconds <= 0); //
if (ticks % TICK_NUM == 0) {
milliseconds += mode * TICK_NUM;
// 0
// mode之后至少为1所以不会转换状态
// 使000
state = READY_TO_OUTPUT * (milliseconds <= 0); //
// print_ticks();
cprintf("\r%d.%03d\t", milliseconds / 1000, milliseconds % 1000);
}
break;
case READY_TO_OUTPUT:
state = STOPPED;
@ -182,9 +186,6 @@ trap_dispatch(struct trapframe *tf) {
break;
}
ticks ++;
// if (ticks % TICK_NUM == 0) {
// print_ticks();
// }
break;
case IRQ_OFFSET + IRQ_COM1:
c = cons_getc();

Loading…
Cancel
Save