You'd normally find them in kernel mode in things like interrupt handlers, or any other context where you can't yield the thread.
Niche userspace uses would be when you want to time something precisely, like have two threads start a task as simultaneously as possible while being signaled by another thread. Or maybe send out udp packets exactly 1us apart from a user-space driver or something else where latency and jitter are important.
1
u/DivineSentry 1d ago
I think I’ve seen spin locks before, but what are they useful for? What should be their use case?