CS FundamentalsHardGATE CS
In the first readers-writers solution (readers share a count; the first reader locks out writers and the last reader lets them in), what can happen under a steady stream of overlapping readers?
- A. Readers can starve, because a waiting writer always gets priority over them
- B. Writers can starve, because a new reader enters while others are still reading
- C. A reader and a writer can be in the critical section together
- D. Deadlock between the first reader and a writer waiting on the same semaphore
Correct answer: B. Writers can starve, because a new reader enters while others are still reading
Once one reader holds the writer lock, more readers keep joining without waiting, so the count may never fall to zero and writers wait forever. The second variant gives writers priority and can starve readers instead.
More Operating Systems questions
- Five philosophers each pick up their left fork and then their right fork. Which change removes the possibility of deadlock without adding…
- Two processes use while (lock) ; lock = 1; / CS / lock = 0; with a plain shared variable (no atomic instruction). Which requirement of the…
- In Peterson's algorithm for P0 and P1, the entry code for Pi is flag[i] = true; turn = j; while (flag[j] && turn == j);. What goes wrong…
- A counting semaphore is implemented WITHOUT busy waiting, and its value is −3 at some moment. What does this tell you?
- Which statement about user-level threads in a many-to-one model is correct?
- A system has 4 instances of R1 and 2 of R2. Allocated: P1 holds 1 R1; P2 holds 2 R1 and 1 R2; P3 holds 1 R1 and 1 R2. Requests: P1 wants 1…