git: 3c6f63902b03 - main - pthread_cond_wait.3: describe spurious wakeups

Konstantin Belousov <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a678373.1dc99.30c0735b__29677.5514188752$1785168778$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=3c6f63902b037e36648fae435d4d5f56f9dc389b

commit 3c6f63902b037e36648fae435d4d5f56f9dc389b
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2026-07-25 20:02:24 +0000
Commit:     Konstantin Belousov <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.