News for hackers. Stuff that matters.
Re:Semaphores are surprisingly versatile by tlb on Monday March 16, 2015 @03:19PM (#9213666)
I think the point is that semaphore calls might be expensive, while in the normal case this is a simple one-instruction atomic increment.
Re:Semaphores are surprisingly versatile by kazinator on Monday March 16, 2015 @04:52PM (#9214304)
My point, on the other hand, is that this one-instruction atomic increment and test, with a conditional wait call is a semaphore (though perhaps a faster one than the underlying semaphore). Whereas the point of the article is that semaphores are very flexible and can be used to implement other primitives.

This could be repaired by reframing the example as "look, slow semaphores, together with an atomic increment/test operation provided by the processor, can be used to implement faster semaphores!"

This is actually a useful case that tends to be overlooked by "primitives X, Y, and Z out of semaphores" tutorials.