1

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
Box Box Box Box
  • 5,094
  • 10
  • 49
  • 67
Pred
  • 11
  • 1
  • 2

1 Answers1

0

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.

caskey
  • 12,305
  • 2
  • 26
  • 27
  • So that would mean the Gantt chart will look like this? |p3|p5|p0|p2|p4|p1| – Pred Sep 03 '13 at 02:23
  • 1
    Sounds like homework to me. If so I suggest you discuss with someone else in your class. I've never used gantt charts to represent process scheduling. – caskey Sep 03 '13 at 02:26
  • yeah it's an assignment where I have to do the cpu-scheduling in c++. I got fcfs and round robin to work but I just dont understand Priority based preemptive Shortest Job First and I needed some examples to check whether the coding gives the correct answer – Pred Sep 03 '13 at 02:40
  • Your text and/or lecture notes should have a couple examples for you to work with. The list you gave above looks correct for the scheduling of your original table. Good luck. – caskey Sep 03 '13 at 02:47