Home › GATE CSE › computerscience › Operating Systems › On a MULTI-CORE system, a SPIN LOCK is generally
On a MULTI-CORE system, a SPIN LOCK is generally
Aalways bad
Bthe same as a mutex on uniprocessors
Cless efficient than disabling interrupts
Duseful for VERY SHORT critical sections on other cores
Answer & Solution
Correct answer: D. useful for VERY SHORT critical sections on other cores
1. On a multi-core system, the lock holder can be running on a DIFFERENT CORE than the spinner.
2. So the spinner waits BRIEFLY (the few microseconds it takes the holder to finish its critical section) — at which point the lock becomes free and the spinner acquires it.
3. No context switches, no system calls — very fast for SHORT critical sections.
4. This is why the LINUX KERNEL uses SPINLOCKS heavily in interrupt handlers and short kernel paths.
5. For LONG critical sections (more than a few microseconds), blocking locks (mutex with sleep) are better.
6. Options A, C, D mischaracterise the multi-core case.
_Source: OSTEP Ch 28, §28.9 (Performance — multiprocessor case), p. 7._
Related questions
Disabling 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 (wiA LOCK is considered FAIR if