You are on page 1of 7

Real- Time Systems Design April 05

Damien Costello, Dept of Computing &


Maths, GMIT 1
April 05 Real Time Scheduling 1
Real Time Scheduling
Process control plants, robotics, air traffic
control, telecommunications
Real Time Computing is defined as:-
a type of computing where the correctness of
the system depends not only on the logical
result of the computation, but also on the time
at which the results are produced
April 05 Real Time Scheduling 2
Real Time Scheduling
Scheduling
the determination of the policies that decide
which tasks execute when multiple tasks are
ready to execute.
A design concern, it fundamentally involves
decisions that optimise the overall system
performance according to some criteria.
April 05 Real Time Scheduling 3
Real-Time Scheduling
System designer decides on the scheduling
approach
Win 2000 is preemptive, swapping out low
priority tasks when a higher priority becomes
ready.
In many embedded systems, hardware
interrupts drive some tasks.
Serial communication handled this way in
Windows.
April 05 Real Time Scheduling 4
Real-Time Scheduling
Commonly
Schedulers use a run-to-completion or a
preemptive policy to control execution.
Most common policies in RTS are
preemptive.
April 05 Real Time Scheduling 5
Real-Time Scheduling
Two keys to good RT design are
repeatability and predictability.
Fighter aircraft require computers to manage
the flight control surfaces.
Frequent and timely updates to airfoil position and
thrust application.
A change that comes too late is no better than
one that does not come at all.
April 05 Real Time Scheduling 6
Real-Time Scheduling
Pace makers
A pulse to the heart just after there is a beat can
induce fibrillation.
Both these are a BAD THING
RTS use one or more scheduling algorithm
to control when a task begins and whether
or not a task may be suspended during
execution and prior to completion.
Real- Time Systems Design April 05
Damien Costello, Dept of Computing &
Maths, GMIT 2
April 05 Real Time Scheduling 7
Real-Time Scheduling
Not a trivial thing.
High priority tasks can be scheduled in
isolation, but may be blocked from execution
by lower priority tasks.
Blocking is unavoidable in preemptive
scheduling with shared resources.
It must be bounded to identify worst case blocking.
April 05 Real Time Scheduling 8
Real-Time Scheduling
Key priorities
ensuring that hard tasks complete or start by their
deadline, and that as many soft tasks also complete or
start by their deadline
not fairness and minimum average response time
most contemporary real-time systems
designed to be as responsive as possible to real-time tasks
when deadline approaches, the task is scheduled
typically require deterministic response times in the
range of milliseconds to sub milliseconds.
April 05 Real Time Scheduling 9
Real-Time Scheduling
Various alternatives to Round Robin
Using priority driven non preemptive
scheduler
real-time task is added to head of queue to run
after current
if current is a slow low priority task, time is
unacceptable if it is running at a critical time.
There are better approaches:-
April 05 Real Time Scheduling 10
Real-Time Scheduling
Combine priority with clock based interrupts
Preemption point occurs at regular intervals, lower
priority preempted by higher.
delays of milliseconds usually, may not be adequate for more
demanding application.
For demanding applications, use an immediate
preemptive scheduler.
OS responds to interrupt almost immediately.
Unless system is in critical code lockout section
April 05 Real Time Scheduling 11
Real-Time Scheduling
The approach taken to scheduling depends
on
1) does the system perform a schedulability
analysis
2) if it does, is it done statically or dynamically
3) does the result of the analysis produce a
schedule according to which tasks are
dispatched at run time.
April 05 Real Time Scheduling 12
Real-Time Scheduling
The classes of algorithm available based on
this
Static table driven
Static priority driven preemtive
Dynamic planning
Dynamic best effort
Real- Time Systems Design April 05
Damien Costello, Dept of Computing &
Maths, GMIT 3
April 05 Real Time Scheduling 13
Real-Time Scheduling
Static Table Driven
Applicable mainly to periodic tasks, this
performs a static analysis of feasible schedules.
Result is a schedule of dispatching.
Input for analysis - periodic arrival times,
execution time, periodic ending deadline,
relative priority of tasks.
The scheduler tries to develop schedule to meet
all needs.
April 05 Real Time Scheduling 14
Real-Time Scheduling
Static Table Driven
Is inflexible - any change to tasks requires
schedule to be redone.
Earliest Deadline first is an example of this type
of scheduling algorithm.
A set of tasks is schedulable if the sum of task
loading is less than 100%.
Not stable, if the load is above 100%, something
fails, but cant predict what.
April 05 Real Time Scheduling 15
Real-Time Scheduling
Static Priority Driven Preemptive
A static analysis is done, and the result is used
to assign priorities to tasks.
A traditional priority driven preemptive scheduler
can then be used.
Usually, in a real-time system, the priority is
related to the time constraints on the tasks.
Rate Monotonic scheduling assigns priorities
based on their periods.
April 05 Real Time Scheduling 16
Real-Time Scheduling
Dynamic Planning Based
Feasibility is determined at run-time rather than
an offline analysis prior to the start of
execution.
An arriving task is accepted only if it is feasible
to meet its time constraints.
Requires constant reworking of the schedule to
accommodate new tasks and existing ones.
April 05 Real Time Scheduling 17
Real-Time Scheduling
If a new task can be scheduled in without
adverse affects (missed deadlines) to the
existing tasks already scheduled, then the
schedule is revised.
Dynamic Best Effort
There is no feasibility analysis.
System tries to meet all deadlines and aborts
any started process whose deadline is missed.
April 05 Real Time Scheduling 18
Real-Time Scheduling
A new task is assigned a priority based on the
characteristics of task.
It uses some form of deadline scheduling.
Typically, the tasks are aperiodic and static
scheduling is not possible.
Until a deadline arrives or until a task is
complete, do not know whether timing
constraint will be met (major disadvantage).
It is easier to implement than the others.
Real- Time Systems Design April 05
Damien Costello, Dept of Computing &
Maths, GMIT 4
April 05 Real Time Scheduling 19
Real-Time Scheduling
Two main approaches:-
Deadline & Rate Monotonic scheduling.
Contemporary RT systems are designed to
start the real-time tasks as rapidly as
possible
emphasise rapid interrupt handling and task
dispatching.
April 05 Real Time Scheduling 20
Real-Time Scheduling
Most real-time apps are more concerned
with completing/starting tasks at the most
valuable times rather than speed.
Must take into account dynamic resource
demands and conflicts, processing overloads
and hardware or software faults.
Priorities alone will not be sufficient
information for scheduling.
April 05 Real Time Scheduling 21
Real-Time Scheduling
No matter what approach is taken, some general
information will be required:-
ready time - when the task becomes ready for execution
periodic task - (regular intervals)
aperiodic task may know time in advance or become aware
only when task becomes ready.
Starting or completion deadline
Processing time supply/measure
Resources required
April 05 Real Time Scheduling 22
Real-Time Scheduling
Information about tasks
priority - relative importance of the task
hard real-time systems may have absolute priority
fails if deadline is missed.
If the system is to continue operation
then the priority is supplied as a guide for the scheduler.
subtask structure - task may be composed of
mandatory task and optional task
April 05 Real Time Scheduling 23
Deadline Scheduling
Several considerations:-
Which task to schedule next.
What preemption is allowed.
Can minimise the missed deadlines using certain
preemption policies and scheduling tasks with
earliest deadline (either starting or completion).
April 05 Real Time Scheduling 24
Deadline Scheduling
To preempt or not to preempt
Makes sense not to preempt with starting
deadlines specified.
Task must block itself after completing mandatory
or critical portion allowing other tasks starting
deadlines to be met.
Priority Driven Nonpreemptive Scheduler
Real- Time Systems Design April 05
Damien Costello, Dept of Computing &
Maths, GMIT 5
April 05 Real Time Scheduling 25
Real-Time Scheduling
Preempt when completion deadlines are specified.
May be possible to allow all tasks to meet deadlines in
this way.
Priority Driven Preemptive Scheduler (on preemption
points) or an ImmediatePreemptive Scheduler.
Example given below, with two tasks to collect
and process data from two sensors A and B.
April 05 Real Time Scheduling 26
Real-Time Scheduling
April 05 Real Time Scheduling 27 April 05 Real Time Scheduling 28
Real-Time Scheduling
By scheduling to give priority at any
preemption point to earliest deadline
all system requirements are met.
The tasks are periodic and predictable
can use static table driven scheduling approach.
What about aperiodic tasks?
April 05 Real Time Scheduling 29
Process Arrival Time Execution Time Starting Deadline
A 10 20 110
B 20 20 20
C 40 20 50
D 50 20 90
E 60 20 70

