From ba895e3587778177f3a827d5dda08644a5e8bd46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rativel?= Date: Tue, 14 Mar 2023 16:44:10 +0100 Subject: [PATCH] Small fix with not matching types --- src/kernel/synch.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/kernel/synch.rs b/src/kernel/synch.rs index 3828d3a..15996ac 100644 --- a/src/kernel/synch.rs +++ b/src/kernel/synch.rs @@ -24,6 +24,11 @@ pub struct Semaphore { impl Semaphore { + /// Initializes a semaphore, so that it can be used for synchronization. + /// + /// ### Parameters + /// - *counter* initial value of counter + /// - *thread_manager* Thread manager which managing threads pub fn new(counter: i32, thread_manager: Rc>) -> Semaphore{ Semaphore { counter, waiting_queue: List::new(), thread_manager} } @@ -153,7 +158,10 @@ impl Lock { } pub fn held_by_current_thread(&mut self, current_thread: Rc>) -> bool { - Rc::ptr_eq(&self.owner, ¤t_thread) + match &self.owner { + Some(x) => Rc::ptr_eq(&x, ¤t_thread), + None => false + } } }