This repository contains an Earliest Deadline First (EDF) Scheduler implemented for real-time task scheduling using an Arduino and LiquidCrystal display. The scheduler manages multiple periodic tasks and attempts to execute them based on their respective deadlines.
- Algorithm Overview
- Features
- How It Works
- Task Scheduling Example
- Metrics Tracked
- How to Run
The EDF Scheduler is an online scheduling algorithm for real-time tasks, where tasks are prioritized based on their deadline. The task with the earliest deadline is selected to run next, which makes EDF an optimal scheduling algorithm for many real-time systems. In the algorithm:
- Arrival Time: The time at which a task becomes available.
- Execution Time: The amount of time a task requires to execute.
- Period: The time interval after which a task reoccurs.
- Relative Deadline: The time from the arrival time by which the task must complete.
- The EDF Scheduler works by monitoring the tasks over time, executing the task with the earliest deadline that still needs to run, and tracking if any tasks miss their deadlines.
- Dynamic Task Creation: Users can input the number of tasks along with their arrival time, execution time, period, and deadline.
- Real-Time Simulation: The system runs a real-time simulation where tasks are scheduled based on their deadlines.
- LCD Display: Displays the simulation time, task information, and task status (running, idle, or missed deadlines).
- Serial Output: Outputs detailed reports of task execution, missed deadlines, and CPU utilization.
- Task Initialization:
- The user is prompted to input the number of tasks (up to 10), each with the following parameters:
- Arrival Time: When the task arrives.
- Execution Time: How long the task needs to execute.
- Period: How often the task reoccurs.
- Relative Deadline: Time from arrival until the task must finish.
- Scheduling Process:
- The scheduler simulates the execution of the tasks, starting from currentTime = 0 and running until the Least Common Multiple (LCM) of all task periods.
- At each time unit, tasks are checked for arrival.
- The task with the earliest deadline is selected for execution.
- If a task misses its deadline, it is flagged as a missed task.
- Metrics Tracked:
- Total Response Time: The time taken from task arrival until the task is first executed.
- CPU Time: The total time spent executing a task.
- Missed Deadlines: Count of missed deadlines for each task.
- Simulation End: At the end of the simulation, the system outputs a report showing:
- CPU utilization
- Task success or failure
- Missed deadlines for each task
For a task with the following parameters:
- Task 1: Arrival Time = 0, Execution Time = 2, Period = 5, Deadline = 4
- Task 2: Arrival Time = 1, Execution Time = 3, Period = 6, Deadline = 5
- Task 3: Arrival Time = 2, Execution Time = 1, Period = 4, Deadline = 3 The algorithm schedules the tasks by selecting the one with the earliest deadline. If any task doesn't complete before its deadline, it is marked as missed.
Task Instance Metrics:
- Total instances of a task.
- Number of missed instances.
- Task Performance Metrics:
- Average response time.
- Missed deadline rate.
- System-wide Metrics:
- CPU utilization (percentage of time the CPU is actively working).
- Idle time (time when no task is running).
- Hardware Requirements:
- Arduino board (e.g., Arduino Uno).
- LCD display (16x2) connected to the Arduino.
- Serial Monitor (for task status and reports).
- Software Setup:
- Install Arduino IDE.
- Install LiquidCrystal library.
- Connect your Arduino to your computer and upload the code.
- Running the Scheduler:
- Open the Serial Monitor.
- Input the number of tasks and their parameters when prompted.
- The simulation will start, and task execution will be shown both on the LCD and in the Serial Monitor.