# GATE | GATE-CS-2006 | Question 64

Consider three processes (process id 0, 1, 2 respectively) with compute time bursts 2, 4 and 8 time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF) scheduling algorithm. In LRTF ties are broken by giving priority to the process with the lowest process id. The average turn around time is:**(A)** 13 units**(B)** 14 units**(C)** 15 units**(D)** 16 units**Answer:** **(A)****Explanation:** **Background Explanation:**

Turn around time of a process is total time between submission of the process and its completion.LRTF(Longest Remaining Time First), means the process which has remaining time largest, will run first and in case of same remaining time, lowest process with will be given priority to run.

Solution:

Let the processes be p0, p1 and p2. These processes will be executed in following order.

Gantt chart is as follows:

p2 p1 p2 p1 p2 p0 p1 p2 p0 p1 p2 0 4 5 6 7 8 9 10 11 12 13 14

First 4 sec, p2 will run, then remaining time p2=4, p1=4, p0=2. Now P1 will get chance to run for 1 sec, then remaining time. p2=4,p1=3,p0=2. Now p2 will get chance to run for 1 sec, then remaining time. p2=3,p1=3,p0=2.

By doing this way, you will get above gantt chart.

Scheduling table:

PID | AT | BT | CT | TAT=CT-AT |
---|---|---|---|---|

p0 | 0 | 2 | 12 | 12 |

p1 | 0 | 4 | 13 | 13 |

p2 | 0 | 8 | 14 | 14 |

Total | 39 |

AT=Arrival Time, BT=Burst Time, CT=Completion Time, TAT=Turn Around Time As we know, turn around time is total time between submission of the process and its completion. i.e turn around time=completion time-arrival time. i.e. TAT=CT-AT Turn around time of p0 = 12 (12-0) Turn around time of p1 = 13 (13-0) Turn around time of p2 = 14 (14-0)

Average turn around time is (12+13+14)/3 = 13. Option (A) is the correct answer.

See question 1 of http://www.geeksforgeeks.org/operating-systems-set-15/

This solution is contributed by **Nitika Bansal**

Quiz of this Question

Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in **GATE Test Series Course**.

Learn all **GATE CS concepts with Free Live Classes** on our youtube channel.