From aba2fbc718722275bf8417b6601a05cc7f6c6b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Autin?= Date: Thu, 20 Apr 2023 14:50:44 +0200 Subject: [PATCH] Updated lock_release to update lock in objaddr list --- src/kernel/thread_manager.rs | 3 ++- src/utility/objaddr.rs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/kernel/thread_manager.rs b/src/kernel/thread_manager.rs index b7ae47d..962b3f4 100644 --- a/src/kernel/thread_manager.rs +++ b/src/kernel/thread_manager.rs @@ -373,6 +373,7 @@ impl ThreadManager { } } }; + self.get_obj_addrs().update_lock(id, lock); machine.interrupt.set_status(old_status); Ok(MachineOk::Ok) } @@ -464,7 +465,7 @@ mod test { { let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap(); assert_eq!(lock.owner, None); - assert!(!lock.free); + assert!(lock.free); assert!(lock.waiting_queue.is_empty()); } } diff --git a/src/utility/objaddr.rs b/src/utility/objaddr.rs index e788eb0..42ad0a5 100644 --- a/src/utility/objaddr.rs +++ b/src/utility/objaddr.rs @@ -66,6 +66,11 @@ impl ObjAddr { 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 pub fn search_thread(&mut self, id: i32) -> Option<&Rc>> { self.threads.get(&id)