Re:Mutexes are faster than Spinlocks
by bubbleRefuge on Saturday January 04, 2020 @10:50AM
(#21955495)
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 ?
[ Parent
| on HN ]
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.
Re:Mutexes are faster than Spinlocks
by anewvillager on Saturday January 04, 2020 @10:59AM
(#21955554)
Yes! That's called an optimistic spinning lock!
https://linuxplumbersconf.org/event/4/contributions/286/atta...
Re:Mutexes are faster than Spinlocks
by CodeWriter23 on Saturday January 04, 2020 @11:40AM
(#21955803)
Or use a mutex and let the scheduler implement equitable dispatching.