Re:The Fastest Mutexes
by xxs on Thursday October 03, 2024 @03:07AM
(#41728018)
start with few attempts w/o pause, just busy CAS, then CAS + pause, then yield (and backoff/sleep with random duration)
[ Parent
| on HN ]
Re:The Fastest Mutexes
by senderista on Thursday October 03, 2024 @02:25PM
(#41733410)
No, you shouldn’t be calling CAS in a tight loop, but rather a relaxed load to check if a CAS might be successful, with PAUSE equivalent after each load. After spinning for ~context switch latency you should back off with sched_yield before retrying the spin loop (and eventually start sleeping on backoff with exponential jitter etc).