Fix scheduler switch_to by making a lot of change(use smart pointers in place of lifetime reference)
This commit is contained in:
@@ -9,15 +9,15 @@ use std::rc::Rc;
|
||||
use super::scheduler::Scheduler;
|
||||
use super::thread_manager::ThreadManager;
|
||||
|
||||
pub struct Semaphore<'t> {
|
||||
pub struct Semaphore {
|
||||
|
||||
counter:i32,
|
||||
waiting_queue:List<Rc<RefCell<Thread>>>,
|
||||
thread_manager: Rc<RefCell<ThreadManager<'t>>> // On s'assure que le tm vit plus longtemps que les semaphore avec le lifetime
|
||||
thread_manager: Rc<RefCell<ThreadManager>> // On s'assure que le tm vit plus longtemps que les semaphore avec le lifetime
|
||||
|
||||
}
|
||||
|
||||
impl<'t> Semaphore<'_> {
|
||||
impl Semaphore {
|
||||
|
||||
pub fn p(&mut self, current_thread: Rc<RefCell<Thread>>, machine: &mut Machine){
|
||||
let old_status = machine.interrupt.set_status(InterruptOff);
|
||||
@@ -39,16 +39,16 @@ impl<'t> Semaphore<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Lock<'t>{
|
||||
pub struct Lock{
|
||||
|
||||
owner: Rc<RefCell<Thread>>,
|
||||
waiting_queue:List<Rc<RefCell<Thread>>>,
|
||||
thread_manager: Rc<RefCell<ThreadManager<'t>>>,
|
||||
thread_manager: Rc<RefCell<ThreadManager>>,
|
||||
free: bool
|
||||
|
||||
}
|
||||
|
||||
impl<'t> Lock<'_> {
|
||||
impl Lock {
|
||||
pub fn acquire(&mut self, machine: &mut Machine, current_thread: Rc<RefCell<Thread>>) {
|
||||
let old_status = machine.interrupt.set_status(InterruptOff);
|
||||
|
||||
@@ -83,14 +83,14 @@ impl<'t> Lock<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Condition<'t>{
|
||||
pub struct Condition{
|
||||
|
||||
waiting_queue:List<Rc<RefCell<Thread>>>,
|
||||
thread_manager: Rc<RefCell<ThreadManager<'t>>>,
|
||||
thread_manager: Rc<RefCell<ThreadManager>>,
|
||||
|
||||
}
|
||||
|
||||
impl<'t> Condition<'_> {
|
||||
impl Condition {
|
||||
|
||||
pub fn wait(&mut self, machine: &mut Machine, current_thread: Rc<RefCell<Thread>>) {
|
||||
let old_status = machine.interrupt.set_status(InterruptOff);
|
||||
|
||||
Reference in New Issue
Block a user