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
- Construct the Gantt Chart:
- Process the tasks in order of their arrival and given burst times.
- 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:- Time 0-3: P1 runs for 3 units (remaining time 2)
- Time 3-6: P2 runs for 3 units (remaining time 1)
- Time 6-9: P3 runs for 3 units (remaining time 3)
- Time 9-10: P4 runs for 2 units (remaining time 0, complete)
- Time 10-12: P1 runs for 2 units (remaining time 0, complete)
- Time 12-13: P2 runs for 1 unit (remaining time 0, complete)
- Time 13-15: P3 runs for 3 units (remaining time 0, complete)
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 = 5Summary
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
- Average Turnaround Time = (12 + 12 + 13 + 7) / 4 = 44 / 4 = 11.0
- Average Waiting Time = (7 + 8 + 7 + 5) / 4 = 27 / 4 = 6.75
Output
1 2 3 4 5 6 7 8 |
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
- Construct the Gantt Chart:
- Process the tasks in order of their arrival and given burst times.
- 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:- Time 0-4: P1 runs for 4 units (remaining time 3)
- Time 4-8: P2 runs for 4 units (remaining time 0, complete)
- Time 8-9: P3 runs for 1 unit (remaining time 0, complete)
- Time 9-13: P4 runs for 4 units (remaining time 0, complete)
- Time 13-17: P5 runs for 4 units (remaining time 2)
- Time 17-20: P1 runs for 3 units (remaining time 0, complete)
- Time 20-22: P5 runs for 2 units (remaining time 0, complete)
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 = 10Summary
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
- Average Turnaround Time = (20 + 6 + 5 + 8 + 16) / 5 = 55 / 5 = 11.0
- Average Waiting Time = (13 + 2 + 4 + 4 + 10) / 5 = 33 / 5 = 6.6
Output
1 2 3 4 5 6 7 8 9 |
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 |