From 77086155b5ecc5802475669efeabaa1d5ef78a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rativel?= Date: Wed, 5 Apr 2023 15:47:46 +0200 Subject: [PATCH] started to implement sc_sem_create and auxiliar function --- src/kernel/exception.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/kernel/exception.rs b/src/kernel/exception.rs index b020f6e..bb99263 100644 --- a/src/kernel/exception.rs +++ b/src/kernel/exception.rs @@ -105,7 +105,13 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result todo!(), SC_P => todo!(), SC_V => todo!(), - SC_SEM_CREATE => todo!(), + SC_SEM_CREATE => { + let addr_name = machine.read_int_register(10); + let initial_count = machine.read_int_register((11)); + let size = get_length_param(addr_name as usize, machine); + Ok(MachineOk::Ok) + + }, SC_SEM_DESTROY => todo!(), SC_LOCK_CREATE => todo!(), SC_LOCK_DESTROY => todo!(), @@ -129,6 +135,17 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result usize{ + let mut i = 0; + let mut c = 1; + while c!= 0 { + c = machine.read_memory(1, addr + i); + i+=1; + + } + i + 1 +} + #[cfg(test)] mod test { use crate::kernel::exception::{SC_SHUTDOWN, SC_WRITE};