Hacker News new | ask | show | jobs
by gpderetta 297 days ago
They are so good that they keep being reinvented even in userspace, for example WTF::ParkingLot.

Or C++ also adding std::atomic::wait which is basically a thin [1] wrapper over futex.

[1] implementations still manage to mess it up.

1 comments

The WTF::ParkingLot example is interesting because it shows that you don't actually need futexes in the kernel to implement them efficiently; you just need something like a spinlock (with sane backoff!) to guard the userspace wait queue and a per-thread eventfd to wake up waiters.
Yes, you can do a good futex impression in userspace and add any missing functionality you need. Most importantly for webkit, I think, you get portability.

The advantage of futex provided by the kernel is ABI stability and cross process support.

It gives you an implementation. The implementation does not have to be ideal, though.