diff --git a/emper/Runtime.hpp b/emper/Runtime.hpp index f52a5843ff072319d0507850803449c6fafcbad7..5e417ab95942cb9add742c44493a6e3ab9df5f95 100644 --- a/emper/Runtime.hpp +++ b/emper/Runtime.hpp @@ -84,7 +84,14 @@ class Runtime : public Logger<LogSubsystem::RUNTI> { // This is sound because wakeupSleepingWorkers() is called from a active // worker which will observe its own new work in its next dispatchLoop before // going to sleep. - skipWakeupThreshold = -1; + + // Note that sem_getvalue() is allowed to return 0 if there are + // waiting workers, hence we need to set the threshold also to + // 0. This has the disadvantage that we will perform one + // unnecessary sem_post. If we ever switch the wakeupSem + // implementation, then the skipWakeupThreshold value should be + // reviewed and potentially changed to '-1'. + skipWakeupThreshold = 0; } int semValue;