Bug#651005: /usr/share/man/man3/pthread_cond_wait.3.gz: pthread_cond_wait documentation incorrect, does not allow for spurious wakeups
Package: glibc-doc
Version: 2.13-21
Severity: normal
File: /usr/share/man/man3/pthread_cond_wait.3.gz
Tags: patch
pthread_cond_wait(3) says:
pthread_cond_wait atomically unlocks the mutex (as per
pthread_unlock_mutex) and waits for the condition variable
cond to be signaled. The thread execution is suspended and does
not consume any CPU time until the condition variable is
signaled. The mutex must be locked by the calling thread on
entrance to pthread_cond_wait. Before returning to the calling
thread, pthread_cond_wait re-acquires mutex (as per
pthread_lock_mutex).
This is actually not true in practice, and also not required by POSIX.
pthread_cond_wait() sometimes wakes up without the condition variable
having been signaled, and POSIX allows for such "spurious wakeups".
See also
http://en.wikipedia.org/wiki/Spurious_wakeup
http://stackoverflow.com/questions/8378789/forcing-a-thread-context-switch
Suggested patch:
pthread_cond_wait atomically unlocks the mutex (as per
pthread_unlock_mutex) and waits for the condition variable
cond to be signaled. The thread execution is suspended and does
not consume any CPU time until woken up. The thread will be woken
up when the condition variable is signaled, but spurious wakeups
without a corresponding signal may also happen. The mutex must
be locked by the calling thread on entrance to
pthread_cond_wait. Before returning to the calling thread,
pthread_cond_wait re-acquires mutex (as per pthread_lock_mutex).
-- System Information:
Debian Release: wheezy/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 3.0.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
glibc-doc depends on no packages.
glibc-doc recommends no packages.
Versions of packages glibc-doc suggests:
pn glibc-doc-reference <none>
-- no debconf information
Reply to: