From 3406544e3bd4ed0ef8e81f7efa63cc5ed98fc9e8 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Wed, 8 Mar 2023 16:05:05 +0100 Subject: [PATCH] Remove old static vars in scheduler, doesn't work --- src/kernel/scheduler.rs | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/src/kernel/scheduler.rs b/src/kernel/scheduler.rs index 670f0fa..0398799 100644 --- a/src/kernel/scheduler.rs +++ b/src/kernel/scheduler.rs @@ -1,8 +1,10 @@ -use std::{sync::Arc, rc::Rc}; +use std::rc::Rc; use crate::utility::list::List; use crate::kernel::thread::Thread; +use super::system::System; + #[derive(PartialEq)] pub struct Scheduler { ready_list: List> @@ -50,34 +52,16 @@ impl Scheduler { /// ## Parameter /// /// **next_thread** thread to dispatch to the CPU - pub fn switch_to(&self, next_thread: Thread) { - match G_CURRENT_THREAD.write() { - Ok(mut current_thread) => { - let old_thread = current_thread.as_mut().unwrap(); + pub fn switch_to(&self, system: Rc, next_thread: Thread) { + /* if let Some(old_thread) = system.get_g_current_thread() { + old_thread.save_processor_state(); + old_thread.save_simulator_state(); - old_thread.save_processor_state(); - old_thread.save_simulator_state(); - - if old_thread != &next_thread { - next_thread.restore_processor_state(); - next_thread.restore_simulator_state(); - current_thread.replace(next_thread); - } - - match G_THREAD_TO_BE_DESTROYED.write() { - Ok(mut thread_to_be_destroyed) => { - if thread_to_be_destroyed.is_some() { - drop(thread_to_be_destroyed.take()); - } - }, - Err(err) => { - panic!("RwLock is poisonned: {}", err); - } - } - }, - Err(err) => { - panic!("RwLock is poisonned: {}", err); + if old_thread != &next_thread { + next_thread.restore_processor_state(); + next_thread.restore_simulator_state(); + system.set_g_current_thread(Option::Some(next_thread)); } - } + } */ } } \ No newline at end of file