mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
kernel: don't yield when JoinThread returns immediately
When waiting on a thread, it may be the case that the thread we're joining has exited already. In this case, the correct approach is to resume execution rather than switching to the parent process. This fixes an issue where `SWITCHTO_CALLER` is None when joining a short-lived thread. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
b18e7d7e99
commit
5dae8f7662
1 changed files with 5 additions and 1 deletions
|
|
@ -1145,7 +1145,11 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
|
|||
}),
|
||||
SysCall::JoinThread(other_tid) => {
|
||||
SystemServices::with_mut(|ss| ss.join_thread(pid, tid, other_tid)).map(|ret| {
|
||||
unsafe { SWITCHTO_CALLER = None };
|
||||
// Successfully joining a thread causes this thread to sleep while the parent process
|
||||
// is resumed. This is the same as a `Yield`
|
||||
if ret == xous_kernel::Result::ResumeProcess {
|
||||
unsafe { SWITCHTO_CALLER = None };
|
||||
}
|
||||
ret
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue