remove suggestion that spurious condition variable wakeups are magically handled by ConditionVariableImpl
Categories
(Core :: mozglue, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: karlt, Assigned: karlt)
References
Details
Attachments
(1 file)
"Block the current thread of execution until this condition variable is
woken from another thread via notify_one or notify_all." derives from
https://hg.mozilla.org/mozilla-central/rev/cbce330b4dd3#l1.18
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rconc-wait
"Don’t wait without a condition"
main 3p pthread_cond_timedwait
"Spurious wakeups from the pthread_cond_timedwait() or pthread_cond_wait()
functions may occur. Since the return from pthread_cond_timedwait() or
pthread_cond_wait() does not imply anything about the value of this predicate,
the predicate should be re- evaluated upon such return."
"It is important to note that when pthread_cond_wait() and
pthread_cond_timedwait() return without error, the associated predicate may
still be false."
"The application needs to recheck the predicate on any return because it
cannot be sure there is another thread waiting on the thread to handle the
signal, and if there is not then the signal is lost. The burden is on the
application to check the predicate."
"In general, whenever a condition wait returns, the thread has to re-evaluate
the predicate associated with the condition wait to determine whether it can
safely proceed, should wait again, or should declare a timeout. A return
from the wait does not imply that the associated predicate is either true or
false.
It is thus recommended that a condition wait be enclosed in the equivalent of
a ``while loop'' that checks the predicate."
https://docs.microsoft.com/en-us/windows/desktop/api/synchapi/nf-synchapi-sleepconditionvariablesrw
"Condition variables are subject to spurious wakeups (those not associated with an explicit wake) and stolen wakeups (another thread manages to run before the woken thread). Therefore, you should recheck a predicate (typically in a while loop) after a sleep operation returns."
https://stackoverflow.com/questions/8594591/why-does-pthread-cond-wait-have-spurious-wakeups
"Spurious wakeups may sound strange, but on some multiprocessor systems, making condition wakeup completely predictable might substantially slow all condition variable operations."
Assignee | ||
Comment 1•5 years ago
|
||
Pushed by ktomlinson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9fa7ed12ba26 remove suggestion that spurious condition variable wakeups are magically handled by ConditionVariableImpl r=froydnj
Comment 3•5 years ago
|
||
bugherder |
Description
•