CS FundamentalsHardGATE CS (PYQ pattern)
Semaphores x = 0, y = 0. P1: print a; signal(x); wait(y); print b. P2: wait(x); print c; signal(y); print d. P3: print e. All three start together and the prints are atomic. How many different complete output strings can be produced?
- A. 14
- B. 4
- C. 22
- D. 10
Correct answer: D. 10
The constraints are a before c before b (via x then y), c before d, and e is free. Counting the interleavings of the orders a<c<{b,d} (b and d unordered) with e inserted anywhere gives 10 strings; there is no deadlock.
More Operating Systems questions
- A Unix file system uses 4 KB blocks, 4-byte pointers and inodes with 12 direct pointers, one single-, one double- and one triple-indirect…
- Eight disks can be arranged as RAID 1+0 (4 mirrored pairs, striped together) or as RAID 0+1 (two 4-disk stripe sets, the second mirroring…
- Assume every fork() succeeds (it returns a non-zero value in the parent and 0 in the child) and each process prints X once when it reaches…
- Assume every fork() succeeds and output is unbuffered. int main(void) { int i; for (i = 0; i < 3; i++) { if (fork() == 0 && fork() == 0)…
- Banker's algorithm with two resource types (R1, R2). Allocation: P0 (0,2), P1 (1,4), P2 (0,4), P3 (6,1), P4 (0,2). Maximum: P0 (1,4), P1…
- Banker's algorithm, a single resource type, 6 processes P0..P5. Allocation: 1, 2, 2, 5, 3, 4. Maximum: 9, 3, 3, 7, 7, 9. Available = 1…