How to Calculate Turnaround Time and Waiting Time in Round Robin Scheduling

412.5K views
•
October 8, 2019
by
Neso Academy
YouTube video player
How to Calculate Turnaround Time and Waiting Time in Round Robin Scheduling

TL;DR

Calculate round-robin turnaround time as completion time minus arrival time, then calculate waiting time as turnaround time minus burst time. For P1, P2, and P3, which all arrive at time 0, use a 4-millisecond quantum to build the Gantt chart and find completion times of 30, 7, and 10 milliseconds. Read on for the complete schedule and each process’s turnaround and waiting times.

Transcript

in the previous lecture we have studied about round-robin scheduling and we have seen how it works so in this lecture we will be seeing how we can calculate the turnaround time and waiting time for a round-robin scheduling so we will be taking an example of a CPU that follows a round-robin scheduling and we will see how we can calculate the turnaro... Read More

Key Insights

  • Round-robin scheduling is based on a fixed time quantum that limits how long each process may use the CPU during one turn. When an unfinished process reaches that limit, it is preempted and placed at the end of the ready queue.
  • The example uses three processes that all arrive at time 0. P1 has a burst time of 24 milliseconds, while P2 and P3 each have a burst time of 3 milliseconds, and the scheduling time quantum is 4 milliseconds.
  • The Gantt chart is the first step in calculating turnaround and waiting times. It records which process uses the CPU during each interval and reveals the point at which every process finishes its complete burst.
  • P1 executes from 0 to 4 milliseconds during its first turn. Because its total burst is 24 milliseconds, it remains unfinished with 20 milliseconds of execution left and is moved behind P2 and P3 in the queue.
  • P2 executes from 4 to 7 milliseconds and P3 executes from 7 to 10 milliseconds. Each process releases the CPU after 3 milliseconds because its entire burst is shorter than the 4-millisecond quantum.
  • P1 continues after P2 and P3 have completed, executing during 10–14, 14–18, 18–22, 22–26, and 26–30 milliseconds. Even when no other process is waiting, its execution is represented in separate 4-millisecond quantum intervals.
  • Completion time is determined by the end of a process’s final appearance in the Gantt chart. The resulting completion times are 30 milliseconds for P1, 7 milliseconds for P2, and 10 milliseconds for P3.
  • Turnaround time is completion time minus arrival time, and waiting time is turnaround time minus burst time. Because every process in the example arrives at time 0, each process’s turnaround time is numerically equal to its completion time.

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: How do you calculate turnaround time in round-robin scheduling?

First build the round-robin Gantt chart and identify when each process completes. Subtract its arrival time from its completion time: turnaround time equals completion time minus arrival time. Because P1 arrives at time 0 and completes at 30 milliseconds, its turnaround time is 30 milliseconds.

Q: How do you calculate waiting time in round-robin scheduling?

Subtract the process’s total CPU burst time from its turnaround time. P1 has a turnaround time of 30 milliseconds and a burst time of 24 milliseconds, so its waiting time is 6 milliseconds.

Q: How is the Gantt chart formed for P1, P2, and P3?

P1 runs from 0 to 4 milliseconds, P2 from 4 to 7, and P3 from 7 to 10. P1 then runs during 10–14, 14–18, 18–22, 22–26, and 26–30 milliseconds until its 24-millisecond burst is complete.

Q: What happens when a process does not finish within the time quantum?

The process is preempted when its time quantum expires, and the CPU is assigned to the next process in the queue. The unfinished process is placed at the end of the ready queue. After P1 runs for 4 milliseconds, it has 20 milliseconds remaining and moves behind P2 and P3.

Q: Why do P2 and P3 run for only 3 milliseconds each?

P2 and P3 each have a burst time of 3 milliseconds, which is shorter than the 4-millisecond quantum. Each finishes within its first turn and voluntarily releases the CPU instead of using the full quantum.

Q: What happens when only P1 remains in the round-robin schedule?

P1 continues executing in 4-millisecond quantum intervals after P2 and P3 finish. Because no other process is waiting, P1 receives the CPU again after every interval and continues until it completes at 30 milliseconds.

Q: What are the completion times of P1, P2, and P3?

A process’s completion time is the ending time of its final occurrence in the Gantt chart. P1 completes at 30 milliseconds, P2 at 7 milliseconds, and P3 at 10 milliseconds.

Q: What are the turnaround and waiting times for all three processes?

Because all three processes arrive at time 0, their turnaround times equal their completion times: P1 is 30 milliseconds, P2 is 7 milliseconds, and P3 is 10 milliseconds. Their waiting times are turnaround time minus burst time: 6 milliseconds for P1, 4 milliseconds for P2, and 7 milliseconds for P3.

Summary & Key Takeaways

  • Round-robin scheduling assigns the CPU to each ready process for a defined time quantum. In the example, the quantum is 4 milliseconds, and all three processes arrive at time 0. A process that remains unfinished after its quantum expires is preempted and placed at the end of the ready queue.

  • The Gantt chart begins with P1 from 0 to 4 milliseconds, P2 from 4 to 7, and P3 from 7 to 10. P2 and P3 finish within their first turns because each needs only 3 milliseconds. P1 continues in 4-millisecond segments until completing at 30 milliseconds.

  • Completion time is found from the final occurrence of each process in the Gantt chart. P1, P2, and P3 complete at 30, 7, and 10 milliseconds, respectively. Turnaround time equals completion time minus arrival time, while waiting time equals turnaround time minus the process’s total CPU burst time.


Read in Other Languages (beta)

Share This Summary 📚

Explore More Summaries from Neso Academy 📚