Priority Preemptive Scheduling

raphnguyen picture raphnguyen · Feb 11, 2012 · Viewed 64.5k times · Source

When using Priority Preemptive Scheduling, does a higher priority yield way to a process with a lower priority but with a shorter burst time?

For example, if I had:

    Arrival Time   Burst Time   Priority
P1       0             5           3
P2       2             6           1
P3       3             3           2

Would the Gannt chart look like this?

| P1 | P2 | P3 | P1 |
0    2    8   11   16   

Answer

Johannes Weiss picture Johannes Weiss · Feb 11, 2012

Priority Scheduling always selects the process(es) with the highest priority currently ready to run. If there is more than one process having the currently highest priority, you need a second scheduling algorithm to choose among these processes. Non-preemptive Priority Scheduling only selects a new process to run if the running process finished its work or yields (voluntarily) to the scheduler.

Preemptive Priority Scheduling is the same algorithm but if a new process having a higher priority than the currently running process arrives, it gets selected immediately. The new process has not to wait until the currently running process finishes or yields.

In your sample, the Gantt chart for Preemptive Priority Scheduling and 3 being the highest and 1 the lowest priority would look like:

|    P1   |  P3 |        P2      |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14