CS FundamentalsHardAccenture · Capgemini technical pattern
In a two-process mutual-exclusion attempt, each process sets its own flag to true and then waits while the other’s flag is true; there is no turn variable (as in Peterson’s algorithm). What can go wrong?
- A. Both may enter the critical section together
- B. Both may set their flags at the same time and then wait for each other forever
- C. One process can enter twice while the other waits forever, but no deadlock is possible
- D. Nothing; flags alone are enough for two processes
Correct answer: B. Both may set their flags at the same time and then wait for each other forever
Mutual exclusion holds (a process enters only after seeing the other’s flag false), but if both set their flags before either checks, each waits for the other: deadlock, violating progress. Peterson adds “turn” so one of them always gives way.
More Operating Systems questions
- A system runs 4 independent processes, each spending 80% of its time waiting for I/O. Assuming waits are independent, what is the…
- Processes (arrival, burst, priority — lower number is higher priority): P1 (0, 5, 3), P2 (1, 3, 1), P3 (2, 4, 4), P4 (4, 2, 2). Under…
- int A[256][256] is stored in row-major order, and a page holds 512 ints (two rows). The process has only ONE frame for A, initially empty…
- Processes (times in ms): A (arrival 0, burst 9), B (arrival 1, burst 4), C (arrival 3, burst 6), D (arrival 5, burst 2), E (arrival 8…
- Processes (times in ms): A (arrival 0, burst 9), B (arrival 1, burst 4), C (arrival 3, burst 6), D (arrival 5, burst 2), E (arrival 8…
- Processes (arrival, burst, priority; a smaller number means higher priority): A (0, 9, 3), B (1, 4, 1), C (3, 6, 4), D (5, 2, 2), E (8, 5…