mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
kernel: hosted: add current_tid() to Process
This allows us to mock the current TID for debugging purposes on hosted environments. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
e5100bcb33
commit
61fdd5be15
2 changed files with 17 additions and 0 deletions
|
|
@ -68,6 +68,10 @@ fn generate_pid_key() -> [u8; 16] {
|
|||
process_key
|
||||
}
|
||||
|
||||
pub fn current_pid() -> PID {
|
||||
crate::arch::process::current_pid()
|
||||
}
|
||||
|
||||
/// Each client gets its own connection and its own thread, which is handled here.
|
||||
fn handle_connection(
|
||||
conn: TcpStream,
|
||||
|
|
|
|||
|
|
@ -171,6 +171,19 @@ impl Process {
|
|||
})
|
||||
}
|
||||
|
||||
/// Calls the provided function with the current inner process state.
|
||||
pub fn with_current_mut<F, R>(f: F) -> R
|
||||
where
|
||||
F: FnOnce(&mut Process) -> R,
|
||||
{
|
||||
let mut process = Self::current();
|
||||
f(&mut process)
|
||||
}
|
||||
|
||||
pub fn current_tid(&self) -> TID {
|
||||
1
|
||||
}
|
||||
|
||||
fn setup_thread_inner(thread: TID, process_table: &mut ProcessTable) {
|
||||
let current_pid_idx = process_table.current.get() as usize - 1;
|
||||
let process = &mut process_table.table[current_pid_idx].as_mut().unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue