From a64b80586a72166312fc8023ddb3ce998326fba7 Mon Sep 17 00:00:00 2001 From: Daniel Bittman Date: Wed, 13 Nov 2024 02:17:12 +0000 Subject: [PATCH] --amend --- src/kernel/src/sched.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/kernel/src/sched.rs b/src/kernel/src/sched.rs index 4a737eaa..a6c4f194 100644 --- a/src/kernel/src/sched.rs +++ b/src/kernel/src/sched.rs @@ -379,13 +379,16 @@ fn do_schedule(reinsert: bool) { pub fn schedule(reinsert: bool) { let cur = current_thread_ref().unwrap(); - /* TODO: switch to needs to also drop the ref on cur, somehow... */ /* TODO: if we preempt, just put the thread back on our list (or decide to not resched) */ let istate = interrupt::disable(); if cur.is_critical() { interrupt::set(istate); return; } + // We have to drop cur here and get it again later, after the call to do_schedule, even though + // it will be the same thread later. This is because the final call to this function after a + // thread exits will never return here after going into do_schedule, so we have to ensure + // that cur is dropped before then. drop(cur); do_schedule(reinsert);