added lock create and destroy system calls
This commit is contained in:
parent
6c3655bd78
commit
6e6d3424f5
@ -175,8 +175,8 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result<MachineOk, Mach
|
|||||||
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 => sc_sem_remove(machine, system),
|
SC_SEM_DESTROY => sc_sem_remove(machine, system),
|
||||||
SC_LOCK_CREATE => todo!(),
|
SC_LOCK_CREATE => sc_lock_create(machine, system),
|
||||||
SC_LOCK_DESTROY => todo!(),
|
SC_LOCK_DESTROY => sc_lock_destroy(machine, system),
|
||||||
SC_LOCK_ACQUIRE => todo!(),
|
SC_LOCK_ACQUIRE => todo!(),
|
||||||
SC_LOCK_RELEASE => todo!(),
|
SC_LOCK_RELEASE => todo!(),
|
||||||
SC_COND_CREATE => todo!(),
|
SC_COND_CREATE => todo!(),
|
||||||
@ -197,6 +197,22 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result<MachineOk, Mach
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn sc_lock_create(machine: &mut Machine, system: &mut System) -> Result<MachineOk, MachineError> {
|
||||||
|
let addr_name = machine.read_int_register(10) as usize;
|
||||||
|
let size = get_length_param(addr_name, &machine);
|
||||||
|
let _name = get_string_param(addr_name, size, machine);
|
||||||
|
let lock = Lock::new();
|
||||||
|
let id = system.get_thread_manager().get_obj_addrs().add_lock(lock);
|
||||||
|
machine.write_int_register(10, id as i64);
|
||||||
|
Ok(MachineOk::Ok)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sc_lock_destroy(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_lock(id);
|
||||||
|
Ok(MachineOk::Ok)
|
||||||
|
}
|
||||||
|
|
||||||
fn sc_p(machine: &mut Machine, system: &mut System) -> Result<MachineOk, MachineError> {
|
fn sc_p(machine: &mut Machine, system: &mut System) -> Result<MachineOk, MachineError> {
|
||||||
let id_sema = machine.int_reg.get_reg(10);
|
let id_sema = machine.int_reg.get_reg(10);
|
||||||
system.get_thread_manager().sem_p(id_sema as i32, machine)
|
system.get_thread_manager().sem_p(id_sema as i32, machine)
|
||||||
|
Loading…
Reference in New Issue
Block a user