From 3244584da9ff22a55923c3c0357917462d948680 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Thu, 13 Apr 2023 02:10:09 +0200 Subject: [PATCH] Add debug message and debug_assert --- src/kernel/thread_manager.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kernel/thread_manager.rs b/src/kernel/thread_manager.rs index 6878c63..870a9fc 100644 --- a/src/kernel/thread_manager.rs +++ b/src/kernel/thread_manager.rs @@ -79,6 +79,7 @@ impl ThreadManager { self.debug(format!("switching from \"{}\" to \"{}\"", old2.borrow().get_name(), next_thread.borrow().get_name())); self.thread_restore_processor_state(machine, Rc::clone(&next_thread)); // next_thread.restore_simulator_state(); + debug_assert!(!self.ready_list.contains(&next_thread)); self.set_g_current_thread(Some(next_thread)); } }, @@ -111,6 +112,7 @@ impl ThreadManager { pub fn thread_join(&mut self, machine: &mut Machine, waiter: Rc>, waiting_for: Rc>) { let waiting_for = Rc::clone(&waiting_for); while self.get_g_alive().contains(&waiting_for) { + self.debug(format!("Joining \"{}\" to \"{}\"", waiter.borrow().get_name(), waiting_for.borrow().get_name())); self.thread_yield(machine, Rc::clone(&waiter)); } }