News for hackers. Stuff that matters.
Re:Semaphores are surprisingly versatile by kazinator on Monday March 16, 2015 @04:46PM (#9214273)
That looks like some API/kernel call overhead; you've moved the fast path of the semaphore implementation into user space. But what you have there is undeniably a semaphore implementation: atomically tweak a counter, and based on that result, wait or signal.
Re:Semaphores are surprisingly versatile by preshing on Monday March 16, 2015 @05:40PM (#9214587)
> you've moved the fast path of the semaphore implementation into user space.

I see now why your original comment was a bit inflammatory. I should have been more clear in the post that by "lightweight", I meant exactly that: "fast path in user space". I guess not everyone shares this vocabulary. I'll improve the post.

You're right that this lightweight mutex is a semaphore, of course. But not every semaphore is a lightweight mutex. So the technique isn't pointless.

Re:Semaphores are surprisingly versatile by asveikau on Tuesday March 17, 2015 @01:26AM (#9216414)
Seems like that's what any sane modern user space sync primitives would do: do the atomic ops in user space for the fast path, enter the kernel when it's time to block. Like the "futex" in Linux.

I suppose it is a fair point that the thing you use to enter the kernel doesn't have to be itself a semaphore.