On a platform that has only events [1], mutexes and semaphores [2], I can create a fair implementation of "wait on multiple events", which returns when any of the events [3] is signaled / set. I assume the existing primitives are fair.
[1] An event is a “flag” that has 4 ops: Set (), Clear (), Wait () and WaitAndClear (). If you wait () in an unoccupied event, you block until someone installs it (). WaitAndClear () is what it seems, but atomic. All the waiters woke up.
[2] I do not believe that the system supports semaphore values that are negative.
[3] I say "events", but it may be a new type of object that uses any of these primitives.
source share