write semaphore id in machine on creation
This commit is contained in:
parent
c419926a4c
commit
6c3655bd78
@ -1,7 +1,7 @@
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use crate::{simulator::{machine::{ExceptionType, Machine}, error::{MachineOk, MachineError}}};
|
||||
use crate::kernel::synch::Semaphore;
|
||||
use crate::kernel::synch::{Lock, Semaphore};
|
||||
|
||||
use super::{system::System, thread::Thread};
|
||||
|
||||
@ -215,7 +215,8 @@ fn sc_sem_create(machine: &mut Machine, system: &mut System) -> Result<MachineOk
|
||||
match initial_count < 0 {
|
||||
true => Err(format!("Initial_count < 0"))?,
|
||||
false => {
|
||||
system.get_thread_manager().get_obj_addrs().add_semaphore(Semaphore::new(initial_count));
|
||||
let id = system.get_thread_manager().get_obj_addrs().add_semaphore(Semaphore::new(initial_count));
|
||||
machine.write_int_register(10, id as i64);
|
||||
Ok(MachineOk::Ok)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user