From e65bc040af3ef27c2535eb327f261ffc4523d4e3 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 9 Mar 2024 23:53:50 +0200 Subject: [PATCH] Kernel: Now all active processors are used in scheduling When a timer reschedule happens, ipi is broadcasted too all processors for them to perform a reschedule! --- kernel/arch/x86_64/IDT.cpp | 8 +++++--- kernel/kernel/Scheduler.cpp | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/kernel/arch/x86_64/IDT.cpp b/kernel/arch/x86_64/IDT.cpp index dce1d4e341..239d800704 100644 --- a/kernel/arch/x86_64/IDT.cpp +++ b/kernel/arch/x86_64/IDT.cpp @@ -310,10 +310,12 @@ done: else { InterruptController::get().eoi(irq); - if (s_interruptables[irq]) - s_interruptables[irq]->handle_irq(); + if (irq == IRQ_IPI) + Scheduler::get().reschedule(); + else if (auto* handler = s_interruptables[irq]) + handler->handle_irq(); else - dprintln("no handler for irq 0x{2H}\n", irq); + dprintln("no handler for irq 0x{2H}", irq); } Scheduler::get().reschedule_if_idling(); diff --git a/kernel/kernel/Scheduler.cpp b/kernel/kernel/Scheduler.cpp index c68428bb6a..73f9d86f59 100644 --- a/kernel/kernel/Scheduler.cpp +++ b/kernel/kernel/Scheduler.cpp @@ -67,6 +67,10 @@ namespace Kernel void Scheduler::timer_reschedule() { + // Broadcast IPI to all other processors for them + // to perform reschedule + InterruptController::get().broadcast_ipi(); + auto state = m_lock.lock(); m_blocking_threads.remove_with_wake_time(m_active_threads, SystemTimer::get().ms_since_boot()); if (save_current_thread())