You are on page 1of 50

Types of Real-Time Systems

Real-time systems are different from the traditional


systems
Tasks have deadlines associated with them
Hard real-time systems
Soft real-time systems
Firm real-time systems
Hard Real-Time Systems
If a deadline is not met,
then the system is said to have failed
The task deadlines are of the order of micro or
milliseconds
Many hard real-time systems are safety-critical
Examples
Industrial control applications
On-board computers
Robots
Firm Real-Time Systems
Tasks have deadlines
If a deadline is missed occasionally, the system
does not fail
The results produced by a task after the
deadline are rejected
Utility
D
Time
Firm Real-Time Systems
Examples
A video conferencing application
A telemetry application
Satellite-based suveillance applications
Soft Real-Time Systems
Tasks have deadlines
If a deadline is missed, the system does not fail.
The performance of the system is said to have degraded
The utility of a result decreases with time after the deadline
Utility
D Time
Soft Real-Time Systems
Examples of soft real-time systems:
Railway reservation system
Web browsing
In fact, all interactive applications
Timing constraints
Defined with respect to some event
An event:
can occur at an instant of time
may have duration
generated either by the system or its envt
Events in RTS
Stimulus events
Response events

Stimulus events
Generated by the environment
Act on the system
Typically asynchronous in nature
aperiodic
can also be periodic
Eg1: a user pressing a button on a telephone set
A stimulus event acts on the telephone system
Eg2: periodic sensing of temp in a chemical plant
Response events
Produced by the system
In response to some stimulus events

Eg1: in a chemical plant, as soon as the temp exceeds 100
c, the system responds by switching off the heater

Classification of timing constraints
Performance constraints
imposed on the response of the system
Behavioral constraints
imposed on the stimuli generated by the envt

Both can be classified into:
Delay constraints
Deadline constraints
Duration constraints

Delay constraint
Expresses minimum time delay
Allowed time b/n the occurrence of two arbitrary events e1
and e2
t(e2) t(e1) d
If e2 occurs earlier than d, then a delay violation would
occur
Deadline constraint
Specifies the maximum permissible separation b/n any two
arbitrary events
t(e2) t(e1) d
Duration constraint
Specifies the time period over which the event acts
It can be:
minimum type
maximum type
Minimum
Once a duration event starts, it must not end
before a certain minimum time
Maximum
Once a duration event starts, it must end before a
certain maximum time
Examples of timing constraints
Deadline constraints
Stimulus-stimulus (SS)
- deadline is defined b/n two stimuli
- a behavioral constraint
- imposed on stimulus
Eg: once a user completes dialing a digit, he must
dial the next digit within the next 5 seconds
Otherwise an idle tone is produced
Deadline constraints
Stimulus- Response (SR)
- defined on the response from the respective stimulus
event
- a performance constraint
- imposed on response
Eg: once the receiver of the handset is lifted, the dial tone
must be produced by the system with in 2 seconds
Otherwise a beeping sound is produced until the handset is
replaced
Deadline constraints
Response- stimulus (RS)
- defined on the response from the respective stimulus
- a performance constraint
once the dial tone appears, the first digit must be dialed
with in 30 seconds
Otherwise the system enters an idle state and an idle tone is
produced

Deadline constraints
Response-Response (RR)
- defined on the response from another response
- a performance constraint
- imposed on response
Once ring tone is given to the called, ring back tone must be
given to the caller with in two seconds
Otherwise the call is terminated


Delay constraint
Stimulus Stimulus (SS)
- a behavioral constraint
- imposed on the environment
Once a digit is dialed, the next digit should be dialed after at
least 1 second
Otherwise a beeping sound is produced until the call
initiator replaces the handset
Duration constraint
- Specifies the time interval over which the event acts
if u press the button of the handset for less than 15
seconds:
it connects to the local operator
if u press the button for any duration lasting b/n 15 and
30 seconds:
it connects to the international operator
if u keep the button pressed for more than 30 seconds:
on releasing it would produce the dial tone


Chapter Two

Real-Time Task Scheduling


