Removed Rc<RefCell<Machine>>

This commit is contained in:
François Autin
2023-03-15 14:56:05 +01:00
parent 84d8bcc84f
commit abb97d17d5
2 changed files with 14 additions and 14 deletions

View File

@ -69,7 +69,7 @@ impl ThreadManager {
pub fn thread_yield(&mut self, thread: Rc<RefCell<Thread>>) {
if let Some(system) = &self.system {
let sys = system.borrow_mut();
let mut machine = sys.get_g_machine().borrow_mut();
let mut machine = sys.get_machine();
let old_status = machine.interrupt.set_status(crate::simulator::interrupt::InterruptStatus::InterruptOff);
assert_eq!(Option::Some(Rc::clone(&thread)), self.g_current_thread);
@ -89,7 +89,7 @@ impl ThreadManager {
assert_eq!(Option::Some(Rc::clone(&thread)), self.g_current_thread);
if let Some(system) = &self.system {
let sys = system.borrow_mut();
let machine = sys.get_g_machine().borrow_mut();
let machine = sys.get_machine();
assert_eq!(machine.interrupt.get_status(), InterruptStatus::InterruptOff);
let mut next_thread = self.g_scheduler.find_next_to_run();
@ -108,7 +108,7 @@ impl ThreadManager {
if let Some(system) = &self.system {
let sys = Rc::clone(system);
let sys = sys.borrow_mut();
let mut machine = sys.get_g_machine().borrow_mut();
let mut machine = sys.get_machine();
let old_status = machine.interrupt.set_status(InterruptStatus::InterruptOff);
self.g_thread_to_be_destroyed = Option::Some(Rc::clone(&thread));
self.g_alive.remove(Rc::clone(&thread));
@ -121,12 +121,12 @@ impl ThreadManager {
pub fn thread_save_processor_state(&mut self, thread: Rc<RefCell<Thread>>) {
if let Some(system) = &self.system {
let mut t: RefMut<_> = thread.borrow_mut();
let system = system.borrow_mut();
let system = system;
for i in 0..NUM_INT_REGS {
t.thread_context.int_registers[i] = system.get_g_machine().borrow().read_int_register(i);
t.thread_context.int_registers[i] = system.get_machine().read_int_register(i);
}
for i in 0..NUM_FP_REGS {
t.thread_context.float_registers[i] = system.get_g_machine().borrow().read_fp_register(i);
t.thread_context.float_registers[i] = system.get_machine().read_fp_register(i);
}
} else {
unreachable!("System is None")
@ -138,8 +138,8 @@ impl ThreadManager {
let system = system.borrow_mut();
let t: Ref<_> = thread.borrow();
for i in 0..NUM_INT_REGS {
let machine = system.get_g_machine();
let mut machine = machine.borrow_mut();
let machine = system.get_machine();
let mut machine = machine;
machine.write_int_register(i, t.thread_context.int_registers[i]);
}
} else {