This is a multipart blog article series, and in this series I am going to explain you the concepts of operating system. This article series is divided into multiple modules and this is the second module which consists of 11 articles.
In this article we will see a question on shortest job first and try to understand the concepts of SJF operation in an operating system.
Question: The gantt chart for pre-emptive shortest job first scheduling algorithm will be?
Process No. | Arrival time | Burst time | |
P1 | 0 | 7 | |
P2 | 1 | 4 | |
P3 | 2 | 8 |
i.)
ii.)
iii.)
iv.)
Answer: (iv.)
Explanation:
- Pre-emptive shortest job first (SJF) is also known as shortest remaining time first.
- Gantt chart always starts from zero.
- The process
P1
arrives at CPU at time unit0
with burst time of7
units, it get executed for1
unit of time. Now the remaining burst time of processP1
is6
. - At time unit
2
processP2
also arrives at the CPU with burst time of4
units less than the burst time ofP1
, soP1
will be preempt andP2
will start executing, it will get executed completely and terminated because no other process have less burst time then it. - Process
P3
has already arrived to CPU at time unit2
. - If we check the time units of the both the processes present in the ready queue, we see that
P1
have burst time of6
unit left andP3
have8
units of burst time. So,P1
will again start its execution till it ends. P1
ends at time unit11
and thenP3
start its execution and get terminate at time unit19
.
So, this was all about pre-emptive shortest job first CPU scheduling algorithm in an operating system. Hope you liked it and learned something from it.
If you have any doubt, question, queries related to this topic or just want to share something with me, then please feel free to contact me.
๐ฑ Contact Me
Twitter, LinkedIn, Telegram, Instagram,