CS FundamentalsVery hardGATE CS (PYQ pattern)
Every fork() succeeds, wait() blocks until some child has terminated (it returns at once if the caller has no un-waited children), and printing is unbuffered. main(): fork() creating C1; fork() creating C2; wait(); print P. C1: print X; fork() creating G; wait(); print Z. G: print g. C2: print Y. How many different output strings are possible over all schedules?
- A. 13
- B. 11
- C. 9
- D. 16
Correct answer: B. 11
Enumerating every interleaving (with wait releasing P after either C1 or C2 ends, and Z only after g) gives 11 distinct strings; XYPgZ, XYgPZ, XYgZP, XgYPZ ... are examples.
More Operating Systems questions
- A buddy allocator manages 1024 KB (minimum block 16 KB, requests rounded up to powers of two; the lowest-addressed free block of the…
- A 128 KB physically-tagged, virtually-indexed L1 cache has 64-byte lines and is 16-way set-associative. The system uses 4 KB pages. How…
- A machine has 2 GB of RAM; the OS occupies 512 MB and every user process needs 192 MB, so as many whole processes as fit are kept in…
- Highest Response Ratio Next (non-preemptive; ratio = (waiting time + burst) / burst, evaluated whenever the CPU becomes free) schedules…
- Four processes with CPU bursts 10, 4, 2 and 1 ms arrive together at time 0 in that order and are scheduled by Round Robin with quantum 3…
- Round Robin, quantum 4 ms, four processes arriving together at time 0 in the order P1..P4 with bursts 9, 5, 2 and 6 ms. Every switch to a…