What is the Turnaround Time in OS?

What-is-Turnaround-Time-in-OS-Operating-System-.jpg

Turnaround time is a very important metric used to calculate the efficiency of a scheduling algorithm in operating system and help the developers decide which algorithm they use like waiting time (the duration a process spent waiting in the ready queue), burst time (the actual CPU execution time required for the process), completion time (the exact time the process finished its execution), and arrival time (the moment the process entered the ready queue and requested the CPU). In this article, you will learn everything about turnaround time and be able to calculate the turnaround time in OS.

Table of Contents

What is the Turnaround Time in Operating System?

Turnaround time is a performance metric that evaluates the efficiency of a CPU scheduling algorithm. It represents the total time a process spends within the system. Turnaround time is the time taken by a process from when it arrives to when it completes execution. This duration includes all time spent waiting in queues, executing on the CPU, and performing any I/O operations.

Master C & Data Structures – Become a Problem-Solving Pro!
Enroll Now and level up your C skills with confidence!
quiz-icon

Why Does Turnaround Time Matter in Operating Systems?

Turnaround Time (TAT) is an important metric in operating systems. It is important to design an efficient system that delivers results faster. Turnaround Time measures how quickly the system processes and completes tasks from start to finish. It helps assess and design a better system.

By reducing the turnaround time(the total time processes spend in the system), we can better utilize all the resources (CPU, memory, and I/O devices). It increases the overall throughput of the system.

Hence, minimizing Turnaround Time is a fundamental goal for operating system designers and directly impacts how responsive and productive a computer system feels.

Turnaround Time Formula

To calculate the turnaround time for a process, use the formula:

Turnaround Time (TAT) = Completion Time (CT)- Arrival Time (AT)

It can also be calculated using the other formula:

Turnaround Time (TAT) = Waiting Time (WT) + Burst Time (BT)

This means that the total time a process spends in the system is simply the sum of the time it spends waiting and the time it spends executing on the CPU.

What is Burst Time?

Burst Time (BT) is also known as Execution Time or CPU Time, which is the total amount of CPU time (represented in milliseconds or seconds) that a process requires to complete its execution. It is the actual time the process spends actively using the CPU.

What is Waiting Time?

Waiting Time is the total amount of time a process spends idly (without doing anything) in the ready queue to get executed by the CPU. It represents the time a process spends in the ready queue.

How to Calculate Turnaround Time with Examples

Let us understand how to calculate the turnaround time with the help of an example. We will first calculate the turnaround time for a single process, and then we will look at an FCFS scheduling algorithm example. We will draw a Gantt chart to visualize the execution. We will use the formula that was discussed in the previous section.

1. Using Single Process

Let us assume a non-preemptive process scheduling example. Imagine a single process, P1, arrives at time 0 and requires 5 units of CPU time to complete. Since it is the only process, it runs immediately and finishes without interruption. From the question, we have the following information:

  • Process: P1
  • Arrival Time (AT): 0
  • Burst Time (BT): 5

Gantt Chart:

Ganttv Chart

2. Using Multiple Processes (FCFS Scheduling Algorithm)

Consider the following scenario: Three processes arrive at three different times that are handled by the First Come First Serve (FCFS) scheduling algorithm. For this example, we will use the formula Turnaround Time (TAT) = Completion Time (CT) – Arrival Time (AT). Their burst times are also given in the table below, which will help us calculate the completion time (CT).

Get 100% Hike!

Master Most in Demand Skills Now!

Process Arrival Time (AT) Burst Time (BT)
P1 0 3
P2 1 6
P3 4 2

Step 1:

Since P1 came first, by the rule of the FCFS scheduling algorithm, it will get the CPU first. After the execution of P1, the completion time (CT), the arrival time (AT), and the turnaround time (TAT) are as follows.

  • CT = 0 + 3 = 3
  • AT = 0
  • TAT = 3 – 0 = 3 units

Step 2:

P2 is scheduled next

  • AT = 1 units

Since the process arrived at 1 unit of time, therefore, P2 will have to wait until the CPU is free, which is after 2 units of time. After the execution, the CT and TAT are:

  • CT = 3 + 6 = 9
  • TAT = 9 – 1 = 8 units

Step 3:

Now, the final process, P3, will run, which has arrived at 4 units of time. Therefore, the arrival time is

  • AT = 4 units

Therefore, the process will wait till the CPU is free. Process P2 finishes at 9 units and releases the CPU. Once the CPU is released, P3 is assigned the CPU. After the completion of the process, the TAT and the CT are

  • CT = 9 + 2 = 11 units
  • TAT = 11 – 4 = 7 units

Average Turnaround Time = (3+8+7)/3 = 18/3 = 6 units

Difference between Completion Time and Turnaround Time.

Beginners usually confuse the completion time and the turnaround time. Let us look at the difference between the completion time and the turnaround time so that, as a beginner, you won’t use them interchangeably.

Aspect Completion Time (CT) Turnaround Time (TAT)
Definition The time when a process finishes Time from arrival to completion
Formula — (Not derived) CT – Arrival Time
Depends On Execution end time CT and Arrival Time
Unit Time (e.g., ms, sec) Time (same as CT)
Used For Knowing the process finish point Measuring total process duration
Example CT = 12 Arrival = 2, CT = 12 → TAT = 10

Difference Between Turnaround Time, Waiting Time, and Burst Time

Let us look at the difference between the turnaround time, burst time, and waiting time.

Aspect Turnaround Time (TAT) Waiting Time (WT) Burst Time (BT)
Definition Total time from arrival to completion Time spent waiting in the ready queue Time required for execution (CPU time)
Formula CT – Arrival Time TAT – BT TAT – WT
Includes Waiting + Execution time Only waiting time Only execution time
Depends On CT and Arrival Time TAT and BT Fixed per process
Used For Measuring total turnaround Evaluating scheduler performance Estimating CPU load
Example CT=10, AT=2 → TAT=8 TAT=8, BT=5 → WT=3 Execution Time = 5

Conclusion

We covered everything you need to calculate the turnaround time in OS. We understood why it is important to minimize the turnaround time (TAT) for better performance of the resources. With the help of examples, we understood how to calculate the TAT with the first-come, first-served CPU scheduling algorithm. We also distinguished between the arrival time, burst time, and waiting time that beginners generally confuse. Understanding and mastering turnaround time helps developers and system administrators to fine-tune the scheduling algorithm they use, which leads to more responsive, productive, and efficient computing environments.

What is Turnaround Time in OS – FAQs

Q1. What is turnaround time in OS?

Turnaround time is the total time taken from process submission to its completion, including waiting and execution time.

Q2. What is the turnaround time of software?

It refers to the total time taken by software to complete a task or process, from start to finish.

Q3. How do you calculate turnaround time?

You calculate it using Turnaround Time = Completion Time – Arrival Time

Q4. What is turnaround time in FCFS?

In FCFS scheduling, turnaround time is the total time each process spends in the system, based on the order of arrival.

Q5. What is a turnaround time example?

If a process arrives at time 0 and finishes at time 10, its turnaround time is 10 – 0 = 10 units.

About the Author

Senior Consultant Analytics & Data Science, Eli Lilly and Company

Sahil Mattoo, a Senior Software Engineer at Eli Lilly and Company, is an accomplished professional with 14 years of experience in languages such as Java, Python, and JavaScript. Sahil has a strong foundation in system architecture, database management, and API integration. 

fullstack