Spurious wakeup

From HandWiki
Short description: Computing phenomenon


The problem of spurious wakeup can be exacerbated on multiprocessor systems. When several threads are waiting on a single condition variable, the system may decide to wake all threads up when it's signaled. The system treats every signal( ) to wake one thread as a broadcast( ) to wake all of them, thus breaking any possibly expected 1:1 relationship between signals and wakeup.Cite error: Closing </ref> missing for <ref> tag The Linux p-thread implementation of condition variables guarantees that it will not do that.[1][2]

Because spurious wakeup can happen, when a thread wakes after waiting on a condition variable, it should always check that the condition it sought is still satisfied. If it is not, it should go back to sleeping on the condition variable, waiting for another opportunity.[3]

References