Remove old static vars in scheduler, doesn't work

This commit is contained in:
Quentin Legot 2023-03-08 16:05:05 +01:00 committed by François Autin
parent 75e5c17f28
commit 3406544e3b
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C

View File

@ -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<Rc<Thread>>
@ -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<System>, next_thread: Thread) {
/* if let Some(old_thread) = system.get_g_current_thread() {
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);
}
system.set_g_current_thread(Option::Some(next_thread));
}
} */
}
}