mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
kernel: immediately switch to new thread on CreateThread
When a new thread is created, immediately switch to the new thread. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
d25629a3ed
commit
b18e7d7e99
1 changed files with 10 additions and 5 deletions
|
|
@ -1048,11 +1048,16 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
|
||||||
}),
|
}),
|
||||||
SysCall::CreateThread(thread_init) => SystemServices::with_mut(|ss| {
|
SysCall::CreateThread(thread_init) => SystemServices::with_mut(|ss| {
|
||||||
ss.create_thread(pid, thread_init).map(|new_tid| {
|
ss.create_thread(pid, thread_init).map(|new_tid| {
|
||||||
if !cfg!(baremetal) {
|
// Immediately switch to the new thread
|
||||||
ss.switch_to_thread(pid, Some(new_tid))
|
ss.switch_to_thread(pid, Some(new_tid))
|
||||||
.expect("couldn't activate new thread");
|
.expect("couldn't activate new thread");
|
||||||
}
|
|
||||||
xous_kernel::Result::ThreadID(new_tid)
|
// Set the return value of the existing thread to be the new thread ID
|
||||||
|
ss.set_thread_result(pid, tid, xous_kernel::Result::ThreadID(new_tid))
|
||||||
|
.expect("couldn't set new thread ID");
|
||||||
|
|
||||||
|
// Return `ResumeProcess` since we're switching threads
|
||||||
|
xous_kernel::Result::ResumeProcess
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
SysCall::CreateProcess(process_init) => SystemServices::with_mut(|ss| {
|
SysCall::CreateProcess(process_init) => SystemServices::with_mut(|ss| {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue