From cbd2d9d625a7bddeea4d734f901237a1ef86e745 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Sun, 23 Jan 2022 00:29:51 -0800 Subject: [PATCH] [kernel] Fix scheduler promotion bug The scheduler was accidentally checking the state of the _currently running_ thread when seeing if it should promote a thread in the ready queue. So, ie, constant-priority threads would get promoted as long as some non-constant-priority thread was the currently-running thread. --- src/kernel/scheduler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/scheduler.cpp b/src/kernel/scheduler.cpp index d0657c8..454f3ac 100644 --- a/src/kernel/scheduler.cpp +++ b/src/kernel/scheduler.cpp @@ -163,7 +163,7 @@ scheduler::check_promotions(run_queue &queue, uint64_t now) { for (auto &pri_list : queue.ready) { for (auto *tcb : pri_list) { - const thread *th = queue.current->thread; + const thread *th = tcb->thread; const bool constant = th->has_state(thread::state::constant); if (constant) continue;