CS FundamentalsVery hardGATE CS (PYQ pattern)
Semaphores s = 1, t = 0. P1: wait(s); print A; print B; signal(s). P2: wait(s); print C; signal(s). P3: wait(t); print D; signal(s). P4: print E; signal(t). All run concurrently, prints are atomic. How many different complete outputs are possible, and can the system deadlock?
- A. 26 outputs; no deadlock
- B. 23 outputs; deadlock possible
- C. 19 outputs; deadlock possible
- D. 23 outputs; no deadlock
Correct answer: D. 23 outputs; no deadlock
A and B are consecutive (P1 holds s). D needs t, i.e. E must come first, and D's signal(s) adds an extra permit. Exhaustive enumeration of schedules gives 23 outputs; deadlock reachable: False.
More Operating Systems questions
- Semaphores a = 1, b = 0, c = 0. P1: wait(a); print x; signal(b). P2: wait(b); print y; signal(c). P3: wait(c); print z; signal(a). P4…
- Round Robin with quantum 4 ms; processes (arrival, burst) in ms: A (0, 11), B (2, 6), C (3, 3), D (5, 9), E (8, 2). A process that arrives…
- The head is at cylinder 50. Pending requests in arrival order: 82, 170, 43, 140, 24, 16, 190. By how many cylinders is the total head…
- NRU replacement runs with 3 frames (initially empty). Each page has bits (R, M): R is set on every reference, M on every write, and a…
- Round Robin runs 10 always-runnable, CPU-bound processes; every context switch costs 0.5 ms and each process always uses its full quantum…
- Six processes share identical units of one resource; each needs at most 4 units. Five of them request units one at a time, holding what…