3 ms·
If you have a fallback to futex, then what you have isn't a spinlock, but an adaptive mutex (which spins, then blocks). Lots of operating systems have those alr
by quotemstr 7y ago
If you have a fallback to futex, then what you have isn't a spinlock, but an adaptive mutex (which spins, then blocks). Lots of operating systems have those already and you don't need to build your own.
- shaklee3 7y agoOr just use a futex alone, since that mimics its behavior enough.
- the8472 7y agoIf you really want to use a pure spinlock you'll either have to accept that worst-case behavior being worse than a mutex or you have to jump through a lot of hoops (pinning threads, isolating cores, reassigning interrupts) to make sure you don't get descheduled. Because the scheduler won't know anything about priority inversions or even waiting threads, they all look runnable.