Practice free →
HomeGATE CSEcomputerscienceOperating Systems › A SPIN LOCK (or busy-waiting lock) is one in whi…

A SPIN LOCK (or busy-waiting lock) is one in which a thread that finds the lock held

Asleeps and is woken up by the kernel when the lock is released
Bloops continuously checking if the lock is free (busy waiting)
Cthrows an exception
Dterminates the process
Answer & Solution
Correct answer: B. loops continuously checking if the lock is free (busy waiting)
1. OSTEP §28.7 introduces SPIN LOCKS: when a thread can't acquire the lock, it LOOPS (spins) checking the lock state repeatedly until it becomes free. 2. ADVANTAGE: no kernel involvement → very fast IF the lock is held briefly. 3. DISADVANTAGE: wastes CPU cycles while spinning. Bad on single-CPU systems (no other thread can release the lock if the spinner is hogging the CPU). 4. Real systems use spinlocks for short critical sections (e.g. inside kernel code), and BLOCKING (sleep-based) locks for longer waits. 5. Option A describes a BLOCKING lock (mutex with sleep/wakeup). Options C, D are wrong. _Source: OSTEP Ch 28, §28.7 (Spin Locks With Test-And-Set), p. 6-7._
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions