diff --git a/include/utils/Condition.h b/include/utils/Condition.h index e63ba7e69..1c99d1ada 100644 --- a/include/utils/Condition.h +++ b/include/utils/Condition.h @@ -60,7 +60,7 @@ public: status_t wait(Mutex& mutex); // same with relative timeout status_t waitRelative(Mutex& mutex, nsecs_t reltime); - // Signal the condition variable, allowing one thread to continue. + // Signal the condition variable, allowing exactly one thread to continue. void signal(); // Signal the condition variable, allowing one or all threads to continue. void signal(WakeUpType type) { @@ -132,6 +132,17 @@ inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) { #endif // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE } inline void Condition::signal() { + /* + * POSIX says pthread_cond_signal wakes up "one or more" waiting threads. + * However bionic follows the glibc guarantee which wakes up "exactly one" + * waiting thread. + * + * man 3 pthread_cond_signal + * pthread_cond_signal restarts one of the threads that are waiting on + * the condition variable cond. If no threads are waiting on cond, + * nothing happens. If several threads are waiting on cond, exactly one + * is restarted, but it is not specified which. + */ pthread_cond_signal(&mCond); } inline void Condition::broadcast() {