-
Philippe Gerum authored
The Cobalt monitor is a double-wait condition object, serializing accesses through a gate. It behaves like a mutex + two condition variables combo with extended signaling logic. Folding several conditions and the serialization support into a single object performs better on low end hw caches and allows for specific optimizations, compared to using separate general-purpose mutex and condvars. This object is used by the Copperplate interface internally when it runs over the Cobalt core. Threads can wait for some resource(s) to be granted (consumer side), or wait for the available resource(s) to drain (producer side). Therefore, signals are thread-directed for the grant side, and monitor-directed for the drain side. Typically, a consumer would wait for the GRANT condition to be satisfied, signaling the DRAINED condition when more resources could be made available if the protocol implements output contention (e.g. the write side of a message queue waiting for the consumer to release message slots). Conversely, a producer would wait for the DRAINED condition to be satisfied, issuing GRANT signals once more resources have been made available to the consumer. Implementation-wise, the monitor logic is shared with the Cobalt thread object.
1fe97683