From 7be4a88a9bc25c78fb9ff9dcedd3b307be43237c Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 17 Jan 2023 02:11:48 +0800 Subject: [PATCH] fix scheduler bug (credit: @xobs) @xobs found a scheduler bug that would trigger a runnable process search every time a scalar message returned. This fixes the problem, causing the quantum to go back to the caller as intended. Improves performance on the syscall by about 40%. --- kernel/src/services.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/src/services.rs b/kernel/src/services.rs index f6c1ac1e1..e9f5fd0cb 100644 --- a/kernel/src/services.rs +++ b/kernel/src/services.rs @@ -653,8 +653,7 @@ impl SystemServices { let process = self.get_process(pid)?; if let Some(tid) = tid { Ok(match process.state { - ProcessState::Running(x) if x & (1 << tid) == 0 => true, - ProcessState::Ready(x) if x & (1 << tid) == 0 => true, + ProcessState::Running(x) | ProcessState::Ready(x) if x & (1 << tid) != 0 => true, ProcessState::Sleeping => true, _ => false, })