A LOCK is considered FAIR if
Aall threads acquire the lock equally fast
Bevery thread can acquire the lock without contention
Cthe lock is held forever once acquired
Dwaiting threads acquire it in FIFO order
Answer & Solution
Correct answer: D. waiting threads acquire it in FIFO order
1. OSTEP §28.6 evaluates locks on three criteria: correctness, performance, and FAIRNESS.
2. FAIRNESS: as the lock is contested, do all waiting threads get a turn? Or do some threads get starved indefinitely?
3. A FAIR lock typically uses FIFO ordering (queue-based) so the longest-waiting thread acquires the lock next.
4. UNFAIR locks (like simple spin-locks) may starve threads: in high contention, the thread that was JUST preempted might re-acquire the lock immediately on resumption, starving others.
5. Linux's MCS lock and ticket lock are fair; simple test-and-set spinlocks are not.
6. Options A, C, D describe other properties or wrong concepts.
_Source: OSTEP Ch 28, §28.6 (Evaluating Locks — Fairness), p. 4-5._
Related questions
On a MULTI-CORE system, a SPIN LOCK is generallyDisabling INTERRUPTS as a way to implement mutual exclusion on a single-CPU system isA LIVELOCK differs from a DEADLOCK in thatSuppose thread A acquires lock L1, then thread B acquires lock L2. Now A tries to acquire Without atomic hardware support, building a correct mutual-exclusion lock for $N \geq 2$ tA CRITICAL SECTION isLinux's `pthread_mutex_lock()` is typically implemented as a HYBRID:What is the PRIMARY problem with using a SPIN LOCK on a SINGLE-CPU uniprocessor system (wi