mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
kernel: syscall: move do_yield() to its own function
This will allow us to call `Yield` for other operations that need to be blocking. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
585e55e8b7
commit
0c344efb60
1 changed files with 20 additions and 18 deletions
|
|
@ -10,6 +10,25 @@ use xous_kernel::*;
|
|||
/// This is the context that called SwitchTo
|
||||
static mut SWITCHTO_CALLER: Option<(PID, TID)> = None;
|
||||
|
||||
fn do_yield(_pid: PID, tid: TID) -> SysCallResult {
|
||||
// If we're not running on bare metal, treat this as a no-op.
|
||||
if !cfg!(baremetal) {
|
||||
return Ok(xous_kernel::Result::Ok);
|
||||
}
|
||||
|
||||
let (parent_pid, parent_ctx) = unsafe {
|
||||
SWITCHTO_CALLER
|
||||
.take()
|
||||
.expect("yielded when no parent context was present")
|
||||
};
|
||||
SystemServices::with_mut(|ss| {
|
||||
// TODO: Advance thread
|
||||
ss.activate_process_thread(tid, parent_pid, parent_ctx, true)
|
||||
.map(|_| Ok(xous_kernel::Result::ResumeProcess))
|
||||
.unwrap_or(Err(xous_kernel::Error::ProcessNotFound))
|
||||
})
|
||||
}
|
||||
|
||||
fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallResult {
|
||||
SystemServices::with_mut(|ss| {
|
||||
let sidx = ss
|
||||
|
|
@ -590,24 +609,7 @@ pub fn handle_inner(pid: PID, tid: TID, call: SysCall) -> SysCallResult {
|
|||
interrupt_claim(no, pid as definitions::PID, callback, arg)
|
||||
.map(|_| xous_kernel::Result::Ok)
|
||||
}
|
||||
SysCall::Yield => {
|
||||
// If we're not running on bare metal, treat this as a no-op.
|
||||
if !cfg!(baremetal) {
|
||||
return Ok(xous_kernel::Result::Ok);
|
||||
}
|
||||
|
||||
let (parent_pid, parent_ctx) = unsafe {
|
||||
SWITCHTO_CALLER
|
||||
.take()
|
||||
.expect("yielded when no parent context was present")
|
||||
};
|
||||
SystemServices::with_mut(|ss| {
|
||||
// TODO: Advance thread
|
||||
ss.activate_process_thread(tid, parent_pid, parent_ctx, true)
|
||||
.map(|_| Ok(xous_kernel::Result::ResumeProcess))
|
||||
.unwrap_or(Err(xous_kernel::Error::ProcessNotFound))
|
||||
})
|
||||
}
|
||||
SysCall::Yield => do_yield(pid, tid),
|
||||
SysCall::ReturnToParentI(_pid, _cpuid) => {
|
||||
unsafe {
|
||||
// let (_current_pid, _current_ctx) = crate::arch::irq::take_isr_return_pair()
|
||||
|
|
|
|||
Loading…
Reference in a new issue