mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
fix thread scheduling bug
the code originally would pick the same thread over and over again this fix starts the thread search at one plus the current thread wrapping around to one plus the current thread, so we always try to pick a new thread compared to the current one, instead of generally picking the same thread most of the time.
This commit is contained in:
parent
4b0f50293f
commit
2d59adbe0e
1 changed files with 3 additions and 3 deletions
|
|
@ -789,7 +789,7 @@ impl SystemServices {
|
|||
) -> Result<TID, xous_kernel::Error> {
|
||||
let previous_pid = self.current_pid();
|
||||
|
||||
let debug = true;
|
||||
let debug = false;
|
||||
if debug {
|
||||
println!(
|
||||
"\n\r KERNEL({},{}): Activating process {} thread {}",
|
||||
|
|
@ -825,12 +825,12 @@ impl SystemServices {
|
|||
new_pid, x,
|
||||
);
|
||||
//new_tid = 0;
|
||||
new_tid = new.current_thread as usize;
|
||||
new_tid = (new.current_thread + 1) as usize;
|
||||
while x & (1 << new_tid) == 0 {
|
||||
new_tid += 1;
|
||||
if new_tid > arch::process::MAX_THREAD {
|
||||
new_tid = 0;
|
||||
} else if new_tid == new.current_thread as usize {
|
||||
} else if new_tid == (new.current_thread + 1) as usize {
|
||||
// If we've looped around, return an error.
|
||||
println!("Looked through all contexts and couldn't find one that was ready");
|
||||
return Err(xous_kernel::Error::ProcessNotFound);
|
||||
|
|
|
|||
Loading…
Reference in a new issue