diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2026-07-25 20:02:24 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2026-07-27 16:12:12 +0000 |
| commit | 3c6f63902b037e36648fae435d4d5f56f9dc389b (patch) | |
| tree | d3dedbfa32d2d133e5e1b3af07c4c1b3fe9dd7b3 | |
| parent | 2a2705a637cd67d0add7fe795fef9b7a722d76bd (diff) | |
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
| -rw-r--r-- | share/man/man3/pthread_cond_wait.3 | 15 |
1 files changed, 14 insertions, 1 deletions
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 |
