230 likes | 272 Views
Explore various scheduling algorithms like FCFS, SJF, Priority Scheduling, and Round Robin, with a focus on real-time constraints and task assignment strategies. Understand the importance of timing, precedence, and resource constraints in optimizing task scheduling efficiency. Learn about EDD and EDF for real-time task management.
E N D
Tasks • Non periodic tasks can be converted to periodic tasks • Converting an interrupt handler to a polling task. • Instead of reacting to an external event the moment it occurs, the system polls the external input regularly. • If the awaited event is detected, the appropriated action is performed.
Schedule • A schedule is a particular assignment of tasks to the processor. Idle τ1 τ2 τ3 Idle t t1 t2 t3 t4
Schedule Preemptive τ1 τ2 τ3 t1 t3 t4 t5 t2 t
Schedule Algorithms Constraints • Timing constraints • Activation, completion, jitter. • Precedence constraints • They impose an ordering in the execution. • Resource constraints • They enforce a synchronization in the access of mutually exclusive resources.
Some Schedule Algorithms • First Come First Served • Shortest Job First • Priority Scheduling • Round Robin • Not suitable for Real Time!!!!!
First Come First Served • It assigns the CPU to tasks based on their arrival times. • Very unpredictable • Response times strongly depend on task arrivals.
Shortest Job First • It selects the task with the shortest computation time.
Shortest Job First • Sometimes…is not feasible
Priority Scheduling • Each task is assigned a priority: e.g. [0, 255]- The task with the highest priority is selected for execution. • - Tasks with the same priority are served FCFS. • Problem: starvation • low priority tasks may experience long delays due to the preemption of high priority tasks.
τ1 τ2 τ3 Round Robin • The ready queue is served as FCFS • Each task cannot execute more than Q time units (Q = time quantum). • When Q expires, the task is put back in the queue. Activation CPU Q expired
Round Robin • Each task runs as it was executing alone on a virtual processor n times slower than the real one!!! nQ Q
Real Time Algorithms • Tasks can be scheduled by • Relative deadlines Di (static) • Absolute deadlines di (dynamic) Di τi t di
Earliest Due Date (EDD) • It selects the task with the earliest relative deadline. • All tasks arrive simultaneously • Fixed priority (Di is known in advance) • Preemption is not an issue • It minimizes the maximum lateness (Lmax)
Earliest Deadline First (EDF) • It selects the task with the earliest absolute deadline • Tasks may arrive at any time • Dynamic priority (di depends on arrival) • Full preemptive tasks • It minimizes the maximum lateness (Lmax)
Periodic Tasks Scheduling • Defining the problem • Each group of tasks has to start after the period defined. • Each group of tasks has to finish before the next period come.
Cyclic Scheduling It has been used for 30 years in military systems, navigation, and monitoring systems. Examples: • Air traffic control • Space Shuttle • Boeing 777
Cyclic Scheduling Method • The time axis is divided in intervals of equal length (time slots). • Each task is statically allocated in a slot in order to meet the desired request rate. • The execution in each slot is activated by a timer.
Cyclic Scheduling Example • Specification : • Task A f=40 Hz, T=25 ms • Task B f=20 Hz, T=50 ms • Task C f=10 Hz, T=100 ms Assumptions guaranteed!!!: CA + CB ≤ Λ CA + Cc ≤ Λ T Major Cycle Λ Minor Cycle Λ T 25 ms 0 ms 50 ms 75 ms 125 ms 100 ms 150 ms 175 ms 200 ms 225 ms