diff --git a/15_day/bootpack.c b/15_day/bootpack.c index 98b7bc4..42ea912 100644 --- a/15_day/bootpack.c +++ b/15_day/bootpack.c @@ -278,5 +278,24 @@ void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c) void task_b_main(void) { - for (;;) { io_hlt(); } + struct FIFO32 fifo; + struct TIMER *timer; + int i, fifobuf[128]; + fifo32_init(&fifo, 128, fifobuf); + timer = timer_alloc(); + timer_init(timer, &fifo, 1); + timer_settime(timer, 500); + + for (;;) { + io_cli(); + if (fifo32_status(&fifo) == 0) { + io_stihlt(); + } else { + i = fifo32_get(&fifo); + io_sti(); + if (i == 1) { /*超时时间为5秒 */ + taskswitch3(); /*返回任务A */ + } + } + } } diff --git a/15_day/bootpack.h b/15_day/bootpack.h index 7028583..5868890 100644 --- a/15_day/bootpack.h +++ b/15_day/bootpack.h @@ -28,6 +28,7 @@ void asm_inthandler21(void); void asm_inthandler27(void); void asm_inthandler2c(void); unsigned int memtest_sub(unsigned int start, unsigned int end); +void taskswitch3(void); void taskswitch4(void); /* fifo.c */ diff --git a/15_day/naskfunc.nas b/15_day/naskfunc.nas index 0a1e37f..d7194a7 100644 --- a/15_day/naskfunc.nas +++ b/15_day/naskfunc.nas @@ -16,7 +16,7 @@ GLOBAL _asm_inthandler20, _asm_inthandler21 GLOBAL _asm_inthandler27, _asm_inthandler2c GLOBAL _memtest_sub - GLOBAL _taskswitch4 + GLOBAL _taskswitch3, _taskswitch4 EXTERN _inthandler20, _inthandler21 EXTERN _inthandler27, _inthandler2c @@ -207,6 +207,10 @@ mts_fin: POP EDI RET +_taskswitch3: ; void taskswitch3(void); + JMP 3*8:0 + RET + _taskswitch4: ; void taskswitch4(void); JMP 4*8:0 RET