From 88a0b31300eac40b240ffda0608183e953052886 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Tue, 14 Mar 2023 22:01:52 +0100 Subject: [PATCH] Add thread_finish --- src/kernel/thread_manager.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/kernel/thread_manager.rs b/src/kernel/thread_manager.rs index 0c65b85..db53e8f 100644 --- a/src/kernel/thread_manager.rs +++ b/src/kernel/thread_manager.rs @@ -103,8 +103,18 @@ impl ThreadManager { } /// Finish the execution of the thread and prepare its deallocation - pub fn thread_finish(&self, thread: Rc>) { - todo!(); + pub fn thread_finish(&mut self, thread: Rc>) { + if let Some(system) = &self.system { + let sys = Rc::clone(system); + let sys = sys.borrow_mut(); + let mut machine = sys.get_g_machine().borrow_mut(); + let old_status = machine.interrupt.set_status(InterruptStatus::InterruptOff); + self.g_thread_to_be_destroyed = Option::Some(Rc::clone(&thread)); + self.g_alive.remove(Rc::clone(&thread)); + // g_objets_addrs->removeObject(self.thread) // a ajouté plus tard + self.thread_sleep(Rc::clone(&thread)); + machine.interrupt.set_status(old_status); + } } pub fn thread_save_processor_state(&mut self, thread: Rc>) {