CS FundamentalsHardProduct-company MCQ pattern
Two processes use this code for mutual exclusion; turn is shared and starts at 0. Which property does it FAIL?
Two processes use this code for mutual exclusion; `turn` is shared and starts at 0. Which property does it FAIL?
// Process i (i = 0 or 1)
while (true) {
while (turn != i) ; // busy wait
/* critical section */
turn = 1 - i;
/* remainder section */
}- A. It satisfies all three requirements
- B. Both mutual exclusion and bounded waiting
- C. Mutual exclusion
- D. Progress
Correct answer: D. Progress
Strict alternation guarantees mutual exclusion and bounded waiting, but if process 0 wants to enter twice in a row while process 1 stays in its remainder section, process 0 is blocked by a process not interested in entering. That violates progress. Peterson's algorithm fixes it with flag[].
More Operating Systems questions
- Producer–consumer with semaphores mutex = 1, empty = N, full = 0. The producer is written as: c wait(mutex); wait(empty); / add item /…
- Match each scheduling algorithm with its property: (P) Round Robin (Q) SRTF (R) Multilevel feedback queue (S) FCFS (1) Moves processes…
- How many of the following statements are correct? 1. On a context switch, the TLB must be flushed unless its entries carry an…
- A 16 GB disk is formatted with 4 KB blocks and a File Allocation Table (FAT) that has one 4-byte entry per block. How large is the FAT…
- How many of the following statements about semaphores and mutexes are correct? 1. A binary semaphore can be used to achieve mutual…
- Process L (low priority) holds a lock that high-priority process H needs. Medium-priority process M, which does not need the lock, becomes…