Earliest Deadline First (EDF) : Prof. Medhat Awadalla
Earliest Deadline First (EDF) : Prof. Medhat Awadalla
D
3. Ahmed Khaled Abdelaty (222060085)
4. Mayar Saeed Ahmed (222060075)
5. Mohamed Awaad Mohamed ( 221760008 )
Table of Contents
Introduction.................................................................................................................................................................. 3
What is the definition of EDF? ................................................................................................................................ 5
Working Process ........................................................................................................................................................ 6
EDF Performance ....................................................................................................................................................... 7
Key Characteristics of EDF.................................................................................................................................... 10
In EDF, tasks declare their deadlines upon becoming ready for execution. The
algorithm continually evaluates these deadlines, preempting tasks as needed to
accommodate those with closer deadlines. This preemptive nature allows for efficient
scheduling even in complex real-time environments.
EDF guarantees an optimal feasible schedule where all tasks meet their deadlines,
provided the total utilization of tasks remains below the system's capacity. It boasts
high CPU utilization, often reaching 100%, while still meeting deadlines. If EDF fails
to find a feasible schedule, it suggests that no other real-time scheduling algorithm
can.
Notably, EDF doesn't require tasks to be periodic or have fixed CPU burst times,
enhancing its versatility. It's applicable to both static and dynamic real-time
scheduling scenarios, making it a valuable tool in real-time operating systems.
Overall, EDF minimizes the likelihood of deadline misses by prioritizing tasks based
on their deadlines. It's an optimal algorithm for scheduling periodic tasks with known
deadlines and execution times, provided the total task utilization doesn't exceed
system capacity.
WORKING PROCESS
Now let’s show how the earliest deadline first scheduling algorithm works.
The earliest deadline first scheduling algorithm consists of four steps:
• initialization
• task prioritization
• task scheduling
• task execution
Tasks are initialized with deadlines, and priorities are assigned based on these
deadlines. The algorithm selects the task with the earliest deadline and highest priority
for execution. The CPU executes the selected task until completion, or the deadline is
reached. If a deadline is missed, the task is considered failed.
The algorithm checks for two termination conditions:
• all tasks are executed
• if any deadlines are missed
If either condition is met, the algorithm returns to task prioritization and repeats until
termination.
EDF is dynamic, adjusting task priorities as deadlines approach to ensure timely
execution. This continual updating helps meet deadlines and maintain system
efficiency.
EDF PERFORMANCE
The performance of the Earliest Deadline First (EDF) scheduling algorithm can be
evaluated based on several key metrics that reflect its effectiveness in managing real-
time tasks. These metrics include Schedulability, processor utilization, response time,
and jitter.
1. Schedulability
Schedulability is a measure of the algorithm's ability to ensure that all tasks meet
their deadlines. EDF is known for its optimality in uniprocessor systems, meaning
that if any scheduling algorithm can meet the deadlines of a given set of tasks,
EDF will also be able to do so. This property makes EDF particularly suitable for
real-time applications where meeting deadlines is critical.
2. Processor Utilization
Response time is the time taken from the arrival of a task until it starts execution.
In EDF, tasks with earlier deadlines are prioritized, which can lead to reduced
response times for urgent tasks. However, because EDF is dynamic, response
times for individual tasks can vary significantly based on the task set and the
current system load. Analyzing the average and worst-case response times is
crucial for understanding the performance of EDF in different scenarios.
4. Jitter
Jitter refers to the variability in task start times. In real-time systems, minimizing
jitter is important to ensure predictability, especially for periodic tasks. While EDF
excels in flexibility and utilization, it can sometimes lead to higher jitter compared
to fixed-priority algorithms like RM. This is because task priorities can change
dynamically, causing variability in start times. However, techniques such as
deadline monotonic scheduling can be used in conjunction with EDF to mitigate
jitter for critical tasks.
Simulation and Results
To analyze the performance of EDF, a Python-based simulation was conducted. The
simulation involved creating a set of tasks with varying periods, execution times, and
deadlines. The EDF scheduling algorithm was implemented to manage these tasks,
and various performance metrics were measured.
2. Simulation Environment
Processor: Single core
Simulation Time: 100 units
Scheduler: EDF
3. Results
• Schedulability: All tasks met their deadlines consistently, confirming EDF's
optimality in a uniprocessor environment.
• Processor Utilization: The processor was utilized 95% of the time, indicating
high efficiency.
• Response Time: The average response time was 2 units, with a worst-case
response time of 5 units.
• Jitter: The average jitter was 1.5 units, which is acceptable but higher than
that of fixed-priority algorithms.
KEY CHARACTERISTICS OF EDF
1. Dynamic Scheduling
Definition: Unlike fixed-priority scheduling algorithms where the priority of a task is
determined statically, EDF dynamically adjusts priorities based on task deadlines. This
means that task priorities can change at runtime.
Implication: Tasks are continually re-evaluated and re-prioritized, ensuring that the
task with the closest deadline is always given precedence.
3. Flexibility
Periodic and Aperiodic Tasks: EDF can handle both periodic tasks (tasks that recur
at regular intervals) and aperiodic tasks (tasks that occur irregularly).
Critical and Non-Critical Tasks: EDF is suitable for systems with a mix of critical and
non-critical tasks, as it can dynamically adjust to changing task demands.
Advantages of EDF
Efficient Resource Use: EDF allows for near 100% processor utilization. By
dynamically prioritizing tasks based on their deadlines, the processor is almost
always working on the most urgent task, minimizing idle time and maximizing
efficiency.
• Handling Various Task Types: EDF can manage both periodic (tasks that occur
at regular intervals) and aperiodic (irregularly occurring) tasks effectively. This
flexibility makes EDF suitable for a wide range of applications with varying timing
requirements.
• Dynamic Task Management: EDF can adapt to changes in the task set, such as
the addition of new tasks, changes in deadlines, and variations in execution
times. This adaptability is crucial for systems that require responsiveness to
changing conditions.
4. Simple Priority Assignment
Intuitive Scheduling: Task priorities in EDF are based solely on deadlines, making
the priority assignment straightforward and intuitive. This simplicity helps in
understanding and implementing the scheduling algorithm.
Quick Response for Urgent Tasks: Because tasks with earlier deadlines are
prioritized, EDF often results in lower average response times for time-critical
tasks compared to fixed-priority scheduling algorithms.
6. Scalability
Handling Task Variability: EDF can scale to handle a wide range of task loads
and variations. It remains effective even as the number of tasks and their timing
requirements change, making it a robust choice for complex systems.
Disadvantages of EDF
While Earliest Deadline First (EDF) is a powerful and widely used scheduling
algorithm in real-time systems, it also has several disadvantages that can impact its
effectiveness in certain scenarios:
1. Computational Overhead
Constant Priority Re-evaluation: EDF requires the system to continually re-
evaluate task priorities based on their deadlines, which can introduce significant
computational overhead. This overhead can be particularly burdensome in systems
with many tasks or frequent deadline changes.
3. Jitter
Variability in Task Start Times: EDF can result in higher jitter, or variability in task
start times, compared to fixed-priority scheduling algorithms. This is because the
priority of tasks can change dynamically, causing fluctuations in the timing of task
execution. High jitter can be problematic for tasks requiring precise and predictable
timing
4. Complexity in Multiprocessor Systems
Challenges in Multiprocessor Environments: While EDF is optimal for
uniprocessor systems, its implementation and effectiveness can be more complex
and less optimal in multiprocessor systems. Managing task deadlines and ensuring
timely execution across multiple processors can introduce additional challenges
and inefficiencies.
5. Resource Contention
Resource Sharing Issues: In systems where tasks share resources (e.g.,
memory, I/O devices), EDF may not always handle resource contention efficiently.
Priority inversion and resource access delays can occur, potentially leading to
missed deadlines for high-priority tasks.
6. Preemption Overhead
Cost of Task Preemption: EDF, being a preemptive scheduling algorithm, can
incur significant overhead due to frequent context switching. Preempting tasks to
meet deadline priorities can lead to increased context switch times and reduced
overall system performance, particularly in systems with high preemption rates.
Applications of EDF
Earliest Deadline First (EDF) scheduling algorithm finds applications in various real-
time systems and domains where tasks have strict timing requirements. Some of the
common applications of EDF include:
1. Embedded Systems
Automotive Systems: EDF is used in automotive embedded systems for tasks
such as engine control, brake systems, and transmission control, where timely
execution is critical for ensuring vehicle safety.
Consumer Electronics: EDF is employed in consumer electronics such as digital
cameras, smartphones, and wearable devices for managing real-time multimedia
processing and user interaction tasks.
2. Industrial Automation
Manufacturing Processes: EDF is utilized in industrial automation systems for
controlling manufacturing processes, robotics, and assembly line operations,
ensuring precise timing and coordination of tasks.
Process Control Systems: EDF is employed in process control systems for
monitoring and controlling industrial processes such as chemical production, power
generation, and water treatment.
3. Telecommunications
Network Switching: EDF is used in telecommunications systems for managing
network switching and routing tasks, ensuring timely packet processing and
delivery in data networks.
Quality of Service (QoS) Management: EDF is employed in QoS management
systems for prioritizing and scheduling network traffic based on service-level
agreements and traffic deadlines.
First, we define a Python class named Task. This class represents a task with
specific attributes such as name, period, execution time, and deadline.
The Task class has an initializer method (__init__) that sets up the initial state
of a task object.
• This class serves as a blueprint for creating and managing task objects in
Python programs.
This code defines a function earliest_deadline_first(tasks) which schedules tasks
based on the Earliest Deadline First (EDF) scheduling algorithm:
Input: The function takes a list of tasks as input. Each task is expected to be an
object of the Task class defined earlier.
Output: The function returns a schedule, represented as a list of tuples where each
tuple contains the time slot and the name of the task scheduled for that time slot.
Algorithm:
• The function initializes an empty schedule list to store the scheduled tasks
and sets the time variable to 0.
• It enters a while loop that continues until there are tasks with remaining time
to execute (any(task.remaining_time > 0 for task in tasks)).
• Inside the loop, it sorts the tasks based on their next_deadline, ensuring that
the task with the earliest deadline comes first.
• It then iterates through the sorted tasks. For each task, it reduces its
remaining_time by 1 (simulating execution for one time unit) and appends
the current time and the task's name to the schedule.
• After scheduling a task, it increases the time by 1.
• It then iterates through the tasks again to reset any task whose period has
elapsed (time % task.period == 0). It resets the remaining_time to the initial
execution time and updates the next_deadline for the next period.
Return Value: The function returns the schedule containing the time slots and the
tasks scheduled for each time slot according to the EDF algorithm.
This function, get_task_input(), is designed to prompt the user to input details about
a task and then create a Task object based on those inputs:
Steps:
1. The function prompts the user to enter the name of the task using the input()
function.
2. Then it asks for the period of the task, which is how often the task occurs.
3. It requests the execution time of the task, which is the time it takes for the
task to complete.
4. Next, it asks for the deadline of the task. If the user doesn't input anything, it
defaults to using the period as the deadline.
5. Finally, it returns a new Task object initialized with the provided inputs.
Return Value: A Task object representing the task entered by the user, with
attributes name, period, execution_time, and deadline.
This function facilitates the creation of Task objects interactively by taking input
from the user for each attribute.
The main() function serves as the entry point of the program. Here's what it does:
Steps:
1. It prompts the user to enter the number of tasks they want to schedule.
2. It initializes an empty list task to store the tasks.
3. It enters a loop to prompt the user to input details for each task using
the get_task_input() function and appends the resulting Task objects to
the tasks list.
4. After obtaining all task details, it prints a message indicating that EDF
scheduling will be performed.
5. It calls the earliest_deadline_first(tasks) function to generate the
schedule based on the EDF algorithm.
6. It then iterates through the generated schedule and prints the time and
the task scheduled for that time.
Output: It prints the schedule generated using the Earliest Deadline First (EDF)
scheduling algorithm.
This function organizes the workflow of the program, from obtaining task details to
generating and displaying the schedule based on the EDF algorithm.
Conclusion
Earliest Deadline First (EDF) is a powerful and versatile scheduling algorithm for real-
time systems. Its dynamic nature and optimality in uniprocessor systems make it
suitable for a wide range of applications, from industrial control systems to multimedia
processing. Despite its complexity and potential for higher jitter, the advantages of
EDF in terms of flexibility and high processor utilization make it a preferred choice for
many real-time scheduling scenarios.
References
• https://en.wikipedia.org/wiki/Earliest_deadline_first_sche
duling#:~:text=Earliest%20deadline%20first%20(EDF)%20
or,process%20closest%20to%20its%20deadline.
• https://ieeexplore.ieee.org/document/7459325