Difference between EDF and LST CPU scheduling algorithms
1. Earliest Deadline First (EDF) :
In Earliest Deadline First scheduling algorithm, at every scheduling point the task having the shortest deadline is scheduled for the execution. It is an optimal dynamic priority-driven scheduling algorithm used in real-time systems. It uses priorities of the tasks for scheduling. In EDF, priorities to the task are assigned according to the absolute deadline. The task having shortest deadline gets the highest priority.
Suppose here are two processes P1 and P2.
Let the period of P1 be p1 = 50
Let the processing time of P1 be t1 = 25
Let the period of P2 be p2 = 75
Let the processing time of P2 be t2 = 30
- Deadline pf P1 is earlier, so priority of P1>P2.
- Initially P1 runs and completes its execution of 25 time.
- After 25 times, P2 starts to execute until 50 times, when P1 is able to execute.
- Now, comparing the deadline of (P1, P2) = (100, 75), P2 continues to execute.
- P2 completes its processing at time 55.
- P1 starts to execute until time 75, when P2 is able to execute.
- Now, again comparing the deadline of (P1, P2) = (100, 150), P1 continues to execute.
- Repeat the above steps.
- Finally at time 150, both P1 and P2 have the same deadline, so P2 will continue to execute till its processing time after which P1 starts to execute.
2. Least Slack Time (LST) :
In Least Slack Time scheduling algorithm, at every scheduling point the task having the minimum laxity is executed first. It is also a dynamic priority-driven scheduling algorithm used in real-time systems. It assigns some priority to all the tasks in the system according to their slack time. The task having the least slack time (laxity) gets the highest priority.
Arrival Time=0, Duration=10, Deadline=33
Arrival Time=4, Duration=3, Deadline=28
Arrival Time=5, Duration=10, Deadline=29
- At time t=0:
Only process P1 has arrived.
P1 is executed till time t=4.
- At time t=4: P2 has arrived.
Slack time of P1: 33-4-6=23
Slack time of P2: 28-4-3=21
Hence P2 starts to execute till time t=5 when P3 arrives.
- At time t=5:
Slack Time of P1: 33-5-6=22
Slack Time of P2: 28-5-2=21
Slack Time of P3: 29-5-10=12
Hence P3 starts to execute till time t=13
- At time t=13:
Slack Time of P1: 33-13-6=14
Slack Time of P2: 28-13-2=13
Slack Time of P3: 29-13-2=14
Hence P2 starts to execute till time t=15
- At time t=15:
Slack Time of P1: 33-15-6=12
Slack Time of P3: 29-15-2=12
Hence P3 starts to execute till time t=16
- At time t=16:
Slack Time of P1: 33-16-6=11
Slack Time of P3:29-16-=12
Hence P1 starts to execute till time t=18 and so on.
Difference between EDF and LST scheduling algorithms :
|Task having shortest deadline is scheduled first in it.||Task having minimum slack time is scheduled first in it.|
|It assigns priority to tasks according to their deadlines.||It assigns tasks according to their slack time.|
|It can be used as both static and dynamic scheduling.||It is used only as dynamic scheduling.|
|Execution time of a task is not required.||It requires execution time of a task.|
|It is a simple and optimal algorithm.||It is a complex algorithm.|
|It can be implemented on any set of tasks.||It can only be implemented on set of tasks having their burst time.|
|It completely utilizes the CPU (even sometimes 100%).||It may under-utilize the CPU.|
|It increases the efficiency and throughput of the processor.||It may decrease the efficiency and throughput of the processor.|