Remove old static vars in scheduler, doesn't work
This commit is contained in:
parent
f15d782916
commit
0f5eb84c7b
@ -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();
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user