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>) {