From: acevest Date: Sun, 7 Nov 2021 08:38:59 +0000 (+0800) Subject: fix 在内核初始化阶段按键盘导致后续无法触发键盘中断的问题 X-Git-Url: http://zhaoyanbai.com/repos/migration?a=commitdiff_plain;h=25ba3cffc8f8252699ad7f5f2075d177c3473f8c;p=kernel.git fix 在内核初始化阶段按键盘导致后续无法触发键盘中断的问题 --- diff --git a/kernel/init.c b/kernel/init.c index 2dd393d..073c542 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -145,9 +145,16 @@ void kernel_task(char *name, void *entry) { printk("kernel[%s] task pid is %d\n", name, pid); } +// 从multiboot.S进入这里 void root_task_entry() { sti(); + // 有一点点垃圾事情需要处理 + // 之前内核初始化都是在关中断下进行的 + // 这就段时间有可能按键盘,然而键盘不把数据读出来就不会触发下一次中断 + // 所以得先清空一下键盘 + inb(0x60); + kernel_task("init", init_task_entry); kernel_task("test", init_task_entry); kernel_task("user", user_task_entry); diff --git a/kernel/sched.c b/kernel/sched.c index fd0bb48..43e3432 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -79,12 +79,16 @@ void setup_tasks() { init_root_tsk(); task_union_cache = kmem_cache_create("task_union", sizeof(task_union), PAGE_SIZE); - if (0 == task_union_cache) panic("setup tasks failed. out of memory"); + if (0 == task_union_cache) { + panic("setup tasks failed. out of memory"); + } } -task_union *alloc_task_union() { return (task_union *)kmem_cache_alloc(task_union_cache, 0); } - -inline task_union *get_next_tsk() { return 0; } +task_union *alloc_task_union() { + task_union *task; + task = (task_union *)kmem_cache_alloc(task_union_cache, 0); + return task; +} void switch_to() { LoadCR3(current->cr3);