4 ms·
What is the source of the complexity inside condition variables? Reading the glibc sources, the main problem seems to be ensuring that signals are delivered pro
by ridiculous_fish 6y ago
What is the source of the complexity inside condition variables? Reading the glibc sources, the main problem seems to be ensuring that signals are delivered properly?
- zvrba 6y agoYes, atomic unlock + wait is the complex bit. Prior to Vista, Windows did not have a CV primitive. Existing emulations used multiple kernel objects and their correctness was difficult to verify. Performance also suffered.
- gpderetta 6y agoI think Vista implemented keyed synchronization objects (i.e. a flavour of futexes) which have similar edge triggered semantics as CVs.
- atq2119 6y agoIt's possible to implement very simple condition variables. The tricky part is preventing correct but inefficient behaviours like stampeding herds.
- gpderetta 6y agoWhen implementing posix semantics there are a lot of nasty corner cases, especially with dealing with fairnes, graceful destruction, correct handling of wait generations and probably more that I'm missing. I would never attempt to implement a full condvar.