The Wayback Machine - https://web.archive.org/web/20240927090055/https://www.geeksforgeeks.org/earliest-deadline-first-edf-cpu-scheduling-algorithm/
Open In App

Earliest Deadline First (EDF) CPU scheduling algorithm

Last Updated : 05 Apr, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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

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


Similar Reads

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 ar
4 min read
Deadline Monotonic CPU Scheduling
Prerequisites - CPU Scheduling Preemptive Scheduling Program for Preemptive Priority CPU Scheduling Deadline Monotonic Scheduling : It is a fixed priority based algorithm in which priorities are assigned to each task based on their relative deadline. Task with shortest deadline is assigned highest priority. It is a Preemptive Scheduling Algorithm t
3 min read
SCAN - EDF Scheduling in OS
SCAN-EDF is a disk scheduling algorithm that is the same as the EDF algorithm but utilizes the seek optimization technique of the 'SCAN' algorithm when similar deadlines occur. It is a hybrid algorithm. To understand the importance of this algorithm, let us first look at the drawbacks of strictly following the Earliest Deadline First (EDF) algorith
4 min read
Longest Remaining Time First (LRTF) or Preemptive Longest Job First CPU Scheduling Algorithm
Longest Remaining Time First (LRTF) is a preemptive version of Longest Job First (LJF) scheduling algorithm. In this scheduling algorithm, we find the process with the maximum remaining time and then process it, i.e. check for the maximum remaining time after some interval of time(say 1 unit each) to check if another process having more Burst Time
7 min read
Difference between Priority scheduling and Shortest Job First (SJF) CPU scheduling
1. Priority Scheduling Algorithm : Priority scheduling algorithm executes the processes depending upon their priority. Each process is allocated a priority and the process with the highest priority is executed first. Priorities can be defined internally as well as externally. Internal priorities are decided by the system depending upon the number o
3 min read
Difference between First Come First Served (FCFS) and Longest Job First (LJF) CPU scheduling algorithms
1.First Come First Served (FCFS) : First Come First Served (FCFS) is the simplest type of algorithm. It is a non-preemptive algorithm i.e. the process cannot be interrupted once it starts executing. The FCFS is implemented with the help of a FIFO queue. The processes are put into the ready queue in the order of their arrival time. The process that
3 min read
Difference between rate monotonic and deadline monotonic scheduling
1. Rate Monotonic Scheduling : Rate monotonic scheduling is a priority algorithm in which the priorities are assigned to the processes according to the cycle time, a process with the least task duration is given the priority. It is preemptive: the highest priority process will preempt the other processes. The priority of a process is inversely prop
2 min read
Scheduling without deadline
What is scheduling ?Scheduling is another popular problem in computer science domain. A scheduling problem is a problem of scheduling resources effectively for a given request. In operating systems, often a single processor of a computer system may encounter many jobs or user programs. One can visualize the scheduling problem as an optimal ordering
5 min read
Scheduling with Deadline
Prerequisite : CPU Scheduling What is Scheduling with Deadline ?The goal of a Scheduling problem is to schedule the tasks such that the maximum total profit is obtained. This algorithm for scheduling with a deadline is different from scheduling without a deadline because task completion here is associated with profit. In order to make a profit, the
4 min read
Longest Job First (LJF) CPU Scheduling Algorithm
Longest Job First (LJF) is a non-preemptive scheduling algorithm. This algorithm is based on the burst time of the processes. The processes are put into the ready queue based on their burst times i.e., in descending order of the burst times. As the name suggests this algorithm is based on the fact that the process with the largest burst time is pro
5 min read
Shortest Job First (or SJF) CPU Scheduling Non-preemptive algorithm using Segment Tree
Shortest job first (SJF) or shortest job next, is a scheduling policy that selects the waiting process with the smallest execution time to execute next. SJN is a non-preemptive algorithm.   Shortest Job first has the advantage of having a minimum average waiting time among all scheduling algorithms.It is a Greedy Algorithm.It may cause starvation i
15+ min read
Difference between Priority Scheduling and Round Robin (RR) CPU scheduling
1. Priority Scheduling Algorithm : Priority scheduling algorithm executes the processes depending upon their priority. Each process is allocated a priority and the process with the highest priority is executed first. Priorities can be defined internally as well as externally. Internal priorities are decided by the system depending upon the number o
3 min read
Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling
Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling is like Multilevel Queue(MLQ) Scheduling but in this process can move between the queues. And thus, much more efficient than multilevel queue scheduling. Characteristics of Multilevel Feedback Queue Scheduling: In a multilevel queue-scheduling algorithm, processes are permanently assigned t
5 min read
Longest Remaining Time First (LRTF) CPU Scheduling Program
We have given some processes with arrival time and Burst Time and we have to find the completion time (CT), Turn Around Time(TAT), Average Turn Around Time (Avg TAT), Waiting Time(WT), Average Waiting Time (AWT) for the given processes. Prerequisite: CPU Scheduling | Longest Remaining Time First (LRTF) algorithm LRTF is a preemptive scheduling algo
15+ min read
Shortest Job First CPU Scheduling with Predicted Burst Time
Shortest Job First (SJF) is an optimal scheduling algorithm as it gives maximum Throughput and minimum average waiting time(WT) and turnaround time (TAT) but it is not practically implementable because the burst time of a process can't be predicted in advance. We may not know the length of the next CPU burst, but we may be able to predict its value
5 min read
Program for Shortest Job First (or SJF) CPU Scheduling | Set 1 (Non- preemptive)
The shortest job first (SJF) or shortest job next, is a scheduling policy that selects the waiting process with the smallest execution time to execute next. SJN, also known as Shortest Job Next (SJN), can be preemptive or non-preemptive. Characteristics of SJF Scheduling: Shortest Job first has the advantage of having a minimum average waiting time
13 min read
Difference between First Come First Served (FCFS) and Round Robin (RR) Scheduling Algorithm
First Come First Served Scheduling Algorithm: First Come First Served (FCFS) is the simplest and non-preemptive scheduling algorithm. In First Come First Served (FCFS), the process is allocated to the CPU in the order of their arrival. A queue data structure is used to implement the FCFS scheduling algorithm. The process which is at the head of the
2 min read
Difference Between User-CPU-Time and System-CPU-Time in UNIX
There are two kinds of CPU time in any UNIX system: User CPU Time and System CPU Time. These metrics help in understanding the way in which the overall execution time is spent by any process using CPU resources. User CPU time is the total amount of time that the CPU spends executing both user processes and those parts of programs that run on behalf
8 min read
Difference between Relative and Absolute Deadline of Real-time Task
1. Relative Deadline : The time interval between the start of the task and the completion of the real-time task is known as Relative deadline. It is basically the time interval between arrival and corresponding deadline of the real-time task. If the arrival time of task is 't' and corresponding deadline of task is 't+d' then, Relative deadline = d
2 min read
Difference between Delay and Deadline Constraint in Real-time System
Prerequisite - Timing Constraints in Real-time System 1. Delay Constraint : Delay constraint is the minimum time interval between occurrence of two consecutive events in the real-time system. If an event occurs before the delay constraint, then it is called a delay violation. The time interval between occurrence of two events should be greater than
2 min read
Deadline scheduler in Operating System
Deadline Scheduler is n I/O scheduler for the Linux kernel and guarantee a start service time for a request. Deadline Scheduler imposes deadlines on all I/O operations in order to prevent wanted requests. Two deadline read and write queues (basically sorted by their deadline) are maintained. For every new request, the scheduler selects which queue
3 min read
Operating Systems | CPU Scheduling | Question 1
Consider three processes (process id 0, 1, 2 respectively) with compute time bursts 2, 4 and 8 time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF) scheduling algorithm. In LRTF ties are broken by giving priority to the process with the lowest process id. The average turn around time is: (A) 13 units (B) 1
1 min read
Operating Systems | CPU Scheduling | Question 2
Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30 units, respectively. Each process spends the first 20% of execution time doing I/O, the next 70% of time doing computation, and the last 10% of time doing I/O again. The operating system uses a shortest remaining compute time first scheduling algorithm a
2 min read
Operating Systems | CPU Scheduling | Question 3
Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end. (A) 1 (B) 2 (C) 3 (D) 4 Answer: (B)
1 min read
Operating Systems | CPU Scheduling | Question 4
Which of the following process scheduling algorithm may lead to starvation (A) FIFO (B) Round Robin (C) Shortest Job Next (D) None of the above Answer: (C) Explanation: Shortest job next may lead to process starvation for processes which will require a long time to complete if short processes are continually added.Quiz of this Question
1 min read
Operating Systems | CPU Scheduling | Question 5
If the quantum time of round robin algorithm is very large, then it is equivalent to: (A) First in first out (B) Shortest Job Next (C) Lottery scheduling (D) None of the above Answer: (A) Explanation: If time quantum is very large, then scheduling happens according to FCFS.Quiz of this Question
1 min read
Operating Systems | CPU Scheduling | Question 6
Which of the following is FALSE about SJF (Shortest Job First Scheduling)? S1: It causes minimum average waiting time S2: It can cause starvation (A) Only S1 (B) Only S2 (C) Both S1 and S2 (D) Neither S1 nor S2 Answer: (D) Explanation: Both SJF and Shortest Remaining time first algorithms may cause starvation. Consider a situation when long process
1 min read
Difference between Preemptive Priority based and Non-preemptive Priority based CPU scheduling algorithms
Prerequisite - CPU Scheduling Priority Scheduling : In priority scheduling, each process has a priority which is an integer value assigned to it. The smallest integer is considered as the highest priority and the largest integer is considered as the lowest priority. The process with the highest priority gets the CPU first. In rare systems, the larg
4 min read
Advantages and Disadvantages of various CPU scheduling algorithms
CPU Scheduling involves many different scheduling algorithms which have their Advantages and Disadvantages. 1. First Come First Serve (FCFS): Advantages: It is simple and easy to understand.FCFS provides fairness by treating all processes equally and giving them an equal opportunity to run.FCFS guarantees that every process will eventually get a ch
3 min read
Difference between SJF and LJF CPU scheduling algorithms
Shortest Job First: The shortest job first (SJF) algorithm is a CPU scheduling algorithm designed to reorder the jobs so that the process having the smallest burst time is chosen for the next execution. It is used to reduce the average waiting time for other processes waiting for execution. This may be preemptive or non-preemptive. Its preemptive v
4 min read