Real-Time Scheduling
Example:-
April 05 Real Time Scheduling 30
Real- Time Systems Design April 05
Damien Costello, Dept of Computing &
Maths, GMIT 6
April 05 Real Time Scheduling 31
Real-Time Scheduling
If, always schedule ready task with EDF
and let run to completion
straightforward, but using this, B will be missed
as A already started.
Performance will improve if deadlines can
be known in advance of ready time.
Known as Earliest Deadline with unforced idle
times:-
April 05 Real Time Scheduling 32
Real-Time Scheduling
ED Unforced Idle Time
Always schedule eligible task with ED and
allow it run to completion.
The eligible task may not be ready. The processor
will remain idle even though there are other ready
processes. The processor may remain idle.
The result is that even though maximum
utilisation is not achieved, all scheduling
requirements are met.
April 05 Real Time Scheduling 33
Real-Time Scheduling
Rate Monotonic Scheduling (RMS)
A way to resolve the multitask scheduling
conflicts for periodic tasks.
Assigns priorities on the basis of a tasks period
(shorter the period, higher the priority)
Priority is determined at design time and
remains fixed. It is a static/fixed scheduling
policy.
April 05 Real Time Scheduling 34
Real-Time Scheduling
Can compute schedulability using a single
utilisation bound for the entire set of tasks.
Will the system meet all hard deadlies?
C = Execution Time
T = Period of a task
Sum of Utilisations
) 1 2 ( ...
1
3
3
2
2
1
1
+ + +
n
n
n
n
T
C
T
C
T
C
T
C
April 05 Real Time Scheduling 35
Real-Time Scheduling
RMS assumes that the end of a tasks period is a
hard deadline and that all tasks are preemptible at
any time.
If the condition is not met, a more detailed
analysis must be performed.
The upper bound converges to 69% as n
approaches infinity.
Not unusual for a utilisation of 90% to be set for
schedulability guarantee.
April 05 Real Time Scheduling 36
Real-Time Scheduling
With known utilisations, requirements can
determine if all tasks can be scheduled
successfully.
Even though it is possible to schedule more
periodic tasks with EDF, RMS has been
adopted because:-
Performance difference is small in practice
Real- Time Systems Design April 05
Damien Costello, Dept of Computing &
Maths, GMIT 7
April 05 Real Time Scheduling 37
Real-Time Scheduling
Most hard RE systems have soft RT
components
These can be executed at lower priority to absorb
the processor idle time not used with RMS.
Stability is easier to achieve with RMS
Need to guarantee deadlines of essential tasks if all
deadlines cannot be met.
Can be done with RMS by structuring essential
tasks to have short periods or modifying the RMS
priorities to account for essential tasks.

You might also like