GATE | GATE-CS-2007 | Question 85 - GeeksforGeeks

28 Jul, 2021
An operating system uses Shortest Remaining Time first (SRT) process scheduling algorithm. Consider the arrival times and execution times for the following processes:
Process  Execution time  Arrival time
P1             20            0
P2             25            15
P3             10            30
P4             15            45
What is the total waiting time for process P2?(A) 5(B) 15(C) 40(D) 55Answer: (B)Explanation: Shortest remaining time, also known as shortest remaining time first (SRTF), is a scheduling method that is a pre-emptive version of shortest job next scheduling. In this scheduling algorithm, the process with the smallest amount of time remaining until completion is selected to execute. Since the currently executing process is the one with the shortest amount of time remaining by definition, and since that time should only reduce as execution progresses, processes will always run until they complete or a new process is added that requires a smaller amount of time.
The Gantt chart of execution of processes:
At time 0, P1 is the only process, P1 runs for 15 time units.At time 15, P2 arrives, but P1 has the shortest remaining time. So P1 continues for 5 more time units.At time 20, P2 is the only process. So it runs for 10 time units.at time 30, P3 is the shortest remaining time process. So it runs for 10 time units.at time 40, P2 runs as it is the only process. P2 runs for 5 time units.At time 45, P3 arrives, but P2 has the shortest remaining time. So P2 continues for 10 more time units. P2 completes its execution at time 55.
As we know, turn around time is total time between submission of the process and its completion. Waiting time is the time The amount of time that is taken by a process in ready queue and waiting time is the difference between Turn around time and burst time.Total turnaround time for P2 = Completion time – Arrival time= 55 – 15 = 40Total Waiting Time for P2= turn around time – Burst time= 40 – 25 = 15See question 3 of https://www.geeksforgeeks.org/operating-systems-set-12/
This solution is contributed by Nitika Bansal
Watch GeeksforGeeks Video Explanation :
YouTubeGeeksforGeeks GATE Computer Science16.2K subscribersCPU Scheduling GATE Previous Year Questions with Viomesh SinghWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0030:52 / 39:01•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=y1BbjvO_xog" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2007
GATE-GATE-CS-2007
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE CS 2019 | Question 27
GATE | GATE-IT-2004 | Question 66
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2006 | Question 49
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2017 (Set 2) | Question 42
GATE | GATE CS 2021 | Set 1 | Question 47
GATE | GATE CS 2011 | Question 65
GATE | Gate IT 2007 | Question 30
GATE | GATE-CS-2000 | Question 43