6 ms·
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
by gpderetta 1y 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.
- senderista 1y agoThe 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.
- saagarjha 1y agoIt gives you an implementation. The implementation does not have to be ideal, though.
- gpderetta 1y agoYes, 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.