Add debug message and debug_assert

This commit is contained in:
Quentin Legot 2023-04-13 02:10:09 +02:00
parent 232617c32e
commit 3244584da9

View File

@ -79,6 +79,7 @@ impl ThreadManager {
self.debug(format!("switching from \"{}\" to \"{}\"", old2.borrow().get_name(), next_thread.borrow().get_name())); 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)); self.thread_restore_processor_state(machine, Rc::clone(&next_thread));
// next_thread.restore_simulator_state(); // next_thread.restore_simulator_state();
debug_assert!(!self.ready_list.contains(&next_thread));
self.set_g_current_thread(Some(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<RefCell<Thread>>, waiting_for: Rc<RefCell<Thread>>) { pub fn thread_join(&mut self, machine: &mut Machine, waiter: Rc<RefCell<Thread>>, waiting_for: Rc<RefCell<Thread>>) {
let waiting_for = Rc::clone(&waiting_for); let waiting_for = Rc::clone(&waiting_for);
while self.get_g_alive().contains(&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)); self.thread_yield(machine, Rc::clone(&waiter));
} }
} }