Remove old static vars in scheduler, doesn't work

This commit is contained in:
Quentin Legot 2023-03-08 16:05:05 +01:00
parent f15d782916
commit 0f5eb84c7b

View File

@ -1,8 +1,10 @@
use std::{sync::Arc, rc::Rc}; use std::rc::Rc;
use crate::utility::list::List; use crate::utility::list::List;
use crate::kernel::thread::Thread; use crate::kernel::thread::Thread;
use super::system::System;
#[derive(PartialEq)] #[derive(PartialEq)]
pub struct Scheduler { pub struct Scheduler {
ready_list: List<Rc<Thread>> ready_list: List<Rc<Thread>>
@ -50,34 +52,16 @@ impl Scheduler {
/// ## Parameter /// ## Parameter
/// ///
/// **next_thread** thread to dispatch to the CPU /// **next_thread** thread to dispatch to the CPU
pub fn switch_to(&self, next_thread: Thread) { pub fn switch_to(&self, system: Rc<System>, next_thread: Thread) {
match G_CURRENT_THREAD.write() { /* if let Some(old_thread) = system.get_g_current_thread() {
Ok(mut current_thread) => { old_thread.save_processor_state();
let old_thread = current_thread.as_mut().unwrap(); old_thread.save_simulator_state();
old_thread.save_processor_state(); if old_thread != &next_thread {
old_thread.save_simulator_state(); next_thread.restore_processor_state();
next_thread.restore_simulator_state();
if old_thread != &next_thread { system.set_g_current_thread(Option::Some(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);
} }
} } */
} }
} }