diff --git a/kernel/src/arch/x86_64/CPU.cpp b/kernel/src/arch/x86_64/CPU.cpp index fdb762a4..08d132db 100644 --- a/kernel/src/arch/x86_64/CPU.cpp +++ b/kernel/src/arch/x86_64/CPU.cpp @@ -26,6 +26,8 @@ extern void pic_eoi(unsigned char irq); extern void pic_eoi(Registers* regs); extern void setup_idt(); +static Thread* g_io_thread; + void FPData::save() { asm volatile("fxsave (%0)" : : "r"(m_data)); @@ -126,7 +128,7 @@ void io_thread() while (true) { u8 scancode; - while (!scancode_queue.try_pop(scancode)) { kernel_sleep(10); } + while (!scancode_queue.try_pop(scancode)) { kernel_wait(0); } char key; if (Keyboard::decode_scancode(scancode).try_set_value(key)) { ConsoleDevice::did_press_key(key); } @@ -147,6 +149,7 @@ extern "C" void arch_interrupt_entry(Registers* regs) { u8 scancode = IO::inb(0x60); scancode_queue.try_push(scancode); + g_io_thread->state = ThreadState::Runnable; pic_eoi(regs); } else if (regs->isr == 66) // System call @@ -219,8 +222,8 @@ namespace CPU void platform_finish_init() { - Scheduler::new_kernel_thread(io_thread, "[x86_64-io]") - .expect_value("Could not create the IO background thread!"); + g_io_thread = Scheduler::new_kernel_thread(io_thread, "[x86_64-io]") + .expect_value("Could not create the IO background thread!"); remap_pic(); }