From 8b5ad2657b6d6ab2c41634b2e7515bf2af2fe14e Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 31 Mar 2022 01:10:58 +0800 Subject: [PATCH] an aborted attempt at doing a clean-shutdown for hosted mode This doesn't work because the shutdown call destroys all the servers then terminates the processes. But, the problem is that the processes are still running, but servers are disappearing. So what you end up with is a panic when the first message gets delivered to a server that no longer exists, and then you end up with the program hanging on that panic because some servers haven't been destroyed/exited yet and are now just spinning waiting to be scheduled. so the call works in the tidy kernel test cases but to get it to work on a full OS you'd need to have a way to put every server into an eternal blocking state before making the shutdown call (to prevent new messages from being issued while servers are going away), which is more work than i'm willing to put into the problem right now. --- services/pddb/src/tests.rs | 11 +++++++++++ services/susres/src/main.rs | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/services/pddb/src/tests.rs b/services/pddb/src/tests.rs index 38a2f692b..c86a3eb88 100644 --- a/services/pddb/src/tests.rs +++ b/services/pddb/src/tests.rs @@ -546,6 +546,17 @@ pub(crate) fn ci_tests(pddb_os: &mut PddbOs) -> Result<()> { list_all(pddb_os, &mut basis_cache); log::info!("CI done"); + + /* + // abortive attempt to get CI to exit cleanly + #[cfg(not(any(target_os = "none", target_os = "xous")))] + { + let xns = xous_names::XousNames::new().unwrap(); + let susres = susres::Susres::new_without_hook(&xns).unwrap(); + susres.initiate_suspend().expect("couldn't initiate suspend op"); + //xous::rsyscall(xous::SysCall::Shutdown).expect("unable to quit"); + }*/ + Ok(()) } } \ No newline at end of file diff --git a/services/susres/src/main.rs b/services/susres/src/main.rs index 203239bfe..35e16682f 100644 --- a/services/susres/src/main.rs +++ b/services/susres/src/main.rs @@ -835,6 +835,14 @@ fn unhook(cb_conns: &mut Vec::) { fn send_event(cb_conns: &Vec::, order: crate::api::SuspendOrder) -> (bool, crate::api::SuspendOrder) { let mut at_least_one_event_sent = false; log::info!("Sending suspend to {:?} stage", order); + /* + // abortive attempt to get suspend to shut down the system. Doesn't work, results in a panic because too many messages are still moving around. + #[cfg(not(any(target_os = "none", target_os = "xous")))] + { + if order == crate::api::SuspendOrder::Last { + xous::rsyscall(xous::SysCall::Shutdown).expect("unable to quit"); + } + }*/ for scb in cb_conns.iter() { if scb.order == order { at_least_one_event_sent = true;