From feb0bdd159a8d79b576db68a4bb8562cb33aea63 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Sun, 24 Dec 2023 17:23:30 +0800 Subject: [PATCH] xous: thread_parking: fix logic on wakeup race When waking up a thread and there's a race condition, the logic may be inverted. Or the thread may time out, in which case there is no thread to wake up. Signed-off-by: Sean Cross --- library/std/src/sys/xous/thread_parking.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/xous/thread_parking.rs b/library/std/src/sys/xous/thread_parking.rs index ec1b6d8c79968..872a4f112d551 100644 --- a/library/std/src/sys/xous/thread_parking.rs +++ b/library/std/src/sys/xous/thread_parking.rs @@ -83,7 +83,8 @@ impl Parker { TicktimerScalar::NotifyCondition(self.index(), 1).into(), ) .expect("failed to send NotifyCondition command")[0] - == 1 + != 1 + && self.state.load(Acquire) != EMPTY { // The target thread hasn't yet hit the `WaitForCondition` call. // Yield to let the target thread run some more.