Updated lock_release to update lock in objaddr list

This commit is contained in:
François Autin 2023-04-20 14:50:44 +02:00
parent c33df28307
commit aba2fbc718
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C
2 changed files with 7 additions and 1 deletions

View File

@ -373,6 +373,7 @@ impl ThreadManager {
} }
} }
}; };
self.get_obj_addrs().update_lock(id, lock);
machine.interrupt.set_status(old_status); machine.interrupt.set_status(old_status);
Ok(MachineOk::Ok) Ok(MachineOk::Ok)
} }
@ -464,7 +465,7 @@ mod test {
{ {
let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap(); let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap();
assert_eq!(lock.owner, None); assert_eq!(lock.owner, None);
assert!(!lock.free); assert!(lock.free);
assert!(lock.waiting_queue.is_empty()); assert!(lock.waiting_queue.is_empty());
} }
} }

View File

@ -66,6 +66,11 @@ impl ObjAddr {
self.locks.get_mut(&id) self.locks.get_mut(&id)
} }
/// Update lock at given id
pub fn update_lock(&mut self, id: i32, lock: Lock) {
self.locks.insert(id, lock);
}
/// Searches for a lock of id **id** in self /// Searches for a lock of id **id** in self
pub fn search_thread(&mut self, id: i32) -> Option<&Rc<RefCell<Thread>>> { pub fn search_thread(&mut self, id: i32) -> Option<&Rc<RefCell<Thread>>> {
self.threads.get(&id) self.threads.get(&id)