CS FundamentalsModerateGATE CS
Which property does Peterson's algorithm guarantee for two processes, assuming loads and stores are atomic and NOT reordered?
- A. Mutual exclusion only; it can deadlock
- B. Mutual exclusion, progress and bounded waiting
- C. Mutual exclusion and progress, but a process can starve
- D. Progress and bounded waiting, but not mutual exclusion
Correct answer: B. Mutual exclusion, progress and bounded waiting
Setting flag[i] and then giving turn to the other process ensures all three requirements. On modern CPUs that reorder memory accesses it needs memory barriers to remain correct.
More Operating Systems questions
- A test-and-set spinlock: while (TestAndSet(&lock)); / CS / lock = false;. Which requirement of the critical-section problem does it NOT…
- 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)…