Prerequisite – CPU Scheduling
List Scheduling also know as Priority List Based Scheduling is a scheduling technique in which an ordered list of processes are made by assigning them some priorities.
So, basically what happens is, a list of processes that are ready to be executed at a given point is made. And then depending on the availability of processors i.e, whether they are free or busy, if processors are free they pick the processes and execute them.
Let us now understand the List Scheduling using one example.
Suppose we have 7 processes P1, P2, P3, P4, P5, P6, P7 such that –
- P3 is dependent on P1 and P2 (P3 can start its execution only when both P1 and P2 completes its execution.).
- P4 is dependent on P3 and P6 (P4 can start its execution only when both P3 and P6 completes its execution.).
- P6 is dependent on P5.
Dependencies are shown below in the figure.
Lets us assume that we have constraint of two processors and we are having both processors free.
Since P1, P2, P5, P7 are independent, lets us assume are they are initially waiting in the ready list and are ready for execution.
Step by step execution of the processes :
- We have only two free processors, so let P1 and P2 gets executed first.
- P1 and P2 goes out of ready list and P3 comes in ready list. So P3, P5, P7 are in ready list now
- Lets assume out of 3 processes present in ready queue, P3 and P5 gets executed next, so P3 and P5 goes out of ready list and P6 comes in ready list. P4 will not come in ready list because it depends on P6 also which is not executed yet.
- P6 and P7 are in ready list now. So P6 and P7 gets executed next.
- P6 and P7 goes out of ready list and P4 comes in ready list and finally P4 gets executed and all the processes terminates .
Ready list is shown below at each step is shown in figure:
So you can see that after 4 unit time the whole processes gets executed. But this time may vary depending upon the scheduling mechanism operating system is using.
Explanation showing execution time depends on scheduling algorithms used.
- Consider the case when same process starts with execution of P5 and P7 first this time instead of P1 and P2 .
- After that P5 and P7 comes out of ready list and P6 comes into ready list.
- P1, P2, P6 are in ready list now. Let P2 and P6 gets executed.
- P2 and P6 comes out of ready list. P1 gets executed then.
- P1 comes out of ready list and P3 comes in the ready list and then P3 gets executed.
- Finally P4 gets executed and all processes get executed.
Ready list for this process is shown below:
So you can see this time that 5 units of time are taken if we change the order of processes in which they gets executed.
The priorities are determined statically before scheduling process begins. The first step chooses the process with the highest priority, the second step selects the best possible resource. Some of the scheduling strategies that can be used are:
- Longest path algorithm
- Longest processing time
- Critical path method
Goal of algorithm is to maximize CPU utilization and minimize the delay.So whichever Scheduling algorithm helps to achieve this can used depending on the processes.