Real Time Scheduling
Real Time Scheduling
Guanpi Lai
May 3, 2003
Outline
Brief real-time review
Scheduling
Schedulability
Scheduling algorithms
Complications
Data Dependencies
Brief discuss of Real Time Operating
Systems
Distinctive Embedded System
Attributes
Reactive: computations occur in response to
external events
Periodic events (e.g. rotating machinery and control loops)
Aperiodic events (e.g. button click)
Real Time: correctness is partially a function of time
Hard real time
– Absolute deadline, beyond which answer is useless
– May include minimum time as well as maximum time
Soft real time
– Approximate deadline
– Utility of answer degrades with time difference from
deadline
Real-Time Review
Real time is not just “real fast”
Real time means that correctness of result depends
differences
Worst case is time that is product of all periods;
utilization
If it runs once, it will always work
EDF: Earliest Deadline First
Assume a preemptive system with dynamic
priorities, and (same 5 restrictions)
Scheduling policy:
Always execute the task with the nearest deadline
Performance
Optimal for uniprocessor (supports up to 100% of
CPU usage in all situations)
If you’re overloaded, ensures that a lot of tasks don’t
complete
– Gives everyone a chance to fail at the expense of the later
tasks
Least Laxity
Assume a preemptive system with dynamic priorities,
and (same 5 restrictions)
Scheduling policy:
Always execute the task with the smallest laxity
Performance:
Optimal for uniprocessor (supports up to 100% of CPU usage
in all situations)
– Similar in properties to EDF
– May take too many bits to achieve a long enough time horizon
Rate Monotonic
Assume a preemptive system with static priorities, and
(same 5 restrictions) plus
Scheduling policy:
Highest static priority goes to shortest period; always
~70%
– Even with arbitrarily selected task periods
– Can do better if you know about periods & offsets
If all periods are multiple of shortest period, works for CPU
load of 100%
Data Dependencies
If two tasks access the same data (violates Assumption
#2)
Use a semaphore to ensure non-simultaneous access
Scheduling can get really nasty…
Priority inversion
Low-priority task holds resource that prevents execution by
high-priority task
– Task 3 acquires lock
allowed to execute
– Task 2 preempts Task 3, because it is higher priority