2 comments

[ 0.19 ms ] story [ 8.1 ms ] thread
Thanks for sharing! Happy to get feedback :)

Note that I don't recommend spinlock for most cases, only when there is a 1:1 mapping between threads and phsycal CPU cores, and only after measuring

One thing I had to learn the hard way is that a spin lock is a bad fit the moment your threads can be preempted mid critical section. Under oversubscription you're spinning against a thread that isn't even scheduled.