diff --git a/src/arch/x86_64/interrupts.rs b/src/arch/x86_64/interrupts.rs index 5e68ac8..dae7506 100644 --- a/src/arch/x86_64/interrupts.rs +++ b/src/arch/x86_64/interrupts.rs @@ -169,10 +169,11 @@ extern "x86-interrupt" fn task_sched(_: InterruptStackFrame) { } } - // ensure that the next CPU core runs the next process when it receives this interrupt - if PTABLE_IDX.load(Ordering::SeqCst) < (PTABLE.read().len() - 1) { + if PTABLE_IDX.load(Ordering::SeqCst) < (PTABLE.read().len()) { + // ensure that the next CPU core runs the next process when it receives this interrupt PTABLE_IDX.fetch_add(1, Ordering::SeqCst); } else { + // we've reached the end of PTABLE, so time to reset this PTABLE_IDX.store(0, Ordering::SeqCst); }