Outline
Introduction
Real-Time task scheduling
Clock-driven
Event-driven
Scheduling of real-time task on a uniprocessor
Rate Monotonic Analysis (RMA)
Earliest Deadline First (EDF)
Scheduling with limited priority levels
Summary
Introduction

A job is a unit of work that is scheduled and
executed by a system
e.g. computation of a control-law, computation of
an FFT on sensor data, transmission of a data
packet, retrieval of a file
A task is a set of related jobs which jointly
provide some function
e.g. the set of jobs that constitute the maintain
constant altitude task, keeping an airplane
flying at a constant altitude


A job executes or is executed by the operating
system on a processor and may depend on some
resources
A processor, P, is an active component on which
jobs scheduled
Eg: Threads scheduled on a CPU
Data scheduled on a transmission link
Read/write requests scheduled to a disk
Introduction

A resource, R, is a passive entity upon which jobs may
depend E.g. memory, database locks, etc
A job J will execute for time e
This is the amount of time required to complete the
execution of J when it executes alone and has all the
resources it needs
Release time: the instant in time when a job becomes
available for execution
Response time: the length of time from the release time
of the job to the time instant when it completes
Not the same as execution time, since may not execute
continually

Introduction

Completion time: the instant at which a job
completes execution
Relative deadline: the maximum allowable job
response time
Absolute deadline: the instant of time by which a
job is required to be completed(counted from 0)
often called simply the deadline
absolute deadline = release time + relative
deadline
Task precedence: the first task must be completed
before the second task can start.

Introduction

Real-time tasks get generated due to certain
event occurrences
Either internal or external events
For example
A task may get generated due to a user
pressing a switch
When a task gets generated
It is said to be released or arrived
Introduction

Real-Time Tasks
Periodic
Periodic tasks repeat after a certain fixed time interval
The 4-tuple Ti = (i, pi, ei, Di)
phase i, period pi, execution time ei, and relative deadline Di
Default i = 0, Di = pi
Sporadic
Sporadic tasks recurs at random instants
The 3-tuple Ti= (ei, gi, Di)
gi minimum separation b/n two consecutive instances of
the task
Aperiodic
Same as sporadic except that minimum separation
between two instances can be 0



Real-Time Task Scheduling
Scheduling of tasks is the primary means by
which the operating system meets task deadlines.
So, scheduling is an important problem.
Lot of work has been done in developing
appropriate schedulers for real-time tasks
Scheduling on uniprocessors
Scheduling on multiprocessors and distributed
systems
Important Scheduling
Terminologies
Valid Schedule
At most one task is assigned to a processor at a
time
No task is scheduled before its time
Precedence and resource constraints of all tasks
are satisfied
Feasible Schedule
A valid schedule in which all tasks meet their
respective time constraints



Important Scheduling
Terminologies
Proficient Scheduler
Proficient scheduler can feasibly schedule all tasks that
other scheduler can but not vice versa
Equally proficient if both processor can schedule same
set of tasks
Optimal Scheduler
Optimal scheduler can feasibly schedule any task set
that can be scheduled by any other scheduler
Scheduling points
the points on timeline at which decisions are made
regarding which task is to be run next.

Task Scheduling Types
Based on how the scheduling points are defined:
Clock-driven,
Event-driven or
Hybrid
Based on the type of task acceptance test
- planning-based
- best effort
Based on the target platform
- Uniprocessor
-Multiprocessor
- Distributed

Goals in RTS Scheduling
Assignment of processors and resources to tasks in
order to complete all tasks under certain imposed
constraints.
Meeting the time constraints
Preventing simultaneous access to shared resources
Attaining a high degree of utilization
Reducing the cost of context switches
Reducing the communication cost
31
Notations
Preemptive tasks Vs Non-preemptive tasks
Dynamic Vs Static systems [ availability of
information prior]
Dependent Vs Independent tasks
Priority based
Assumption: at every moment each processor is
assigned to at most one task and each task is processed
by at most one processor.
32
Clock-driven Scheduling
Examples
Table-driven scheduler
Cyclic scheduler
Decision regarding which job to run next is made
at specific time instants
Timers are used to trigger the decision point
The joblist along with information regarding
which task to be run for how long are stored in
a table.
Clock-driven Scheduling
Table-driven scheduling
- Precompute which task would compute when
- Store the schedule in a table ( schedule table)
- The scheduler develops a permanent schedule for
a period LCM(P1,P2,...,Pn) and stores in a table.


