3 ms·
i mean you can use semaphores to implement condition variables, but it's extremely tricky to the point where you've got to be Mike Burrows in order to do it rig
by krackers 1y ago
i mean you can use semaphores to implement condition variables, but it's extremely tricky to the point where you've got to be Mike Burrows in order to do it right [1] (in fact, that's how it's done in the nsync library, as a fallback when every faster option is unavailable).
[1] http://birrell.org/andrew/papers/ImplementingCVs.pdf http://birrell.org/andrew/papers/ImplementingCVs.pdf
- the_mitsuhiko 1y ago> i mean you can use semaphores You absolutely can use semaphores for it, but the benefits of a benaphore would not work with when you build a condition variable with it. The wait on the CV would need to go through the kernel.