Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The go-to synchronization primitive on Windows, critical sections[1], does a short spin in then waits.

To me it has always seemed as a decent strategy, and when working on a cross-platform heavily multi-threaded code base which had a fairly contested hot-spot, Windows performed quite well using just plain critical sections.

[1]: https://learn.microsoft.com/en-us/windows/win32/sync/critica...



Musl libc also does this for threads, spinning 100 times by default before switching to a heavier system wait (see line 71): https://git.musl-libc.org/cgit/musl/tree/src/thread/pthread_...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: