Hacker News new | ask | show | jobs
by bubbleRefuge 2363 days ago
couldn't you eliminate the bad spinlock behavior by coding them to be go into an efficient wait if to much spinning is going on ?
4 comments

That’s what virtually all battle-hardened lock libraries do: spin for a bit (but not too tightly, using a pause in the loop) then fall back to waiter lists and futex.
Yes! That's called an optimistic spinning lock!

https://linuxplumbersconf.org/event/4/contributions/286/atta...

Or use a mutex and let the scheduler implement equitable dispatching.
Yes. And then it becomes an adaptive mutex.