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:
parent
96f3d29d37
commit
3ed9e578c7
@ -26,6 +26,8 @@ extern void pic_eoi(unsigned char irq);
|
|||||||
extern void pic_eoi(Registers* regs);
|
extern void pic_eoi(Registers* regs);
|
||||||
extern void setup_idt();
|
extern void setup_idt();
|
||||||
|
|
||||||
|
static Thread* g_io_thread;
|
||||||
|
|
||||||
void FPData::save()
|
void FPData::save()
|
||||||
{
|
{
|
||||||
asm volatile("fxsave (%0)" : : "r"(m_data));
|
asm volatile("fxsave (%0)" : : "r"(m_data));
|
||||||
@ -126,7 +128,7 @@ void io_thread()
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
u8 scancode;
|
u8 scancode;
|
||||||
while (!scancode_queue.try_pop(scancode)) { kernel_sleep(10); }
|
while (!scancode_queue.try_pop(scancode)) { kernel_wait(0); }
|
||||||
|
|
||||||
char key;
|
char key;
|
||||||
if (Keyboard::decode_scancode(scancode).try_set_value(key)) { ConsoleDevice::did_press_key(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);
|
u8 scancode = IO::inb(0x60);
|
||||||
scancode_queue.try_push(scancode);
|
scancode_queue.try_push(scancode);
|
||||||
|
g_io_thread->state = ThreadState::Runnable;
|
||||||
pic_eoi(regs);
|
pic_eoi(regs);
|
||||||
}
|
}
|
||||||
else if (regs->isr == 66) // System call
|
else if (regs->isr == 66) // System call
|
||||||
@ -219,8 +222,8 @@ namespace CPU
|
|||||||
|
|
||||||
void platform_finish_init()
|
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!");
|
.expect_value("Could not create the IO background thread!");
|
||||||
|
|
||||||
remap_pic();
|
remap_pic();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user