mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
kernel: services: fix suspend for running processes
If a process is currently running, it needs to be placed into the `Debug` state rather than the `Ready` state. Additionally, the process that's being switched to must enter the `Running` state. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
1cb86078d5
commit
b43366e6ec
1 changed files with 13 additions and 1 deletions
|
|
@ -2112,10 +2112,22 @@ impl SystemServices {
|
||||||
// but without a context to switch to.
|
// but without a context to switch to.
|
||||||
p.set_tid(parent_process.previous_thread).unwrap();
|
p.set_tid(parent_process.previous_thread).unwrap();
|
||||||
parent_process.current_thread = parent_process.previous_thread;
|
parent_process.current_thread = parent_process.previous_thread;
|
||||||
|
parent_process.state = match parent_process.state {
|
||||||
|
ProcessState::Ready(x) | ProcessState::Running(x)
|
||||||
|
if x & (1 << parent_process.previous_thread) != 0 =>
|
||||||
|
{
|
||||||
|
ProcessState::Running(x & !(1 << parent_process.previous_thread))
|
||||||
|
}
|
||||||
|
ProcessState::Sleeping => ProcessState::Running(0),
|
||||||
|
_ => panic!(
|
||||||
|
"parent process was not ready to be resumed: {:?}",
|
||||||
|
parent_process.state
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
// Ensure we don't switch back to the same process.
|
// Ensure we don't switch back to the same process.
|
||||||
unsafe { crate::arch::irq::take_isr_return_pair() };
|
unsafe { crate::arch::irq::take_isr_return_pair() };
|
||||||
ProcessState::Ready(tids | 1 << current_tid)
|
ProcessState::Debug(tids | 1 << current_tid)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue