diff --git a/kernel/src/arch/hosted/process.rs b/kernel/src/arch/hosted/process.rs index 44db55b50..3f3e795a8 100644 --- a/kernel/src/arch/hosted/process.rs +++ b/kernel/src/arch/hosted/process.rs @@ -128,12 +128,12 @@ impl Process { context: TID, _setup: ContextInit, ) -> Result<(), xous::Error> { - println!( - "KERNEL({}): Setting up context {} @ {:?}", - self.pid, - context, - std::thread::current() - ); + // println!( + // "KERNEL({}): Setting up context {} @ {:?}", + // self.pid, + // context, + // std::thread::current() + // ); assert!(context > 0); PROCESS_TABLE.with(|pt| { let mut process_table = pt.borrow_mut(); @@ -142,12 +142,12 @@ impl Process { assert!(!process.contexts[context - 1].allocated); process.contexts[context - 1].allocated = true; - println!( - "KERNEL({}): self.contexts[{}].allocated = {}", - current_pid_idx, - context - 1, - process.contexts[context - 1].allocated - ); + // println!( + // "KERNEL({}): self.contexts[{}].allocated = {}", + // current_pid_idx, + // context - 1, + // process.contexts[context - 1].allocated + // ); }); Ok(()) } diff --git a/kernel/src/services.rs b/kernel/src/services.rs index f3362c088..264bb178f 100644 --- a/kernel/src/services.rs +++ b/kernel/src/services.rs @@ -500,10 +500,10 @@ impl SystemServices { pid, context, other ), }; - println!( - "KERNEL({}): Readying context {} -> {:?}", - pid, context, process.state - ); + // println!( + // "KERNEL({}): Readying context {} -> {:?}", + // pid, context, process.state + // ); Ok(()) } @@ -513,13 +513,11 @@ impl SystemServices { /// /// If the current process is not running, or if it's "Running" but has no free contexts pub fn switch_to(&mut self, pid: PID, context: Option) -> Result<(), xous::Error> { - // println!("KERNEL(?): Getting current process..."); let process = self.get_process_mut(pid)?; - // println!("KERNEL(?): Current process is {:?}", process); - println!( - "switch_to({}:{:?}): Old state was {:?}", - pid, context, process.state - ); + // println!( + // "switch_to({}:{:?}): Old state was {:?}", + // pid, context, process.state + // ); // Determine which context number to switch to process.state = match process.state { @@ -620,10 +618,10 @@ impl SystemServices { ProcessState::Running(new_mask) } }; - println!( - "switch_to({}:{:?}): New state is {:?}", - pid, context, process.state - ); + // println!( + // "switch_to({}:{:?}): New state is {:?}", + // pid, context, process.state + // ); // self.pid = pid; Ok(()) } @@ -643,10 +641,10 @@ impl SystemServices { can_resume: bool, ) -> Result<(), xous::Error> { let process = self.get_process_mut(pid)?; - println!( - "switch_from({}:{}): Old state was {:?}", - pid, context, process.state - ); + // println!( + // "switch_from({}:{}): Old state was {:?}", + // pid, context, process.state + // ); process.state = match process.state { ProcessState::Running(x) if x & (1 << context) != 0 => panic!( "PID {} context {} was already queued for running when `switch_from()` was called", @@ -675,10 +673,10 @@ impl SystemServices { pid, other ), }; - println!( - "switch_from({}:{}): New state is {:?}", - pid, context, process.state - ); + // println!( + // "switch_from({}:{}): New state is {:?}", + // pid, context, process.state + // ); Ok(()) } @@ -1196,7 +1194,7 @@ impl SystemServices { // &[arg.map(|x| x.get()).unwrap_or_default() as usize], // ); - println!("KERNEL({}): Created new context {}", pid, new_context_nr); + // println!("KERNEL({}): Created new context {}", pid, new_context_nr); // Queue the thread to run process.state = match process.state { diff --git a/kernel/src/syscall.rs b/kernel/src/syscall.rs index c42552c1f..3d287acff 100644 --- a/kernel/src/syscall.rs +++ b/kernel/src/syscall.rs @@ -111,13 +111,7 @@ fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallRes let sender = match message { Message::Scalar(_) | Message::Move(_) => 0, Message::Borrow(_) | Message::MutableBorrow(_) => ss - .remember_server_message( - sidx, - pid, - thread, - &message, - client_address, - ) + .remember_server_message(sidx, pid, thread, &message, client_address) .or_else(|e| { ss.server_from_sidx(sidx) .expect("server couldn't be located") @@ -144,32 +138,20 @@ fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallRes } else if blocking && !cfg!(baremetal) { // println!("Blocking client, since it sent a blocking message"); ss.switch_to(server_pid, None)?; - ss.set_context_result( - server_pid, - ctx_number, - xous::Result::Message(envelope), - ) - .and_then(|_| ss.switch_from(pid, thread, false)) - .map(|_| xous::Result::BlockedProcess) + ss.set_context_result(server_pid, ctx_number, xous::Result::Message(envelope)) + .and_then(|_| ss.switch_from(pid, thread, false)) + .map(|_| xous::Result::BlockedProcess) } else if cfg!(baremetal) { // println!("Setting the return value of the Server and returning to Client"); - ss.set_context_result( - server_pid, - ctx_number, - xous::Result::Message(envelope), - ) - .map(|_| xous::Result::Ok) + ss.set_context_result(server_pid, ctx_number, xous::Result::Message(envelope)) + .map(|_| xous::Result::Ok) } else { // println!("Setting the return value of the Server and returning to Client"); // "Switch to" the server PID when not running on bare metal. This ensures // that it's "Running". ss.switch_to(server_pid, None)?; - ss.set_context_result( - server_pid, - ctx_number, - xous::Result::Message(envelope), - ) - .map(|_| xous::Result::Ok) + ss.set_context_result(server_pid, ctx_number, xous::Result::Message(envelope)) + .map(|_| xous::Result::Ok) } } else { // Add this message to the queue. If the queue is full, this @@ -199,10 +181,14 @@ fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallRes }) } -pub fn handle(pid: PID, tid: TID, call: SysCall) -> core::result::Result { +pub fn handle( + pid: PID, + tid: TID, + call: SysCall, +) -> core::result::Result { // let pid = arch::current_pid(); - println!("KERNEL({}): Syscall {:?}", pid, call); + // println!("KERNEL({}): Syscall {:?}", pid, call); match call { SysCall::MapMemory(phys, virt, size, req_flags) => { let mut mm = MemoryManagerHandle::get(); @@ -326,13 +312,12 @@ pub fn handle(pid: PID, tid: TID, call: SysCall) -> core::result::Result { SystemServices::with_mut(|ss| { - let context_nr = ss.current_context_nr(pid); unsafe { assert!( SWITCHTO_CALLER.is_none(), "SWITCHTO_CALLER was not None, indicating SwitchTo was called twice" ); - SWITCHTO_CALLER = Some((pid, context_nr)); + SWITCHTO_CALLER = Some((pid, tid)); } ss.activate_process_context(new_pid, new_context, true, false) .map(|_ctx| { @@ -376,7 +361,6 @@ pub fn handle(pid: PID, tid: TID, call: SysCall) -> core::result::Result { SystemServices::with_mut(|ss| { // See if there is a pending message. If so, return immediately. - let context_nr = ss.current_context_nr(pid); let sidx = ss.server_sidx(sid).ok_or(xous::Error::ServerNotFound)?; let server = ss .server_from_sidx(sidx) @@ -400,9 +384,9 @@ pub fn handle(pid: PID, tid: TID, call: SysCall) -> core::result::Result core::result::Result core::result::Result { - send_message(pid, tid, cid, message) - } + SysCall::SendMessage(cid, message) => send_message(pid, tid, cid, message), SysCall::TerminateProcess => SystemServices::with_mut(|ss| { - let context_nr = ss.current_context_nr(pid); - ss.switch_from(pid, context_nr, false)?; + ss.switch_from(pid, tid, false)?; let ppid = ss.terminate_process(pid)?; if cfg!(baremetal) { ss.switch_to(ppid, None)