Site icon T4Tutorials.com

Round Robin scheduling Exercise with solution

Question 1:

Given the following processes with their arrival times and burst times, calculate the turnaround time and waiting time for each process using – Round Robin scheduling with a time quantum of 3 units.

Process ID Arrival Time Burst Time
P1 0 5
P2 1 4
P3 2 6
P4 3 2

Steps to Solve

  1. Construct the Gantt Chart:
    • Process the tasks in order of their arrival and given burst times.
  2. Track remaining times and process scheduling:
    • P1: Remaining time 5
    • P2: Remaining time 4
    • P3: Remaining time 6
    • P4: Remaining time 2

Gantt Chart Construction

Using a time quantum of 3 units:

Calculate Turnaround and Waiting Times

Turnaround Time (TAT) = Completion Time – Arrival Time
Waiting Time (WT) = Turnaround Time – Burst Time

P1:

Completion Time = 12

Turnaround Time = 12 – 0 = 12

Waiting Time = 12 – 5 = 7

P2:

Completion Time = 13

Turnaround Time = 13 – 1 = 12

Waiting Time = 12 – 4 = 8

P3:

Completion Time = 15

Turnaround Time = 15 – 2 = 13

Waiting Time = 13 – 6 = 7

P4:

Completion Time = 10

Turnaround Time = 10 – 3 = 7

Waiting Time = 7 – 2 = 5

Summary

Process ID Arrival Time Burst Time Completion Time Turnaround Time Waiting Time
P1 0 5 12 12 7
P2 1 4 13 12 8
P3 2 6 15 13 7
P4 3 2 10 7 5

Average Times

Output

Process | Turnaround Time | Waiting Time
P1 | 12 | 7
P2 | 12 | 8
P3 | 13 | 7
P4 | 7 | 5

Average Waiting Time= 6.75
Average Turnaround Time = 11.0

Question 2:

Consider the following set of processes that arrive at different times. Calculate the average waiting time and average turnaround time using Round Robin scheduling with a time quantum of 4 units.

Process ID Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
P5 6 6

Steps to Solve

  1. Construct the Gantt Chart:
    • Process the tasks in order of their arrival and given burst times.
  2. Track remaining times and process scheduling:
    • P1: Remaining time 7
    • P2: Remaining time 4
    • P3: Remaining time 1
    • P4: Remaining time 4
    • P5: Remaining time 6

Gantt Chart Construction

Using a time quantum of 4 units:

Calculate Turnaround and Waiting Times

Turnaround Time (TAT) = Completion Time – Arrival Time
Waiting Time (WT) = Turnaround Time – Burst Time

P1:

Completion Time = 20

Turnaround Time = 20 – 0 = 20

Waiting Time = 20 – 7 = 13

P2:

Completion Time = 8

Turnaround Time = 8 – 2 = 6

Waiting Time = 6 – 4 = 2

P3:

Completion Time = 9

Turnaround Time = 9 – 4 = 5

Waiting Time = 5 – 1 = 4

P4:

Completion Time = 13

Turnaround Time = 13 – 5 = 8

Waiting Time = 8 – 4 = 4

P5:

Completion Time = 22

Turnaround Time = 22 – 6 = 16

Waiting Time = 16 – 6 = 10

Summary

Process ID Arrival Time Burst Time Completion Time Turnaround Time Waiting Time
P1 0 7 20 20 13
P2 2 4 8 6 2
P3 4 1 9 5 4
P4 5 4 13 8 4
P5 6 6 22 16 10

Average Times

Output

Process | Turnaround Time | Waiting Time
P1      | 20              | 13
P2      | 6               | 2
P3      | 5               | 4
P4      | 8               | 4
P5      | 16              | 10

Average Waiting Time= 6.6
Average Turnaround Time = 11.0
Exit mobile version