Re:Measuring mutexes, spinlocks and how bad the Linux schedu...
by gpderetta on Wednesday January 01, 2020 @07:43AM
(#21927814)
If a spin lock ends up in a call to sched_yeld, it means that it is already outside its intended use case (uncontrnded or nearly uncontented), so it is a bit pointless to optimize this path or expect any sane scheduling behaviour. If contention is probable it is better to fall back on a futex after a few[1] busy spins.
This is what pthread_mutex (and pretty much every decent OS provided mutex does) on glibc by default.
[1] how much is 'few' of course is often application dependent.
This is what pthread_mutex (and pretty much every decent OS provided mutex does) on glibc by default.
[1] how much is 'few' of course is often application dependent.