CS FundamentalsHardGATE CS (PYQ pattern)
Semaphores a = 1, b = 0, c = 0. Four processes each run once: P1: wait(a); print 1; signal(b); signal(c). P2: wait(b); print 2; signal(a). P3: wait(c); print 3; signal(a). P4: wait(a); print 4. All four start together. Which statement is correct?
- A. Exactly 6 different complete outputs exist, and some schedules deadlock
- B. Exactly 4 different complete outputs exist, and some schedules deadlock
- C. Exactly 4 different complete outputs exist, and no schedule can deadlock
- D. Exactly 3 different complete outputs exist, and some schedules deadlock
Correct answer: B. Exactly 4 different complete outputs exist, and some schedules deadlock
Only one wait(a) can succeed first. If P4 wins, a stays 0 and P1 blocks forever (deadlock). If P1 wins, 1 is followed by an order of 2, 3, 4 where 4 needs a signal(a) from 2 or 3: 1234, 1243, 1324, 1342.
More Operating Systems questions
- Round Robin with quantum 4 ms. Processes (arrival, burst) in ms: P1 (0, 7), P2 (1, 4), P3 (2, 9), P4 (3, 5), P5 (16, 3). A process that…
- Periodic tasks (execution time, period = deadline): T1 (2, 5), T2 (4, 7). Which statement is correct?
- Three periodic tasks (execution time, period = deadline) are given: A (1, 4), B (2, 6), C (3, 12). Which statement is correct?
- A system has R identical units of one resource. Four processes need at most 3, 4, 2 and 5 units. Each process requests units TWO at a time…
- Banker's algorithm: 5 processes, resource types A, B, C with totals (10, 5, 7). Allocation / Maximum: P0 (0,1,0)/(7,5,3), P1…
- A disk has cylinders 0 to 199. The head is at cylinder 60 moving upward. Pending requests: 18, 150, 72, 41, 177, 95, 33, 124. C-LOOK…