diff --git a/kernel/src/arch/hosted.rs b/kernel/src/arch/hosted.rs index b9e56b87c..687303163 100644 --- a/kernel/src/arch/hosted.rs +++ b/kernel/src/arch/hosted.rs @@ -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, diff --git a/kernel/src/arch/hosted/process.rs b/kernel/src/arch/hosted/process.rs index 8f381a63e..738e384f2 100644 --- a/kernel/src/arch/hosted/process.rs +++ b/kernel/src/arch/hosted/process.rs @@ -171,6 +171,19 @@ impl Process { }) } + /// Calls the provided function with the current inner process state. + pub fn with_current_mut(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();