Merge branch 'thread_scheduler' of gitlab.istic.univ-rennes1.fr:simpleos/burritos into thread_scheduler
This commit is contained in:
commit
02dd1f5ccf
@ -172,7 +172,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!(),
|
||||
@ -196,6 +202,35 @@ 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
|
||||
}
|
||||
|
||||
fn get_string_param(addr: i64, maxlen: i64, machine: &Machine) -> Vec<char>{
|
||||
let mut dest = Vec::with_capacity(maxlen as usize);
|
||||
|
||||
let mut i = 0;
|
||||
let mut c = 1;
|
||||
|
||||
while c != 0 && i < maxlen {
|
||||
c = machine.read_memory(1, (addr + i) as usize);
|
||||
//dest.push(c as char);
|
||||
dest[i] = c as char;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
dest[maxlen - 1] = '\0';
|
||||
|
||||
dest
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::kernel::exception::{SC_SHUTDOWN, SC_WRITE};
|
||||
@ -241,7 +276,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();
|
||||
machine.run(&mut system);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user