From 8c827365240216cbde7dc4a4f6d90c8c9f840ac8 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 30 Jan 2023 21:53:18 +0800 Subject: [PATCH] kernel: syscall: short-circuit return_scalar irq When in an IRQ, short-circuit the return logic. This should make interrupt returns slightly faster. Signed-off-by: Sean Cross --- kernel/src/syscall.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kernel/src/syscall.rs b/kernel/src/syscall.rs index d95579b35..5c9823163 100644 --- a/kernel/src/syscall.rs +++ b/kernel/src/syscall.rs @@ -434,9 +434,11 @@ fn return_scalar( } }; - let client_is_runnable = ss.runnable(client_pid, Some(client_tid))?; + if cfg!(baremetal) { + ss.ready_thread(client_pid, client_tid)?; + } - if !cfg!(baremetal) || in_irq || !client_is_runnable { + if !cfg!(baremetal) || in_irq || !ss.runnable(client_pid, Some(client_tid))? { // In a hosted environment, `switch_to_thread()` doesn't continue // execution from the new thread. Instead it continues in the old // thread. Therefore, we need to instruct the client to resume, and @@ -444,9 +446,6 @@ fn return_scalar( // In a baremetal environment, the opposite is true -- we instruct // the server to resume and return to the client. ss.set_thread_result(client_pid, client_tid, xous_kernel::Result::Scalar1(arg))?; - if cfg!(baremetal) { - ss.ready_thread(client_pid, client_tid)?; - } Ok(xous_kernel::Result::Ok) } else { // Switch away from the server, but leave it as Runnable @@ -455,7 +454,6 @@ fn return_scalar( ss.set_thread_result(server_pid, server_tid, xous_kernel::Result::Ok)?; // Switch to the client - ss.ready_thread(client_pid, client_tid)?; ss.switch_to_thread(client_pid, Some(client_tid))?; Ok(xous_kernel::Result::Scalar1(arg)) }