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:
- 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.
Advantages of the EDF scheduling algorithm:
- Meeting Deadlines: EDF ensures that tasks with the earliest deadlines are executed first. By prioritizing tasks based on their deadlines, EDF minimizes the chances of missing deadlines and helps meet real-time requirements.
- Optimal Utilization: EDF maximizes CPU utilization by allowing tasks to execute as soon as their deadlines arrive, as long as the CPU is available. It optimizes the use of system resources by minimizing idle time.
- Responsiveness: EDF provides a high level of responsiveness for time-critical tasks. It ensures that tasks are scheduled and executed promptly, reducing response times and improving system performance.
- Predictability: EDF provides predictability in terms of task execution times and deadlines. The scheduling decisions are deterministic and can be analyzed and predicted in advance, which is crucial for real-time systems.
- Flexibility: EDF can handle both periodic and aperiodic tasks, making it suitable for a wide range of real-time systems. It allows for dynamic task creation and scheduling without disrupting the execution of existing tasks.
Limitations of EDF scheduling algorithm:
- Transient Overload Problem
- Resource Sharing Problem
- Efficient Implementation Problem