From 1303e6416d5578531ee9230bfed90cae97304eab Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Tue, 31 Jan 2023 16:01:35 +0800 Subject: [PATCH] kernel: fixup current_thread==0 on resume For some reason, the current thread becomes 0 during suspend or resume. This causes an error during boot. Patch this up while we figure out what's causing it. Signed-off-by: Sean Cross --- kernel/src/services.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/src/services.rs b/kernel/src/services.rs index 209e95bcf..7d8697e15 100644 --- a/kernel/src/services.rs +++ b/kernel/src/services.rs @@ -587,7 +587,11 @@ impl SystemServices { let mut current = self .get_process_mut(current_pid) .expect("couldn't get current PID"); - assert!(arch::process::current_tid() == current.current_thread); + // The current thread should never be 0, but for some reason it ends up + // as 0 after resuming from suspend. It's unclear how this happens. + if current.current_thread == 0 { + current.current_thread = arch::process::current_tid(); + } // let old_state = current.state; current.state = match current.state { ProcessState::Running(x) => ProcessState::Ready(x | (1 << current.current_thread)),