**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.

**Example –**

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

**Explanation :**

- 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.

**Example –**

Process P1:

Arrival Time=0, Duration=10, Deadline=33

Process P2:

Arrival Time=4, Duration=3, Deadline=28

Process P3:

Arrival Time=5, Duration=10, Deadline=29

**Explanation :**

- 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 :**

EDF | LST |
---|---|

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. |

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Difference between SJF and LJF CPU scheduling algorithms
- Difference between SJF and SRJF CPU scheduling algorithms
- Difference between FCFS and SJF CPU scheduling algorithms
- Difference between LOOK and C-LOOK Disk scheduling algorithms
- Difference between LJF and LRJF CPU scheduling algorithms
- Difference between SCAN and LOOK Disk scheduling algorithms
- Difference between SRJF and LRJF CPU scheduling algorithms
- Difference between Shortest Job First (SJF) and Round-Robin (RR) scheduling algorithms
- Difference between First Come First Served (FCFS) and Longest Job First (LJF) CPU scheduling algorithms
- Difference between FCFS and SCAN disk scheduling algorithms
- Difference between Longest Job First (LJF) and Round Robin (RR) scheduling algorithms
- Difference between SCAN and CSCAN Disk scheduling algorithms
- Difference between Multi Level Queue (MLQ) Scheduling and Round Robin (RR) algorithms
- Difference between Multi Level Queue Scheduling (MLQ) and Priority Scheduling
- Difference between Priority Scheduling and Round Robin (RR) CPU scheduling
- Difference between Multilevel Queue (MLQ) and Multi Level Feedback Queue (MLFQ) CPU scheduling algorithms
- Difference between Priority scheduling and Shortest Job First (SJF) CPU scheduling
- Difference between Preemptive and Non-preemptive CPU scheduling algorithms
- Disk Scheduling Algorithms
- Advantages and Disadvantages of various CPU scheduling algorithms

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.