forked from Rativel/BurritOS
Fix a lot of errors
This commit is contained in:
@@ -198,34 +198,37 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result<MachineOk, Mach
|
||||
}
|
||||
}
|
||||
|
||||
fn sc_p(machine: &mut Machine, system: &mut System) -> Result<(), Error> {
|
||||
fn sc_p(machine: &mut Machine, system: &mut System) -> Result<MachineOk, MachineError> {
|
||||
let id_sema = machine.int_reg.get_reg(10);
|
||||
match system.get_obj_addrs().search_semaphore(id_sema) {
|
||||
Some(sema) => { sema.p(machine, system.get_thread_manager()); Ok(()) }
|
||||
None => Err(format!("Coudn't find semaphore {}", id_sema))
|
||||
match system.get_obj_addrs().search_semaphore(id_sema as i32) {
|
||||
Some(sema) => { sema.p(machine, system.get_thread_manager()); Ok(MachineOk::Ok) }
|
||||
None => Err(format!("Coudn't find semaphore {}", id_sema))?
|
||||
}
|
||||
}
|
||||
|
||||
fn sc_v(machine: &mut Machine, system: &mut System) -> Result<(), Error> {
|
||||
fn sc_v(machine: &mut Machine, system: &mut System) -> Result<MachineOk, MachineError> {
|
||||
let id_sema = machine.int_reg.get_reg(10);
|
||||
match system.get_obj_addrs().search_semaphore(id_sema) {
|
||||
Some(sema) => { sema.v(machine, system.get_thread_manager()); Ok(()) },
|
||||
None => Err(format!("Couldn't find semaphore {}", id_sema))
|
||||
match system.get_obj_addrs().search_semaphore(id_sema as i32) {
|
||||
Some(sema) => {
|
||||
sema.v(machine, system.get_thread_manager());
|
||||
Ok(MachineOk::Ok)
|
||||
},
|
||||
None => Err(format!("Couldn't find semaphore {}", id_sema))?
|
||||
}
|
||||
}
|
||||
|
||||
fn sc_sem_create(machine: &mut Machine) -> Result<(), Error> {
|
||||
fn sc_sem_create(machine: &mut Machine) -> Result<MachineOk, MachineError> {
|
||||
let addr_name = machine.read_int_register(10) as usize;
|
||||
let initial_count = machine.read_int_register(11);
|
||||
let size = get_length_param(addr_name as usize, machine);
|
||||
let _name = get_string_param(addr_name, size, machine);
|
||||
match initial_count < 0 {
|
||||
true => Err(format!("Initial_count < 0")),
|
||||
false => Ok(())
|
||||
true => Err(format!("Initial_count < 0"))?,
|
||||
false => Ok(MachineOk::Ok)
|
||||
}
|
||||
}
|
||||
|
||||
fn sc_new_thread(machine: &mut Machine, system: &mut System) -> Result<(), Error> {
|
||||
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
|
||||
let name_addr = machine.read_int_register(10) as usize;
|
||||
// Get the pointer of the function to be executed in the new thread
|
||||
|
||||
Reference in New Issue
Block a user