RTSys Lecture Note - ch02 A Reference Model For Real-Time Systems PDF
RTSys Lecture Note - ch02 A Reference Model For Real-Time Systems PDF
Real--Time Systems
Real
Embedded RealReal-Time
Software
Lecture 2
Lecture Outline
Processors
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
Examples:
Two processors are of the same type if they are functionally identical and
can be used interchangeably
Resources
A resource, R, is a passive entity upon which jobs may depend
E.g. memory, sequence numbers, mutexes, database locks, etc.
Resources have different types and sizes, but do not have a speed attribute
Resources are usually reusable, and are not consumed by use
Use of Resources
If the system contains (rho) types of resource, this means:
There are different types of serially reusable resources
There are one or more units of each type of resource, only one job can use
each unit at once (mutually exclusive access)
A job must obtain a unit of a needed resource, use it, then release it
A resource is plentiful if no job is ever prevented from executing
by the unavailability of units of the resource
Jobs never block when attempting to obtain a unit of a plentiful resource
We typically omit such resources from our discussion, since they dont
impact performance or correctness
Execution Time
A job Ji will execute for time ei
This is the amount of time required to complete the execution of when it executes
alone and has all the resources it needs
Value of depends upon complexity of the job and speed of the processor on
which it is scheduled; may change for a variety of reasons:
Conditional branches
Cache memories and/or pipelines
Compression (e.g. MPEG video frames)
Execution times fall into an interval
; assume that we know this interval
for every hard real-time job, but not necessarily the actual
Terminology: (x, y] is an interval starting immediately after x, continuing up to and
including y
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
10
Example
A system to monitor and control a heating furnace
The system takes 20ms to initialize when turned on
After initialization, every 100 ms, the system:
Samples and reads the temperature sensor
Computes the control-law for the furnace to process temperature readings,
determine the correct flow rates of fuel, air and coolant
Adjusts flow rates to match computed values
11
Example
Suppose each job must complete before the release of the next job:
Jk s relative deadline is 100 ms
Jk s absolute deadline is 20 + ((k + 1) 100) ms
Alternatively, each control-law computation may be required to
finish sooner i.e. the relative deadline is smaller than the time
between jobs, allowing some slack time for other jobs
Slack time : the difference between the completion time and the earliest
possible completion time
12
usefulness
A timing constraint is hard if the failure to meet it is considered a fatal error; this
definition is based upon the functional criticality of a job
A timing constraint is hard if the usefulness of the results falls off abruptly (or may
even go negative) at the deadline
A timing constraint is hard if the
user requires validation
1
(formal proof or exhaustive
SOFT
simulation) that the system always
meets its timing constraint
HARD
deadline
13
Probabilistic
e.g. the probability of the response time exceeding 50 ms is less than 0.2
14
Flight control
Railway signaling
Anti-lock brakes
Etc.
Soft real-time:
15
Types of Task
There are various types of task
Periodic
Aperiodic
Sporadic
16
Periodic Tasks
Periodic Task - a set of jobs that are executed repeatedly at regular
time intervals
Each periodic task Ti is a sequence of jobs Ji,1, Ji,2, , Ji,n
The phase of a task Ti is the release time r i,1 of the first job J i,1 in the task. It is
denoted by i (phi)
The period pi of a task Ti is the length of time intervals between release times of
two consecutive jobs
The execution time ei of a task Ti is the maximum execution time of all jobs in the
periodic task
The period and execution time of every periodic task in the system are known with
reasonable accuracy at all times
17
Hyper-Periodic Tasks
The hyper-period of a set of periodic tasks is the least common
multiple of their periods:
H = LCM(pi) for i = 1, 2, , n
Time after which the pattern of job release/execution times starts to
repeat, limiting analysis needed
Example:
T1 : p1 = 3, e1 = 1
T2 : p2 = 5, e2 = 2
18
Utilization
The ratio u i = e i/p i is the utilization of task T i
The fraction of time a periodic task with period pi and execution time e i
keeps a processor busy
The total utilization of a system is the sum of the utilizations of all
tasks in a system: U = u i
We will usually assume the relative deadline for the jobs in a task
is equal to the period of the task
It can sometimes be shorter than the period, to allow slack time
19
20
Sporadic and aperiodic tasks occur in some real-time systems, and greatly
complicate modelling and reasoning
21
22
Task Graphs
Can represent the precedence constraints among jobs in a set J
using a directed graph G = (J, <)
Each node represents a job represented; a directed edge goes from J i to J k
if J i is an immediate predecessor of J k
23
24
Functional Parameters
Jobs may have priority, and in some cases may be interrupted by
a higher priority job
A job is preemptable if its execution can be interrupted in this manner
A job is non-preemptable if it must run to completion once started
25
Scheduling
Jobs scheduled and allocated resources according to a chosen set
of scheduling algorithms and resource access-control protocols
Scheduler implements these algorithms
26
Scheduling
A valid schedule is also a feasible schedule if every job meets its
timing constraints.
Miss rate is the percentage of jobs that are executed but completed too
late
Loss rate is the percentage of jobs that are not executed at all
A hard real time scheduling algorithm is optimal if the algorithm
always produces a feasible schedule if the given set of jobs has
feasible schedules
Many scheduling algorithms exist: main focus of this module is
understanding real-time scheduling
27
Summary
Outline of terminology and a reference model:
Jobs and tasks
Processors and resources
Time and timing constraints
Hard real-time
Soft real-time
28