Hacker News new | ask | show | jobs
by scott_s 3665 days ago
Pthreads on Linux encourage holding the lock during a signal or broadcast (http://linux.die.net/man/3/pthread_cond_signal):

  The pthread_cond_broadcast() or pthread_cond_signal()
  functions may be called by a thread whether or not it
  currently owns the mutex that threads calling
  pthread_cond_wait() or pthread_cond_timedwait() have
  associated with the condition variable during their waits;
  however, if predictable scheduling behavior is required,
  then that mutex shall be locked by the thread calling
  pthread_cond_broadcast() or pthread_cond_signal().
They don't define what exactly "predictable scheduling is", but the message that most programmers will probably come away with is, grabbing the lock is probably the better thing to do.