started to implement sc_sem_create and auxiliar function
This commit is contained in:
parent
41611b54e8
commit
77086155b5
@ -105,7 +105,13 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result<MachineOk, Mach
|
||||
SC_PERROR => 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<MachineOk, Mach
|
||||
}
|
||||
}
|
||||
|
||||
fn get_length_param(addr: usize, machine: & Machine) -> 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};
|
||||
|
Loading…
Reference in New Issue
Block a user