> Most industry uses of spinlocks would be where threads are pinned to scheduler isolated cores
I have seen this assumption many times, and people not realising it wasn't the perfect environment they initially believed. Yes you can have an isolated environment where it's perfectly fine but for most people it's rare even when they think it might be.
And lots of people use them even without being in a perfect environment, just because someone gave them an idea it was always better to use then a mutex.
Ultimately the chances of spinning because the kernel pre-empted another thread while it held the lock are quite small (assuming you're doing little work under the lock), and you might be willing to pay that occasional cost for lower latency the other 99.9% of the time.
View all comments
Show parent comment
1
u/ReDucTor Game Developer | quiz.cpp-perf.com Sep 06 '26
> Most industry uses of spinlocks would be where threads are pinned to scheduler isolated cores
I have seen this assumption many times, and people not realising it wasn't the perfect environment they initially believed. Yes you can have an isolated environment where it's perfectly fine but for most people it's rare even when they think it might be.
And lots of people use them even without being in a perfect environment, just because someone gave them an idea it was always better to use then a mutex.