From 4faa315591a730fce6f2ab0654acddfe292cb159 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Wed, 26 Apr 2023 15:52:31 +0200 Subject: [PATCH] Use broadcast in Cond, for now. --- src/sync/cond.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sync/cond.rs b/src/sync/cond.rs index 750dc14083..4942653e61 100644 --- a/src/sync/cond.rs +++ b/src/sync/cond.rs @@ -1,3 +1,5 @@ +// Used design from https://www.remlab.net/op/futex-condvar.shtml + use crate::header::pthread::*; use crate::header::bits_pthread::*; use crate::header::time::timespec; @@ -28,7 +30,8 @@ impl Cond { self.wake(i32::MAX) } pub fn signal(&self) -> Result<(), Errno> { - self.wake(1) + self.broadcast() + //self.wake(1) } pub fn timedwait(&self, mutex: &RlctMutex, timeout: ×pec) -> Result<(), Errno> { self.wait_inner(mutex, Some(timeout)) @@ -37,7 +40,7 @@ impl Cond { // TODO: Error checking for certain types (i.e. robust and errorcheck) of mutexes, e.g. if the // mutex is not locked. let current = self.cur.load(Ordering::Relaxed); - self.prev.store(current, Ordering::Relaxed); // TODO: ordering? + self.prev.store(current, Ordering::Relaxed); mutex.unlock();