Earliest Deadline First (EDF) CPU scheduling algorithm

Earliest Deadline First (EDF) is an optimal dynamic priority scheduling algorithm used in real-time systems.
It can be used for both static and dynamic real-time scheduling.

EDF uses priorities to the jobs for scheduling. It assigns priorities to the task according to the absolute deadline. The task whose deadline is closest gets the highest priority. The priorities are assigned and changed in a dynamic fashion. EDF is very efficient as compared to other scheduling algorithms in real-time systems. It can make the CPU utilization to about 100% while still guaranteeing the deadlines of all the tasks.

EDF includes the kernel overload. In EDF, if the CPU usage is less than 100%, then it means that all the tasks have met the deadline. EDF finds an optimal feasible schedule. The feasible schedule is one in which all the tasks in the system are executed within the deadline. If EDF is not able to find a feasible schedule for all the tasks in the real-time system, then it means that no other task scheduling algorithms in real-time systems can give a feasible schedule. All the tasks which are ready for execution should announce their deadline to EDF when the task becomes runnable.

EDF scheduling algorithm does not need the tasks or processes to be periodic and also the tasks or processes require a fixed CPU burst time. In EDF, any executing task can be preempted if any other periodic instance with an earlier deadline is ready for execution and becomes active. Preemption is allowed in the Earliest Deadline First scheduling algorithm.

Example:
Consider 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 period2 = 75
Let the processing time of P2 be t2 = 30

Steps for solution:

  1. Deadline pf P1 is earlier, so priority of P1>P2.
  2. Initially P1 runs and completes its execution of 25 time.
  3. After 25 times, P2 starts to execute until 50 times, when P1 is able to execute.
  4. Now, comparing the deadline of (P1, P2) = (100, 75), P2 continues to execute.
  5. P2 completes its processing at time 55.
  6. P1 starts to execute until time 75, when P2 is able to execute.
  7. Now, again comparing the deadline of (P1, P2) = (100, 150), P1 continues to execute.
  8. Repeat the above steps…
  9. 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.

Limitations of EDF scheduling algorithm:

  • Transient Overload Problem
  • Resource Sharing Problem
  • Efficient Implementation Problem

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.



Improved By : pp_pankaj