3 ms·
The test-and-set lock has the "advantage" of being unfair. Being unfair could be seen as a problem, and indeed it is, especially when access to memory takes a t
by bonzini 3y ago
The test-and-set lock has the "advantage" of being unfair. Being unfair could be seen as a problem, and indeed it is, especially when access to memory takes a time that depends on who performs the access. However, if the lock holder could be preempted, and you have no way to schedule it back, it will cause all waiters to delay even if one is runnable, and that will quickly send performance down a cliff.
For that reason test-and-set spinlocks are sometimes used in userspace or in virtual machines.