diff --git a/kernel/src/arch/hosted.rs b/kernel/src/arch/hosted.rs index d9a136977..e49831d73 100644 --- a/kernel/src/arch/hosted.rs +++ b/kernel/src/arch/hosted.rs @@ -550,7 +550,6 @@ pub fn idle() -> bool { } // Handle the syscall within the Xous kernel - crate::arch::process::clear_response_sent_already(); let response = crate::syscall::handle(pid, thread_id, false, call).unwrap_or_else(Result::Error); @@ -575,18 +574,17 @@ pub fn idle() -> bool { let s = unsafe { core::slice::from_raw_parts(mem.as_ptr(), mem.len()) }; response_vec.extend_from_slice(s); } - // Send a response only if we haven't already sent one - if ! crate::arch::process::response_sent_already() { - process.send(&response_vec).unwrap_or_else(|_e| { - // If we're unable to send data to the process, assume it's dead and terminate it. - eprintln!( - "KERNEL({}): Unable to send response to process: {:?} -- terminating", - pid, _e - ); - crate::syscall::handle(pid, thread_id, false, SysCall::TerminateProcess).ok(); - }); - } + process.send(&response_vec).unwrap_or_else(|_e| { + // If we're unable to send data to the process, assume it's dead and terminate it. + eprintln!( + "KERNEL({}): Unable to send response to process: {:?} -- terminating", + pid, _e + ); + crate::syscall::handle(pid, thread_id, false, SysCall::TerminateProcess).ok(); + }); crate::arch::process::set_current_pid(existing_pid); + // SystemServices::with_mut(|ss| { + // ss.switch_from(pid, 1, true)}).unwrap(); } if is_shutdown { diff --git a/kernel/src/arch/hosted/process.rs b/kernel/src/arch/hosted/process.rs index 530633c11..bf35cea02 100644 --- a/kernel/src/arch/hosted/process.rs +++ b/kernel/src/arch/hosted/process.rs @@ -27,9 +27,6 @@ struct ProcessImpl { /// Memory that may need to be returned to the caller for each thread memory_to_return: [Option>; MAX_THREAD + 1], - /// We've already sent a response, so don't send another one - response_sent: bool, - /// This enables the kernel to keep track of threads in the /// target process, and know which threads are ready to /// receive messages. @@ -61,27 +58,9 @@ thread_local!( current: unsafe { PID::new_unchecked(1) }, total: 0, table: Vec::new(), - }); + }) ); -pub fn response_sent_already() -> bool { - PROCESS_TABLE.with(|pt| { - let mut process_table = pt.borrow_mut(); - let current_pid_idx = process_table.current.get() as usize - 1; - let process = &mut process_table.table[current_pid_idx].as_mut().unwrap(); - process.response_sent - }) -} - -pub fn clear_response_sent_already() { - PROCESS_TABLE.with(|pt| { - let mut process_table = pt.borrow_mut(); - let current_pid_idx = process_table.current.get() as usize - 1; - let process = &mut process_table.table[current_pid_idx].as_mut().unwrap(); - process.response_sent = false; - }) -} - pub fn current_pid() -> PID { PROCESS_TABLE.with(|pt| pt.borrow().current) } @@ -320,10 +299,22 @@ impl Process { if result.memory().is_some() { panic!("Result has memory and we're also returning memory!"); } + // if let xous_kernel::Result::Message(_) = result { + // } else { + // panic!( + // "memory was waiting to be returned, but message was not a result message" + // ); + // } + print!(" [adding {} additional bytes from memory being returned]", buf.len()); response.extend_from_slice(&buf); } - process.response_sent = true; + // eprintln!( + // "KERNEL({}): Setting thread return value to {:?}", + // current_pid_idx + 1, + // response + // ); + print!(" [setting thread return value to {} bytes]", response.len()); process .conn .as_mut() @@ -356,7 +347,6 @@ impl Process { conn: None, key: init_data.key, memory_to_return: filled_array![None; 32 /* MAX_THREAD */], - response_sent: false, current_thread: INITIAL_TID, threads: [Thread { allocated: false }; MAX_THREAD + 1], };