kernel: services: remember new thread if specified

If we switch to a thread and specify a thread ID, remember that as the
current thread ID.

This prevents thread starvation by repeatedly going back to the same
thread ID.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-03-23 19:50:12 +08:00
parent 9ab5b4880f
commit 00e7f07187

View file

@ -854,13 +854,15 @@ impl SystemServices {
} }
} }
new.current_thread = new_tid as _; new.current_thread = new_tid as _;
// println!(" -- picked thread {}", new_tid); klog!("picked thread ID {}", new_tid);
} else if x & (1 << new_tid) == 0 { } else if x & (1 << new_tid) == 0 {
// println!( // println!(
// "thread is {:?}, which is not valid for new thread {}", // "thread is {:?}, which is not valid for new thread {}",
// new.state, new_tid // new.state, new_tid
// ); // );
return Err(xous_kernel::Error::ProcessNotFound); return Err(xous_kernel::Error::ProcessNotFound);
} else {
new.current_thread = new_tid as _;
} }
} }
ProcessState::Sleeping => { ProcessState::Sleeping => {