GATE / CS ARCHIVE

GATE CSE 2012 / QUESTION 31

FCFS and round-robin completion order

Operating Systems · CPU Scheduling · Full GATE CSE 2012 paper

GATE 2012, Q31 2 marks · MCQ
Report issue

CPU Scheduling

Question 31, GATE 2012: Consider the 3 processes, P1, P2 and P3 shown in the table.

                                       Process       Arrival       Time Units
                                                     time          Required
                                       P1            0             5
                                       P2            1             7
                                       P3            3             4

        The completion order of the 3 processes under the policies FCFS and RR2 (round robin scheduling
        with CPU quantum of 2 time units) are
        (A) FCFS: P1, P2, P3 RR2: P1, P2, P3                 (B) FCFS: P1, P3, P2 RR2: P1, P3, P2
        (C) FCFS: P1, P2, P3 RR2: P1, P3, P2                 (D) FCFS: P1, P3, P2 RR2: P1, P2, P3
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (2 schedules)

FCFS executes P1 from 0–5, P2 from 5–12 and P3 from 12–16, so completion order is P1, P2, P3. For quantum 2, round robin runs P1 0–2, P2 2–4, P1 4–6, P3 6–8, P2 8–10, P1 10–11, P3 11–13, P2 13–15 and 15–16. Completion times are respectively 11, 16, 13, giving P1, P3, P2. Hence C.

Check: The arrivals occur between quantum boundaries: P2 joins during P1’s first slice, and P3 joins during P2’s first slice. A preempted unfinished process returns to the tail, whereas a completed process is removed. This explains why the shorter P3 finishes before P2 under RR.

Original paper, page 7 · Answer key