Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Jul 2026 02:53:38 +0000
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 26cad57094d1 - stable/15 - pthread_cond_wait.3: describe spurious wakeups
Message-ID:  <6a6abcb2.1d469.2a52855c@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=26cad57094d1088ddb94abb64b2c2eb7dc91f0f6

commit 26cad57094d1088ddb94abb64b2c2eb7dc91f0f6
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-07-25 20:02:24 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-07-30 02:50:49 +0000

    pthread_cond_wait.3: describe spurious wakeups
    
    (cherry picked from commit 3c6f63902b037e36648fae435d4d5f56f9dc389b)
---
 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


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a6abcb2.1d469.2a52855c>