1
0
forked from Rativel/BurritOS

Add debug field to thread_manager and tried to fix sc_join (not worked :-( )

This commit is contained in:
Quentin Legot
2023-04-13 02:05:21 +02:00
parent f144438490
commit 232617c32e
6 changed files with 44 additions and 35 deletions

View File

@@ -286,14 +286,15 @@ fn sc_join(machine: &mut Machine, system: &mut System) -> Result<MachineOk, Mach
let tid = machine.read_int_register(10);
let p_thread = system.get_thread_manager().get_obj_addrs().search_thread(tid as i32);
match p_thread {
Some(_) => {
Some(waiting_for) => {
let rc_waiting_for = Rc::clone(waiting_for);
if let Some(current_thread) = system.get_thread_manager().get_g_current_thread() {
let rc = Rc::clone(current_thread);
system.get_thread_manager().thread_join(machine, rc);
let rc_curr = Rc::clone(current_thread);
system.get_thread_manager().thread_join(machine, rc_curr, rc_waiting_for);
Ok(MachineOk::Ok)
} else {
Ok(MachineOk::Ok)
Err("Current should not be None")?
}
},
None => {
@@ -347,7 +348,7 @@ mod test {
machine.write_memory(4, 0, 0b000000000000_00000_000_00000_1110011); // ecall
machine.write_memory(4, 4, 0b000000001010_00000_000_00001_0010011); // r1 <- 10
let mut system = System::default();
let mut system = System::new(true);
machine.run(&mut system);
// If the machine was stopped with no error, the shutdown worked
assert_ne!(machine.read_int_register(1), 10); // Check if the next instruction was executed
@@ -378,7 +379,7 @@ mod test {
machine.write_memory(4, 4, 0b000000000000_00000_000_10001_0010011); // r17 <- SC_SHUTDOWN
machine.write_memory(4, 8, 0b000000000000_00000_000_00000_1110011); // ecall
let mut system = System::default();
let mut system = System::new(true);
machine.run(&mut system);
}