Priority based preemptive Shortest Job First. How to determine what process comes first

9.2k views Asked by At

I have a question for Priority based preemptive Shortest Job First algorithm. If two processes have the same priority, who is the one to go first. The one that was put in first or the one with smaller burst time? Same goes with burst time if I have 2 processes with same burst time do I sort by priority? And what happens if 2 processes have same burst time and priority?

For example what would a Gantt chart based on this table look like?

           Arrival Time    Burst Time    Priority
p0              0              8            2
p1              4              15           5
p2              7              9            3
p3              13             5            1
p4              9              13           4
p5              0              6            1
1

There are 1 answers

4
caskey On

As the name implies, you first pick the set of highest priority jobs.

Then, from that set you select the shortest job. In this case I presume 'burst time' represents the expected execution time (or time to yield).

Therefore assuming that your lower priority numbers represent 'higher' priority jobs, p3 and p5 are the two highest priority jobs.

At that point, what matters is the expected job size (burst time) at which point you select the one with the shortest burst time. In this case it would be p3.