added sc_sem_remove

This commit is contained in:
Samy Solhi 2023-04-12 23:00:12 +02:00
parent 19356a36d9
commit c419926a4c

View File

@ -174,7 +174,7 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result<MachineOk, Mach
SC_P => sc_p(machine, system), SC_P => sc_p(machine, system),
SC_V => sc_v(machine, system), SC_V => sc_v(machine, system),
SC_SEM_CREATE => sc_sem_create(machine, system), SC_SEM_CREATE => sc_sem_create(machine, system),
SC_SEM_DESTROY => todo!(), SC_SEM_DESTROY => sc_sem_remove(machine, system),
SC_LOCK_CREATE => todo!(), SC_LOCK_CREATE => todo!(),
SC_LOCK_DESTROY => todo!(), SC_LOCK_DESTROY => todo!(),
SC_LOCK_ACQUIRE => todo!(), SC_LOCK_ACQUIRE => todo!(),
@ -221,6 +221,12 @@ fn sc_sem_create(machine: &mut Machine, system: &mut System) -> Result<MachineOk
} }
} }
fn sc_sem_remove(machine: &mut Machine, system: &mut System) -> Result<MachineOk, MachineError>{
let id = machine.read_int_register(10) as i32;
system.get_thread_manager().get_obj_addrs().remove_semaphore(id);
Ok(MachineOk::Ok)
}
fn sc_new_thread(machine: &mut Machine, system: &mut System) -> Result<MachineOk, MachineError> { fn sc_new_thread(machine: &mut Machine, system: &mut System) -> Result<MachineOk, MachineError> {
// Get the address of the string for the name of the thread // Get the address of the string for the name of the thread
let name_addr = machine.read_int_register(10) as usize; let name_addr = machine.read_int_register(10) as usize;