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 |
Explanation:
- Pre-emptive shortest job first (SJF) is also known as shortest remaining time first.
- Gantt chart always starts from zero.
- The process
P1arrives at CPU at time unit0with burst time of7units, it get executed for1unit of time. Now the remaining burst time of processP1is6. - At time unit
2processP2also arrives at the CPU with burst time of4units less than the burst time ofP1, soP1will be preempt andP2will start executing, it will get executed completely and terminated because no other process have less burst time then it. - Process
P3has 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
P1have burst time of6unit left andP3have8units of burst time. So,P1will again start its execution till it ends. -
P1ends at time unit11and thenP3start 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




Top comments (0)