CS FundamentalsVery hardGATE CS
mutex m = 1. P1: wait(m); print A; print B; signal(m). P2: wait(m); print C; print D; signal(m). P3: print E (no synchronisation). How many distinct outputs are possible?
- A. 2
- B. 6
- C. 10
- D. 12
Correct answer: C. 10
AB and CD each appear as an unbroken pair in either order (2 ways), and E can be inserted in any of the 5 gaps of the 4-letter string: 2 × 5 = 10.
More Operating Systems questions
- Shared x = 0, mutex m = 1. T1: wait(m); x = x + 1; signal(m). T2: wait(m); x = x + 2; signal(m). T3: x = x + 4 (no lock). Each assignment…
- A counting semaphore is implemented WITHOUT busy waiting: wait() decrements the value and, if it becomes negative, puts the caller on the…
- Strict alternation uses a shared turn variable: P0: while (turn != 0); CS; turn = 1; P1: while (turn != 1); CS; turn = 0;. P0 wants to…
- Two processes each run flag[i] = true; while (flag[j]); CS; flag[i] = false; (no turn variable). Which statement is correct?
- Two processes each run while (flag[j]); flag[i] = true; CS; flag[i] = false; (check first, then set). Which property fails?
- 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]…