Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Priority Preemptive Scheduling

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   
like image 388
raphnguyen Avatar asked Feb 11 '12 19:02

raphnguyen


2 Answers

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
like image 79
Johannes Weiss Avatar answered Oct 09 '22 04:10

Johannes Weiss


| p1 | p2 | p3 | p1 |

0....2....8....11...14   

taking 1 as the highest priority.

like image 26
Mayank Avatar answered Oct 09 '22 02:10

Mayank