mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +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| {
|
||||
ss.create_thread(pid, thread_init).map(|new_tid| {
|
||||
if !cfg!(baremetal) {
|
||||
ss.switch_to_thread(pid, Some(new_tid))
|
||||
.expect("couldn't activate new thread");
|
||||
}
|
||||
xous_kernel::Result::ThreadID(new_tid)
|
||||
// Immediately switch to the new thread
|
||||
ss.switch_to_thread(pid, Some(new_tid))
|
||||
.expect("couldn't activate new thread");
|
||||
|
||||
// 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| {
|
||||
|
|
|
|||
Loading…
Reference in a new issue