Hacker News new | ask | show | jobs
by kprotty 1033 days ago
A spinlock can be conditionally faster than a lock with uses futex, but it doesn't scale. Futex is really meant to provide an efficient way to block and unblock threads. One could use FUTEX_LOCK_PI to have it actually implement a lock, but that's a separate argument/edge-case.
1 comments

This has varied over time depending on kernel implementations, CPU core count, number of threads, etc.

Some relevant reading: https://matklad.github.io/2020/01/04/mutexes-are-faster-than...