From 2e6c74457219d13473c5a3fe1abec32e4cfb7db4 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Tue, 16 Apr 2024 16:30:12 +0200 Subject: [PATCH] riot-rs-threads: always set `threads.current_thread` in `sched()` --- src/riot-rs-threads/src/arch/cortex_m.rs | 1 + src/riot-rs-threads/src/lib.rs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/riot-rs-threads/src/arch/cortex_m.rs b/src/riot-rs-threads/src/arch/cortex_m.rs index 7084bbbd8..ae54e5b36 100644 --- a/src/riot-rs-threads/src/arch/cortex_m.rs +++ b/src/riot-rs-threads/src/arch/cortex_m.rs @@ -259,6 +259,7 @@ unsafe fn sched(old_sp: usize) -> usize { threads.current_thread = Some(next_pid); current_high_regs = threads.threads[current_pid as usize].data.as_ptr(); } else { + threads.current_thread = Some(next_pid); current_high_regs = core::ptr::null(); } diff --git a/src/riot-rs-threads/src/lib.rs b/src/riot-rs-threads/src/lib.rs index c8f89a189..a0790d62d 100644 --- a/src/riot-rs-threads/src/lib.rs +++ b/src/riot-rs-threads/src/lib.rs @@ -187,7 +187,6 @@ pub unsafe fn start_threading() { let cs = unsafe { CriticalSection::new() }; let next_sp = THREADS.with_mut_cs(cs, |mut threads| { let next_pid = threads.runqueue.get_next().unwrap(); - threads.current_thread = Some(next_pid); threads.threads[next_pid as usize].sp }); Cpu::start_threading(next_sp);