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);