CS FundamentalsVery hardGATE CS (PYQ pattern)
Semaphores S = 0 and T = 0 are shared. P1 executes: print A; signal(S); print B. P2 executes: wait(S); print C; signal(T). P3 executes: print D; wait(T); print E. Each statement runs atomically and the processes run once concurrently. How many distinct output strings are possible?
- A. 11
- B. 9
- C. 12
- D. 10
Correct answer: A. 11
The constraints are A before B, A before C, C before E and D before E. Counting the valid interleavings of the five prints by exhaustively exploring schedules gives 11 distinct strings (for example ABCDE and DACEB, but not CDABE).
More Operating Systems questions
- A Unix-style inode has 12 direct pointers, one single-indirect and one double-indirect pointer. Block size is 2 KB and a block pointer is…
- A process with pages numbered 0 to 4 references them in the order 0 4 0 1 3 4 0 1 4 0 2 0 4 1 3 2. Under FIFO replacement with initially…
- With 3 initially empty frames, the reference string 1 1 1 3 2 6 6 3 3 5 2 5 1 5 6 2 4 6 4 6 5 3 is processed under LRU and under the…
- A process makes 18 page references (times 1 to 18): 2 4 4 3 4 2 4 5 2 5 5 2 1 1 3 5 4 1. The working set W(t, 5) is the set of distinct…
- A multilevel feedback queue has three queues: Q0 (round robin, quantum 4 ms), Q1 (round robin, quantum 8 ms) and Q2 (FCFS). Queues are…
- Five processes (arrival time, CPU burst) are: P1 (1, 8), P2 (4, 1), P3 (0, 3), P4 (7, 6), P5 (5, 1). With preemptive…