CS FundamentalsHardGATE CS
Two processes each run `while (flag[j]); flag[i] = true; CS; flag[i] = false;` (check first, then set). Which property fails?
- A. Mutual exclusion: both can see the other's flag false and enter together
- B. Progress only
- C. Bounded waiting only
- D. None; it is correct
Correct answer: A. Mutual exclusion: both can see the other's flag false and enter together
Checking before setting leaves a window: both read false, both set true, and both enter the critical section. Swapping the order (set then check) gives the deadlock-prone version instead.
More Operating Systems questions
- Peterson's algorithm is written with turn = i; (giving the turn to ITSELF) instead of turn = j;: flag[i] = true; turn = i; while (flag[j]…
- stdout is a pipe (fully buffered) and every fork() succeeds. What is the complete output, up to the order of the lines? c int main() {…
- How many times is "x" printed? (Every fork() succeeds; output unbuffered.) c int main() { for (int i = 0; i < 2; i++) { if (fork() == 0)…
- What values are printed (in any order)? (Every fork() succeeds.) c int main() { int x = 1; if (fork() == 0) { x = 2; if (fork() == 0) x =…
- How many processes are created in total, including the original? (Every fork() succeeds.) c int main() { for (int i = 0; i < 3; i++) if…
- Processes (arrival, burst): P1 (0, 7), P2 (2, 3), P3 (3, 1), P4 (6, 2). SRTF is used and every switch to a DIFFERENT process costs 1 ms…