The arrival time, priority, and duration of the CPU and I/O bursts for each of…

2006

The arrival time, priority, and duration of the CPU and I/O bursts for each of three processes P1, P2 and P3 are given in the table below. Each process has a CPU burst followed by an I/O burst followed by another CPU burst. Assume that each process has its own I/O resource.

2006_54

The multi-programmed operating system uses preemptive priority scheduling. What are the finish times of the processes P1, P2 and P3 ?

  1. A.

    11, 15, 9

  2. B.

    10, 15, 9

  3. C.

    11, 16, 10

  4. D.

    12, 17, 11

Attempted by 51 students.

Show answer & explanation

Correct answer: B

Answer: Finish times — P1 = 10, P2 = 15, P3 = 9.

Key points: preemptive priority scheduling is used (priority 1 is highest). Each process has CPU→I/O→CPU and a separate I/O device, so I/O runs in parallel and does not block other processes from using the CPU.

  • Time 0–1: P1 runs its first CPU burst (1) and then goes to I/O for 5 units (I/O from 1–6).

  • Time 2: P2 arrives and starts its first CPU burst (3). It runs from 2–3 (1 unit done, 2 units remaining).

  • Time 3: P3 arrives with highest priority and preempts P2. P3 runs its first CPU (2) from 3–5, then goes to I/O from 5–8.

  • Time 5: P2 resumes and runs 5–6 (one more unit), leaving 1 unit of its first CPU. At time 6 P1 returns from I/O and, having higher priority than P2, preempts P2.

  • Time 6–8: P1 runs its second CPU burst; it executes 2 of the 3 units (one unit remains at time 8).

  • Time 8: P3 finishes I/O and, being highest priority, preempts P1. P3 runs its final CPU (1) from 8–9 and completes at 9.

  • Time 9–10: P1 resumes and completes its remaining 1 unit, finishing at 10.

  • Time 10–11: P2 completes its remaining 1 unit of the first CPU burst (finishes CPU1 at 11), then does I/O 11–14 and its final CPU (1) at 14–15, finishing at 15.

Therefore the completion times are: P1 = 10, P2 = 15, P3 = 9.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir