Back to the 2023 paper

Module 2: Processes & Scheduling

20237m

Consider the following four processes with following details (time given in ms):

Process Arrival Time CPU Burst Time
P1 0 12
P2 0 10
P3 1 4
P4 4 10
P5 2 12

Draw the Gantt chart using RR scheduling with time slice 3ms. Calculate average waiting time and average turn-around time.

Worked SolutionAI Assisted

Answer

Note: Question states “four processes” but lists five (P1–P5). Solution is given for all five as per table.

Time quantum q=3 msq = 3\,ms. Arrival Times (AT) and Burst Times (BT) as given.

Process AT BT
P1 0 12
P2 0 10
P3 1 4
P4 4 10
P5 2 12

Assumptions

  • Arrival order for same AT: P1 before P2.
  • New arrivals during a quantum are enqueued before the preempted process is appended to the ready queue (standard RR).
  • Context switch overhead = 0.

Step-by-Step Execution

Time Running Ready Queue after slice Remarks
0–3 P1 (12→9) [P2, P3, P5, P1] P3 (1), P5 (2) arrived
3–6 P2 (10→7) [P3, P5, P1, P4, P2] P4 (4) arrived
6–9 P3 (4→1) [P5, P1, P4, P2, P3]
9–12 P5 (12→9) [P1, P4, P2, P3, P5]
12–15 P1 (9→6) [P4, P2, P3, P5, P1]
15–18 P4 (10→7) [P2, P3, P5, P1, P4]
18–21 P2 (7→4) [P3, P5, P1, P4, P2]
21–22 P3 (1→0) completes at 22 [P5, P1, P4, P2] Quantum truncated to 1
22–25 P5 (9→6) [P1, P4, P2, P5]
25–28 P1 (6→3) [P4, P2, P5, P1]
28–31 P4 (7→4) [P2, P5, P1, P4]
31–34 P2 (4→1) [P5, P1, P4, P2]
34–37 P5 (6→3) [P1, P4, P2, P5]
37–40 P1 (3→0) completes at 40 [P4, P2, P5]
40–43 P4 (4→1) [P2, P5, P4]
43–44 P2 (1→0) completes at 44 [P5, P4]
44–47 P5 (3→0) completes at 47 [P4]
47–48 P4 (1→0) completes at 48 []

Gantt Chart

0   3   6   9  12  15  18  21 22  25  28  31  34  37  40  43 44  47 48
|P1 |P2 |P3 |P5 |P1 |P4 |P2 |P3|P5 |P1 |P4 |P2 |P5 |P1 |P4 |P2|P5 |P4|

Mermaid:

MermaidDiagram
Rendering diagram…

Calculation Table

PID AT BT CT TAT = CT−AT WT = TAT−BT
P1 0 12 40 40 28
P2 0 10 44 44 34
P3 1 4 22 21 17
P4 4 10 48 44 34
P5 2 12 47 45 33
Sum 48 194 146

Final Answer

  • Average Turn-Around Time =1945=38.8 ms= \dfrac{194}{5} = \mathbf{38.8\,ms}
  • Average Waiting Time =1465=29.2 ms= \dfrac{146}{5} = \mathbf{29.2\,ms}

If strictly only four processes are considered (excluding P5), CTs are P1=28, P2=32, P3=10, P4=36 → Avg TAT = 26.5 ms, Avg WT = 18.5 ms (quantum 3).

Similar questions

Operating SystemConsider the following CPU processes with arrival times 0 and CPU bursts (in milliseconds) as given below: | Process | Burst time | |---|---| | P1 | 24 | | P2 | 3 | | P3 | 3 | If the Round Robin Scheduling is used with time quantum of 4 milliseconds to schedule the processes. Draw the Gantt chart and calculate the average waiting time across all processes (in milliseconds).20227mOperating SystemConsider the following set of processes with the length of the CPU burst given in milliseconds: | Process | Burst Time | Priority | | :---: | :---: | :---: | | A | 10 | 3 | | B | 1 | 1 | | C | 2 | 3 | | D | 1 | 4 | | E | 5 | 2 | The processes are assumed to have arrived in order A, B, C, D, E all at time 0. Draw the Gantt charts that illustrate the execution of SJF scheduling algorithm. Show which algorithm results in the minimum average waiting time.20257mOperating SystemConsider the following process : | Process | Arrival Time | Burst Time | | :--- | :--- | :--- | | P1 | 0.0 | 7 | | P2 | 2.0 | 4 | | P3 | 4.0 | 1 | | P4 | 5.0 | 4 | Considering non-preemptive and preemptive SJF algorithm, find out average waiting time and average turnaround time in both cases.201914mOPERATING SYSTEMConsider the following process: | Process | Arrival Time | Burst Time | | :--- | :--- | :--- | | P1 | 0.0 | 7 | | P2 | 2.0 | 4 | | P3 | 4.0 | 1 | | P4 | 5.0 | 4 | Considering non-preemptive and preemptive SJF algorithm, find out average waiting time and average turnaround time in both cases.201914m
Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.