CS FundamentalsVery hardGATE CS
A condition-variable based bounded buffer uses a single condition variable `cv` for both 'not full' and 'not empty', and signals with `signal(cv)` (wake one). With several producers and consumers, what can go wrong?
- A. Mutual exclusion is violated
- B. Items are delivered out of order
- C. Nothing; one condition variable is always enough
- D. A signal can wake the wrong kind of thread (e.g. a producer wakes another producer), leaving a consumer asleep even though data is available, and all threads may end up waiting
Correct answer: D. A signal can wake the wrong kind of thread (e.g. a producer wakes another producer), leaving a consumer asleep even though data is available, and all threads may end up waiting
With one shared condition, signal() may wake a thread whose condition is still false; it goes back to sleep and the needed wakeup is lost. Use two condition variables or broadcast.
More Operating Systems questions
- Which statement about deadlock in a system with only ONE resource type that has 10 instances is correct?
- What is the main drawback of deadlock prevention by requiring a process to request ALL its resources before starting (breaking…
- Deadlock recovery by process termination: which criteria are sensible for choosing a victim? 1. Lowest priority 2. Least CPU time consumed…
- An OS uses the Banker's algorithm. Which assumption must hold for it to be applicable?
- Processes (arrival, burst): P1 (0, 6), P2 (1, 8), P3 (2, 7), P4 (3, 3). Under SRTF, what is the turnaround time of P2?
- Preemptive priority scheduling (smaller number = higher priority; equal priority is FCFS and does not preempt). Processes (arrival, burst…