Task Start time
T1 0
T2 3
T3 10
Clock-Driven Scheduling

Clock-driven schedulers are
Simple: used in low cost applications
Efficient: very little runtime overhead
Inflexible: Very difficult to accommodate
dynamically changing task set or task
characteristics.
cant handle aperiodic and sporadic tasks
satisfactorily
Clock-Driven Scheduling
Cyclic Schedulers
- Repeats a precomputed schedule
- The schedule will be stored only for 1 major cycle
- Each minor cycle is called a frame
- The scheduling points occur at frame boundaries
- The boundaries are defined by interrupts generated
by a periodic timer

Clock-Driven Scheduling
Cyclic scheduler


a schedule table

Task Number Frame Number
T3 F1
T1 F2
T3 F3
T4 F4
Clock-Driven Scheduling
Cyclic scheduler
- A selected frame size should satisfy the following three
constraints:
Minimum Context Switching
- max(ei) F
Minimization of Table Size
- Major cycle (M) has to be an integral multiple of F
Satisfaction of Task deadline
- b/n the arrival of a task and its deadline, there must
exist at least one full frame
- 2F-gcd(F, Pi) di

Event-Driven Scheduling
Scheduling points are defined by task
completion and arrival events
These schedulers are generally preemptive
Simplest example:
Foreground-Background Scheduler



Event-driven Schedulers
Scheduling decisions are made when certain events
occur
Tasks becoming ready
Tasks completing execution
These are called preemptive schedulers
When a higher priority task becomes ready it
preempts the executing lower priority task
These are greedy schedulers:
They never keep the processor idle if a task is
ready.
Event-driven Schedulers
Static priority schedulers:
The task priorities once assigned by the
programmers, do not change during runtime
RMA (Rate Monotonic Algorithm) is the
optimal static priority scheduling algorithm
Dynamic priority
The task priorities can change during runtime
based on the relative urgency of completion of
tasks
EDF (Earliest Deadline First) is the optimal
uniprocessor scheduling algorithm
Event-Driven Schedulers
First let us consider the simplest scenario:
Uniprocessor
Independent tasks
Tasks do not share resources
There is no precedence ordering among the
tasks
Priority-based Scheduling
Independent tasks executed on a uniprocessor
Two algorithms pretty much summarise the
important results in this scenario
EDF
RMA
Foreground-Background
Scheduler
In this scheduler real-time tasks run as foreground
tasks
Sporadic, aperiodic and non-real-time tasks are run
as background tasks
Among the foreground tasks, at every scheduling,
highest priority task is scheduled
Background task can run when no foreground task
is ready



EDF
EDF is the optimal uniprocessor scheduling
algorithm
If EDF cannot feasibly schedule a set of tasks,
there exists no other scheduling algorithms to
do that.
Can schedule both periodic and aperiodic tasks
Schedulability check:
Sum of utilization due to tasks is less than
one.
ei/pi 1
EDF
EDF is
Simple
Optimal
But, is rarely used
No commercially available operating system
directly supports EDF scheduling
Let us examine the disadvantages of EDF
Disadvantages of EDF
Transient overload handling
EDF has very poor transient overload
handling capability
When a low-criticality task becomes delayed it
can make even the most critical task miss its
deadline
In fact, it is extremely difficult to predict
which task would miss its deadline when a
task takes more time
Disadvantages of EDF
Runtime efficiency
EDF is not very efficient
Inorder to implement EDF the tasks need to
be maintained sorted in a priority queue based
on their deadline
The complexity of maintaining a priority
queue is logn, where n is the number of tasks
Disadvantages of EDF
Resource sharing among tasks
It is very difficult to let tasks share non-
premptable resources (called critical sections)
without some tasks missing their deadlines

General EDF Schedulability
When the task deadlines differ from the task
periods,
the schedulability criterion needs to be generalized
as follows:

You might also like