git: 3c6f63902b03 - main - pthread_cond_wait.3: describe spurious wakeups
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 27 Jul 2026 16:12:35 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=3c6f63902b037e36648fae435d4d5f56f9dc389b
commit 3c6f63902b037e36648fae435d4d5f56f9dc389b
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-07-25 20:02:24 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-07-27 16:12:12 +0000
pthread_cond_wait.3: describe spurious wakeups
Reviewed by: markc
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58458
---
share/man/man3/pthread_cond_wait.3 | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/share/man/man3/pthread_cond_wait.3 b/share/man/man3/pthread_cond_wait.3
index c09e7aa68738..d26602c69cfc 100644
--- a/share/man/man3/pthread_cond_wait.3
+++ b/share/man/man3/pthread_cond_wait.3
@@ -45,13 +45,26 @@ variable specified by
.Fa cond ,
and releases the mutex specified by
.Fa mutex .
-The waiting thread unblocks only after another thread calls
+The waiting thread unblocks after another thread calls
.Xr pthread_cond_signal 3 ,
or
.Xr pthread_cond_broadcast 3
with the same condition variable, and the current thread reacquires the lock
on
.Fa mutex .
+.Pp
+It is possible that the
+.Fn pthread_cond_wait
+function returns without corresponding wakeup from either
+.Fn pthread_cond_signal
+or
+.Fn pthread_cond_broadcast .
+Such condition is called spurious wakeup, and is allowed by
+.St -p1003.1-96 .
+Applications should have a boolean expression used for each wait
+on the condition variable, and recheck it after return from the
+.Fn pthread_cond_wait
+function.
.Sh RETURN VALUES
If successful, the
.Fn pthread_cond_wait