CS FundamentalsHardGATE CS
A test-and-set spinlock: `while (TestAndSet(&lock)); /* CS */ lock = false;`. Which requirement of the critical-section problem does it NOT guarantee?
- A. Mutual exclusion
- B. Progress
- C. It satisfies all three
- D. Bounded waiting
Correct answer: D. Bounded waiting
TestAndSet is atomic, so only one process enters, and a free lock is always taken (progress). But nothing orders the waiters: an unlucky process may lose the race every time, so waiting is unbounded.
More Operating Systems questions
- A semaphore S is initialised to 3. The operations wait(S) ×6, signal(S) ×2, wait(S) ×1 are issued in that order by different processes…
- Binary semaphore mutex = 1 protects a counter. A programmer mistakenly writes signal(mutex); / critical section / wait(mutex); in every…
- In the dining philosophers problem with 5 philosophers, each picks up the LEFT fork and then the RIGHT fork. Which change by itself…
- Readers–writers with readers' preference: semaphores mutex = 1 (protects readcount), wrt = 1. Reader: wait(mutex); readcount++; if…
- A bounded buffer of size N uses semaphores empty = N, full = 0, mutex = 1. Producer: wait(empty); wait(mutex); add; signal(mutex)…
- Monitors versus semaphores: in a Hoare-style monitor, when a process executes x.signal() and some process is waiting on condition x, which…