CS FundamentalsVery hardGATE CS (PYQ pattern)
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 ms. A context switch is counted only when the CPU is handed from one process to a DIFFERENT process (a process that gets the CPU again immediately, because it is the only one left, costs none), and none is counted at the start or end. How many context switches occur?
- A. 7
- B. 8
- C. 6
- D. 4
Correct answer: C. 6
Dispatches = ceil(10/3) + ceil(4/3) + ceil(2/3) + ceil(1/3) = 4 + 2 + 1 + 1 = 8, i.e. 7 gaps. P1 runs its last quanta alone once the others finish, so those gaps are not switches; simulating the queue gives 6 real switches.
More Operating Systems questions
- 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…
- A system has 48-bit virtual addresses, 8 KB pages and 2^40 bytes of physical memory. Each page-table entry holds a frame number plus 5…
- A 7200 RPM disk has 500 sectors of 512 bytes per track and an average seek of 8 ms. A 1,048,576-byte file is stored in consecutive sectors…
- A program loops over pages 1, 2, 3, 4, 5 six times in cyclic order (30 references) with 4 frames, initially empty. How many page faults…
- SJF predicts each process's next CPU burst by exponential averaging, tau(n+1) = a x t(n) + (1 - a) x tau(n), with a = 0.5 and tau(0) = 10…
- Assume every fork() succeeds. for (int i = 0; i < 4; i++) { if (fork() == 0 && i % 2 == 1) execl("/bin/true", "true", NULL); }…