mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
kernel: implement retry_instruction()
This function is used to decrement the program counter to re-run a given instruction. This can be used as a cheap way to implement blocking calls. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
a0a90cc3ab
commit
585e55e8b7
2 changed files with 13 additions and 0 deletions
|
|
@ -179,6 +179,10 @@ impl Process {
|
|||
process.threads[thread - 1].allocated = true;
|
||||
}
|
||||
|
||||
pub fn retry_instruction(&mut self, _tid: TID) -> Result<(), xous_kernel::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn setup_process(pid: PID, setup: ThreadInit) -> Result<(), xous_kernel::Error> {
|
||||
let mut tmp = Process { pid };
|
||||
tmp.setup_thread(INITIAL_TID, setup)
|
||||
|
|
|
|||
|
|
@ -235,6 +235,15 @@ impl Process {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn retry_instruction(&mut self, tid: TID) -> Result<(), xous_kernel::Error> {
|
||||
let process = unsafe { &mut *PROCESS };
|
||||
let mut thread = &mut process.threads[tid];
|
||||
if thread.sepc >= 4 {
|
||||
thread.sepc -= 4;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Initialize this process thread with the given entrypoint and stack
|
||||
/// addresses.
|
||||
pub fn setup_process(pid: PID, thread_init: ThreadInit) -> Result<(), xous_kernel::Error> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue