kernel/x86_64: Wake the IO thread up only when there is an IO event, instead of polling every 10 ms

This commit is contained in:
apio 2023-05-04 23:07:09 +02:00
parent 96f3d29d37
commit 3ed9e578c7
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -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,7 +222,7 @@ namespace CPU
void platform_finish_init()
{
Scheduler::new_kernel_thread(io_thread, "[x86_64-io]")
g_io_thread = Scheduler::new_kernel_thread(io_thread, "[x86_64-io]")
.expect_value("Could not create the IO background thread!");
remap_pic();