Which synchronization primitive uses busy-waiting and is typically suitable for low-contention scenarios?

Enhance your understanding with the System Software, Architecture, Memory and Storage Test. Study with flashcards and multiple choice questions. Each question offers hints and detailed explanations. Prepare effectively for your exam!

Multiple Choice

Which synchronization primitive uses busy-waiting and is typically suitable for low-contention scenarios?

Explanation:
Busy-waiting means a thread keeps looping, repeatedly checking if a condition is true instead of yielding the CPU. A spinlock embodies this: a thread continuously tries to acquire the lock using an atomic operation, and if the lock is already held, it spins in a tight loop until the owner releases it. This approach avoids the overhead of blocking and waking up a thread, which is why it shines when contention is low and the critical section is very short—the expected wait time is tiny, so the cost of spinning is often less than the cost of a context switch. Spinlocks are common in low-latency paths or in contexts where blocking is expensive, such as kernel code or interrupt-sensitive regions. In contrast, a semaphore relies on blocking and waking up waiting threads, a barrier waits for a group of threads to reach a point, and a condition variable works with a mutex to block until a predicate changes. None of these primarily use busy-waiting, which is why they don’t fit the scenario described. So, the primitive that uses busy-waiting and is typically suitable for low-contention scenarios is the spinlock.

Busy-waiting means a thread keeps looping, repeatedly checking if a condition is true instead of yielding the CPU. A spinlock embodies this: a thread continuously tries to acquire the lock using an atomic operation, and if the lock is already held, it spins in a tight loop until the owner releases it. This approach avoids the overhead of blocking and waking up a thread, which is why it shines when contention is low and the critical section is very short—the expected wait time is tiny, so the cost of spinning is often less than the cost of a context switch. Spinlocks are common in low-latency paths or in contexts where blocking is expensive, such as kernel code or interrupt-sensitive regions.

In contrast, a semaphore relies on blocking and waking up waiting threads, a barrier waits for a group of threads to reach a point, and a condition variable works with a mutex to block until a predicate changes. None of these primarily use busy-waiting, which is why they don’t fit the scenario described.

So, the primitive that uses busy-waiting and is typically suitable for low-contention scenarios is the spinlock.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy