Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can have fair spinlocks if you handle queuing yourself.

Also the article does indeed implement a real mutex (although a buggy one), not a spinlock. std::atomic::wait will use futexes (or whatever) underneath to genuinely put the process to sleep until it receives a wakeup.



Are the locks presented in the article guaranteed to be acquired in approximate FIFO order?


I don't think atomic::wait/notify does guarantee any fairness. It would need to be built on top.


Btw, I retract my "buggy" comment.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: