From 50f78ebbe69c8d5e0573b4987d1e7dc21af9779c Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 10 Oct 2025 15:15:47 -0400 Subject: kern/amd64: Attempt to dequeue on a cores first go When a CPU core first starts up, it has no proceses to assign to itself. This commit ensures that the processor will right away start trying to find tasks to grab from its runqueue. Signed-off-by: Ian Moffett --- src/sys/arch/amd64/os/os_proc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/sys/arch/amd64/os/os_proc.c') diff --git a/src/sys/arch/amd64/os/os_proc.c b/src/sys/arch/amd64/os/os_proc.c index d944f41..b8e7c99 100644 --- a/src/sys/arch/amd64/os/os_proc.c +++ b/src/sys/arch/amd64/os/os_proc.c @@ -137,11 +137,24 @@ md_proc_init(struct proc *procp, int flags) __dead void md_proc_yield(void) { - /* Clear pending interrupts and oneshot */ + struct proc *proc; + struct pcore *core = this_core(); + int error; + lapic_eoi(); - lapic_timer_oneshot_us(9000); + /* + * Set the oneshot timer and check if there is + * any procs in our runqueues. If not, wait for + * it to fire again. + */ for (;;) { + lapic_timer_oneshot_us(9000); + error = sched_deq(&core->scq, &proc); + if (error == 0) { + core->curproc = proc; + md_proc_kick(proc); + } __ASMV("sti; hlt"); } } -- cgit v1.2.3