Multithreaded Programming Guide

Exit Print View

Updated: July 2014
 
 

Lost Wake-Up Problem

A call to pthread_cond_signal() or pthread_cond_broadcast() when the thread does not hold the mutex lock associated with the condition can lead to lost wake-up bugs.

A lost wake-up occurs when all of the following conditions are in effect:

  • A thread calls pthread_cond_signal() or pthread_cond_broadcast()

  • Another thread is between the test of the condition and the call to pthread_cond_wait()

  • No threads are waiting

    The signal has no effect, and therefore is lost

This can occur only if the condition being tested is modified without holding the mutex lock associated with the condition. As long as the condition being tested is modified only while holding the associated mutex, pthread_cond_signal() and pthread_cond_broadcast() can be called regardless of whether they are holding the associated mutex.