CS 1 and 2 - RTOS-Real Time Systems - Expanded
CS 1 and 2 - RTOS-Real Time Systems - Expanded
Tech,PhD
Guest Faculty, WILP, BITS Pilani
BITS Pilani Real Time Operating Systems
Pilani Campus
Course Agenda
Embedded System design
Real Time systems
Components
Real time Operating systems as a part of an
embedded system design
Real Time Databases
Real Time Communication
Performance and Engineering aspects
3
Introduction: Real-Time System
Real-time
– Does not denote speed/fast
– But meet the timing constraints or deadlines
A real-time system must deliver services in a timely manner
– Not necessarily fast, but must meet some timing deadline
Many real-time and embedded systems exist, often without
the awareness of their users
– Washing machine, photocopier, mobile phone, car,
aircraft, industrial plant, microwave oven, CD player,
medical devices, etc.
4
Introduction: Real-Time System
(Contd.,)
Must be able to validate real-time systems
for correctness
– Some embedded real-time systems are safety
critical – i.e. if they do not complete on a
timely basis, serious consequences result
– Bugs in embedded real-time systems are often
difficult or expensive to fix
5
What is Real-Time?
Real time is a quantitative notion of time
measured using a physical clock.
– Example : After a certain event occurs(temperature
exceeds 500 degrees) the corresponding action
(coolant shower) must complete within 100m sec.
This is in contrast to the quantitative notion of
time :
– Expressed using notions such as before, after,
sometime, eventually ,etc.
6
What is an embedded System
Embedded system is firmware
– Combination of software and Hardware
Why and where do we really use an embedded
system
– Embedded systems are devices which are
designed to accomplish a set of tasks or operations
What are the building blocks of an embedded
system
– Sensors or Actuators, microcontrollers, Output
display units
7
Nature and type of system
An embedded system needs to be timely in
nature
– By timeliness it implies that failure to meet
deadlines can bring the system to a grinding
halt
– Such systems are real time in nature.
It also implies that a real time clock should be
present in the system either as a hardware /
software component.
8
Timeliness
It is evident that real time systems need to be
timely in nature
– Under such constraints what would happen if
the timeliness constraint is not met
The failure to meet timeliness could be
devastating or not
Some applications like aircraft applications
where an automated pilot system is introduced
timeliness is critical
– These are hard real time systems
9
Timeliness
Embedded applications in toys and other
small devices timeliness may not actually
pose a threat.
– These are soft real time systems
10
Components of a real time
system
A real time system may actually have all or
a subset of components of a conventional
system.
– Real Time Operating System
– Real Time Database
– Real time communication
11
Block diagram showing a real
time system
12
Real Time Operating System
Operating System that is timely in nature
A real time operating system would have
features incorporated to handle exceptions
and failures.
In a nutshell a real time operating system
should be susceptible to failures
13
Real Time Operating System
Real time operating systems include
Vxworks, WinCE, RTLinux, QNX,
LynxOS etc
Smaller versions of RTOS are MicroC,
FreeRTOS, etc
14
Embedded system Applications
Industrial
– Chemical plant control
– Automated car assembly plant
– Supervisory Control and Data Acquisition(SCADA)
Medical
– Robot used in recovery of displaced
– Radioactive material, medical equipments
Peripheral Equipments
– Laser printer, digital cameras, sensors
15
Transportation
– Multi-point fuel injection (MPFI) system
– Automated car
Telecommunication Applications
– Cellular system
Multimedia Applications
– Video conferencing
Consumer Electronics
– Cell Phones, digital cameras
Defence Applications
– Missile Guidance System
16
MPFI:Multi point Fuel Injection
ECU(Engine control unit) controls the
timing and amount of fuel injected:
– Receive signal from various sensors,
– Process the signals
– Send control signals to the actuators
17
Basic model of an Embedded
System
18
Introduction: Real-Time System
Real-time system
(Contd.,)
respond to external events in a timely fashion and the response time
is guaranteed
19
Introduction: Real-Time System
(Contd.,)
Responding to external events includes
– Recognize when an event occurs
– Perform the required processing
– Output the result within a given time constraint
20
Introduction: Real-Time System
(Contd.,)
The structure of a real-time system is a controlling
system and at least one controlled system
Controlling
System
input output
Controlled Controlled
System System
Controlled
System
21 output input
Real-Time Systems (Contd.,)
The controlling system interacts with the controlled system in
various ways
– The interaction can be periodic
• The controlling system -> the controlled system
• Predictable and occurs at predefined intervals
– The interaction can be aperiodic
• The controlled system -> the controlling system
• Unpredictable from random occurrences of external events
– The communication can be a combination of both types
The controlling system must process and respond to the events
and information generated by the controlled system in a
guaranteed time frame.
22
Real-Time Systems Examples
Real-time weapons defense system
– Controlling system
• A command-and-decision (C&D) system
– Controlled system
• A radar system
• Weapons firing control system
– Communication between the radar system and
C&D system is aperiodic
– Communication between the C&D system and the
weapon firing control system is periodic
23
Real-Time Systems Examples (Contd.,)
Cruise missile guidance system
– Controlling system
• Navigation system: contain digital maps covering
the missile flight path
– Controlled system
• Radar system
• Divert-and-altitude-control system
– Communication between radars and the navigation
system is aperidoic
– Communication between the navigation system and the
diver-and-altitude-control system is periodic
24
Real-Time Systems Examples
(Contd.,)
DVD player
– Controlling system
• DVD player must decode both the video and audio
streams from the disc simultaneously.
– Controlled system
• Remote control is viewed as a sensor to feed pause
and language selection events into DVD player
25
Characteristics of Real-Time
Systems
Characteristics
– Must produce correct computational results,
called logical or functional correctness
– These computations must conclude within a
predefined period, called timing correctness
The overall correctness of a real-time
system depends on both the functional
correctness and the timing correctness
26
Representative Classes of Real-
Time and Embedded System
Digital control
– Sampled data systems
High-level controls
– Planning and policy above low level control
Signal processing
– Digital filtering, video compression &
encryption, radar signal processing
Other real-time applications
– Real-time databases, multimedia applications
27
Digital Control
Plant refers to controlled system e.g. an engine, brake.
The state of the plant is monitored by sensors and can be
changed by actuators.
The RTS estimates from the sensor readings the current
state and the desired state.
This is called as control – law computation of the
controller
28
Digital Control (Contd.,)
29
Digital Control Applications
Many real-time systems are embedded in sensors and
actuators and function as digital controllers.
The state of the controlled system is monitored by
sensors and can be changed by actuators.
The real-time computing system estimates from the
sensor readings the current state of the system and
computes a control output based on the difference
between the current state and the desired state.
The computed output controls the actuators which bring
the system closer to the desired state.
30
Sampled Data Systems
Before digital computers were widely used,
analogue controllers were used to control systems.
A common approach to designing a digital
controller is to start with a suitable analogue
controller.
The analogue version is transformed into a digital
(discrete time, discrete state) version.
The resultant controller is a sampled data system.
31
Inside a Sampled Data System
Periodically the analogue sensors are sampled
(read) and the readings digitized.
Each period the control-law computations are
carried out on the digitized readings.
The computed digital results are then
converted back to an analogue form needed
for the actuators.
This sequence of operations is repeated
periodically.
32
Computing the Control Law for a
Sampled Data System
Many control systems require knowledge of not
just the current sensor readings, but also some
past history.
For instance it may be necessary to know not only
the position of some part of the controlled system,
but also its velocity and perhaps its acceleration.
Often the control laws may take the form of
differential equations. It may be necessary to
have derivatives or integrals of measured
readings.
33
Effect of Sampling Period
Positions are
represented by 0 & 1
Time origin is r(t)
Output u(t) of the
analog controller is
given by dashed lines
Observed position y(t) is
function of time
Fig a – analog
Fig b & c – digital
34
Jitter
In some cases the response time of the
computation can vary from period to period.
In some systems it is necessary to keep this
variation small so that digital control outputs are
available at instants more regularly spaced in time.
In such cases we may impose a timing jitter
requirement on the control-law computation.
The variation in response time (jitter) does not
exceed some threshold.
35
More Complex Control-law Computations
The simplicity of our digital controller depends on
three assumptions:
1. Sensors give accurate estimates of the state-variable
values being monitored and controlled. This is not
always true given noise or other factors.
2. Sensor data give the state of the system. In general
sensors monitor some observable attributes and the
values of state variables have to be computed from the
measured values.
3. All parameters representing the dynamics of the system
are known.
36
A More Complex Digital Controller
37
A More Complex Digital
Controller (Contd.,)
Deadbeat Control
A discrete time control scheme that has no
continuous time equivalence is called deadbeat
control.
Kalman Filter
Used to improve the accuracy of measurements
and to estimate model parameters in the
presence of noise and uncertainity.
38
High-Level Controls
Controllers in complex systems are typically
organized hierarchically.
One or more digital controllers at the lowest
level directly control the physical system.
Each output of a higher-level controller is an
input of one or more lower-level controllers.
Usually one or more of the higher-level
controllers interfaces with the operator.
39
Examples of Control Hierarchy
A patient care system in a hospital.
– Low-level controllers handling blood pressure, respiration,
glucose, etc.
– High-level controller, e.g. an expert system which interacts with
the doctor to choose desired values for the low-level controllers
to maintain.
The hierarchy of flight control, avionics and air-traffic control
systems.
– The air-traffic control system is at the highest level.
– The flight management system chooses the flight paths etc. and
sets parameters for the lower level controllers.
– The flight controller at the lowest level handles cruise speed,
turn radius, ascend/descend rates etc.
40
Examples of Control Hierarchy
(Contd.,)
A more
complex
example of
hierarchy of
control is Air
Traffic Control
(ATC)
41
Guidance and Control
Digital controller deals with some dynamic behavior of the physical
plant
A second level perform typically guidance and path planning functions
It tries to find one of the most desirable trajectories among all the
trajectories that meet the constraints of the system.
The trajectory is most desirable because it optimizes cost functions as
the algorithm used for finding the solution generates optimized results.
Guidance and control should take care of the complexity and timing
requirements to solve non linear systems.
Higher level control systems leads to many additional complicated
control algorithms.
42
Real – Time Command and Control
The controller at
the highest level of
control hierarchy is
a command and
control system
ATC – monitors
the aircraft
coverage area, the
environment,
generates and
presents the
information needed
by the operators at
ATC
43
Signal Processing
Most signal processing applications are real-time
requiring response times from less than a
millisecond up to seconds. e.g. digital filtering,
video and audio compression/decompression, and
radar signal processing.
Typically a real-time signal processing application
computes in one sampling period, one or more
outputs, each being a weighted sum of n inputs.
The weights may even vary over time.
Each O/P x(k) is weighted sum of n I/P y(i)
44
Signal Processing Bandwidth
Demands
The processing time demand of an application
depends on the sampling period and how many
outputs are required to be produced per sampling
period.
For digital filtering the sampling rate can be tens
of kHz and the calculation may involve tens or
hundreds of terms, hence tens of millions of
multiplications and additions may be required
per second.
45
More Complex Signal Processing
While digital filtering is often a linear
computation depending on the number of terms in
the expression, other signal processing
applications are even more computationally
intensive.
For instance real-time video compression may
have complexity of order n2, and may require
hundreds of millions of multiplications per second.
Signal processing is usually part of a larger
system. e.g. a passive radar signal processing
system.
46
Radar Signal Processing
Fig shows the passive radar signal
processing and tracking system.
47
Radar Signal Processing (Contd.,)
The system comprises an I/O subsystem that samples
and digitizes the echo signal from the radar and
places the sampled values in shared memory.
An array of digital signal processors process these
values.
The data produced are analysed by one or more data
processors which not only interface to the display
system but also feed back commands to control the
radar and select parameters for the signal processors
to be used for the next sampling period.
Tracking, Gating, Data Association are the stages in
Radar Signal Processing
48
Other Real-Time Applications: Databases
Stock exchange price
database systems
Air traffic control
databases
What makes it real-time?
– The data is
‘perishable’
– The data values are
updated periodically
– After a while the data
has reduced value
– There needs to be
temporal consistency
as well as normal
data consistency
49
Real-Time Databases: Absolute
Temporal Consistency
Real-time data has parameters such as age and
temporal dispersion.
The age of an object measures how up-to-date the
information is?
The age of an object whose value is computed from
other objects is equal to that of the oldest of those
objects.
A set of data objects is said to be absolutely
temporally consistent if the maximum age in the set
is no greater than a certain threshold.
50
Real-Time Database: Relative
Temporal Consistency
51
Real-time Databases: Consistency Models
Concurrency control mechanisms such as 2-phase
locking have been used to ensure serializability of
read and update transactions and maintain data
integrity of non-real-time databases.
These mechanisms can make it more difficult for
updates to be completed in time.
Late updates may cause data to become temporally
inconsistent.
Weaker consistency models are sometimes used to
ensure the timeliness of updates and reads.
52
Real-time Databases: Consistency
Models (Contd.,)
For instance we may require updates to be
serializable but allow read-only transactions
not to be serializable.
Usually the more relaxed the serialization
requirement, the more flexibility the system
has in interleaving the read and write
operations from different transactions, and
the easier it is to schedule transactions so
that they complete in time.
53
Real-time Databases:
Consistency Models (Contd.,)
Kuo and Mok proposed that ‘similarity’ may be
a suitable correctness criterion in some real-
time situations.
Two views of a transaction are ‘similar’ if every
read operation gets similar values of every data
objects read by the transaction, where ‘similar’
means that the data values are within an
acceptable threshold from the point of view of
every transaction that may read the object.
54
Other Real-Time Applications:
Multimedia Applications
One of the most
frequently
encountered real-
time application
Multimedia may
process, store,
transmit and display
any number of video
streams, audio
streams, images,
graphics and text
55
Other Real-Time Applications:
Multimedia Applications (Contd.,)
MPEG Compression / decompression
Video compression standard MPEG make
use of three techniques:
– Motion compensation for reducing temporal
redundancy
– Discrete cosine transform for reducing spatial
redundancy
– Entropy encoding for reducing the no. of bits
required to encode all the information
56
Summary of Real-Time Applications
Purely cyclic: Every task executes periodically. Even I/O
operations are polled. Demands on resources do not vary
significantly from period to period. Most digital controllers are
of this type.
Mostly cyclic: Most tasks execute periodically. The system can
also respond to some external events asynchronously.
Asynchronous and somewhat predictable: In applications
such as multimedia communication, radar signal processing,
tracking, most tasks are not periodic. Duration between
executions of a task may vary considerably or the resource
requirements may vary. Variations have bounded ranges or
known statistics.
Asynchronous and unpredictable.
57
Jobs and Processors
For describing and characterizing different types of
real-time systems and methods for scheduling and
resource management we need job and task.
Job versus Task
Job: unit of work that is scheduled and executed by
the system
– Computation of control law is a job
– Computation of a FFT (Fast Fourier Transform)
– Transmission of a data packet
Task: a set of related jobs which jointly provide some
system function
58
Type of Tasks
A Periodic task is executed repeatedly at regular time
intervals, and each invocation is called a job or instance.
– Often time-driven
A Aperiodic task is executed to response to external events,
and to respond, it executes aperiodic jobs whose release time
are not know a priori
– Often event-driven
– Off-line guarantee of aperiodic tasks must make proper
assumptions on the environments; that is, by assuming a
maximum arrival rate for each event (i.e., minimum
interarrival time)
• Aperiodic tasks characterized by a minimum interarrival
time are called sporadic tasks
59
Release Times, Deadlines and
Timing Constraints
Release time of a job
– the instant of time at which the job becomes available
for execution
– Job can be scheduled and executed at any time at or
after its release whenever its data and control
dependency conditions are met
– Jobs have no release time if all the jobs are released
when the system begins execution
Response time
– The length of time from the release time of the job to
the instant when it completes
60
Release Times, Deadlines and
Timing Constraints (Contd.,)
Relative deadline
– The maximum allowable response time of a job
Deadline or Absolute Deadline
– The instant of time by which its execution is required to be
completed
– Equal to the release time plus the relative deadline
– A job has no deadline if its deadline is at infinity
Timing Constraints
– A constraints imposed on the timing behavior of a job
– Specified in terms of release time or deadline
– Periodic Tasks: Time-driven recurring at regular intervals.
– Aperiodic: event-driven.
61
Hard Real-Time System
Degree of tolerance of missed deadline
– Extremely small or zero
Usefulness of computed results after missed deadlines
– Likely useless
Severity of the penalty incurred for failing to meet deadlines
– catastrophe
Failure to meet constraint is a fatal fault. Validation system
always meets timing constraints.
– Deterministic constraints
– Probabilistic constraints
– Constraints in terms of some usefulness function.
62
Hard Real-Time System
(Contd.,)
Examples:
(many embedded systems are hard)
– Nuclear reactors
– Flight controller
– Weapon defense system
– Missile guidance system
63
Soft Real-Time System
Degree of tolerance of missed deadline
– Non-zero
Usefulness of computed results after missed
deadlines
– Have a rate of depreciation
Severity of the penalty incurred for failing to
meet deadlines
– Non-catastrophic
Late completion of jobs is undesirable but not
fatal. Validation - Demonstration of jobs meeting
some statistical constraints suffices
64
Soft Real-Time System
(Contd.,)
A miss of timing constraints is undesirable.
However, a few misses do no serious harm
– The timing requirements are often specified in
probability terms
– The time constraints are guaranteed on a
statistical basis
65
Soft Real-Time System
(Contd.,)
Examples:
• Multimedia Streaming
(25 frames per second
on an average)
• Electronic games
• Quality-of-Service (QoS)
guarantees
• Online databases
66
Comparison
Value
Deadline
Soft RTS
Hard RTS
Time
67
Summary of Hard v/s Soft
Real-time Systems
68
A Reference Model for Real-Time
Systems
69
Lecture Outline
• Why a reference model?
• Jobs and tasks
• Processors and resources
• Time and timing constraints
– Hard real-time
– Soft real-time
• Periodic, aperiodic and sporadic tasks
• Precedence constraints and dependencies
• Scheduling
Summary
70
A Reference Model of Real-
Time Systems
Want to develop a model to let us reason about real-time systems
– Consistent terminology
– Lets us to focus on the important aspects of a system while ignoring the
irrelevant properties and details
• Our reference model is characterized by:
– A workload model that describes the applications supported by the system
– A resource model that describes the system resources available to the
applications
– Algorithms that define how the application system uses the resources at
all times
• Today: focus on the first two elements of the reference model
– The next few lectures will study the algorithms, using the definitions from
this lecture
71
Jobs and Tasks
• 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
72
Processors and Resources
• 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:
• Threads scheduled on a CPU
• Data scheduled on a transmission link
• Read/write requests scheduled to a disk
• Transactions scheduled on a database server
73
Processors and Resources (Contd..)
– Each processor has a speed attribute which determines the rate
of progress a job makes toward completion
• May represent instructions-per-second for a CPU,
bandwidth of a network, etc.
– Two processors are of the same type if they are functionally
identical and can be used interchangeably
A resource, R, is a passive entity upon which jobs may
depend
– E.g. memory, sequence numbers, mutexes, database locks,
– Resources have different types and sizes, but do not have a
speed attribute
– Resources are usually reusable, and are not consumed by use
74
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
75
Use of Resources (Contd..)
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 don’t impact performance or correctness
76
Execution Time
A job Ji will execute for time ei
– This is the amount of time required to complete the execution
of Ji when it executes alone and has all the resources it needs
– Value of ei 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)
77
Execution Time (Contd..)
Execution times fall into an interval [ei -, ei
+]; assume that we know this interval for
every hard real-time job, but not necessarily
the actual ei
• Terminology: [x, y] is an interval starting immediately
after x, continuing up to and including y
Often, we can validate a system using ei+ for
each job; we assume ei = ei+ and ignore the
interval lower bound
– Inefficient, but safe bound on execution time
78
Release and Response Time
Release time – the instant in time when a
job becomes available for execution
– May not be exact: Release time jitter so ri is in the
interval [ri -, ri +]
– A job can be scheduled and executed at any time at, or
after, its release time, provided its resource dependency
conditions are met
79
Release and Response Time
(Contd..)
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
80
Deadlines and Timing
Constraints
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 (often
called simply the deadline)
- absolute deadline = release time + relative deadline
– Feasible interval for a job Ji is the interval (ri, di]
81
Deadlines and Timing Constraints (contd..)
82
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
The periodic computations can be stated in terms of release times of
the jobs computing the control-law: J0, J1, …, Jk, …
– The release time of Jk is 20 + (k × 100) ms
83
Example (Contd..)
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
84
Types of Task
There are various types of task
– Periodic
– Aperiodic
– Sporadic
• Different execution time patterns for the jobs in
the task
• Must be modelled differently
– Differing scheduling algorithms
– Differing impact on system performance
– Differing constraints on scheduling
85
Modelling Periodic Tasks
A set of jobs that are executed repeatedly at
regular time intervals can be modeled as a
periodic task
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 ri,1 of the first
job Ji,1 in the task. It is denoted by ϕi (“phi”)
– The period pi of a task Ti is the minimum length of all time
intervals between release times of consecutive jobs
–
86
Modelling Periodic Tasks (Contd..)
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
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
87
Modelling Periodic Tasks
(Contd..)
Example:
– T1 : p1 = 3, e1 = 1
– T2 : p2 = 5, e2 = 2
88
Modelling Periodic Tasks
(Contd..)
The ratio ui = ei/pi is the utilization of task Ti
– The fraction of time a periodic task with period pi and execution time
ei keeps a processor busy
• The total utilization of a system is the sum of the utilizations of
all tasks in a system: U = Σ ui
• 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
90
Modelling Sporadic and
Aperiodic Tasks
A set of jobs that execute at irregular time intervals
comprise a sporadic or aperiodic task
– Each sporadic/aperiodic task is a stream of
sporadic/aperiodic jobs
• The inter-arrival times between consecutive jobs in
such a task may vary widely according to probability
distribution A(x) and can be arbitrarily small
• Similarly, the execution times of jobs are identically
distributed random variables with some probability
distribution B(x)
91
Precedence Constraints and
Dependencies
The jobs in a task, whether periodic, aperiodic or sporadic, may
be constrained to execute in a particular order
– This is known as a precedence constraint
– A job Ji is a predecessor of another job Jk (and Jk a successor
of Ji) if Jk cannot begin execution until the execution of Ji
completes
• Denote this by saying Ji < Jk
– Ji is an immediate predecessor of Jk if Ji < Jk and there is no
other job Jj such that Ji < Jj < Jk
– Ji and Jk are independent when neither Ji < Jk nor Jk < Ji
A job with a precedence constraint becomes ready for execution
once when its release time has passed and when all predecessors
have completed
92
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
Ji to Jk if Ji is an immediate predecessor of
Jk
93
Task Graphs: Dependencies &
Constraints
Normally a job must wait for the completion of all
immediate predecessors; an AND constraint
– Unfilled circle in the task graph
• An OR constraint indicates that a job may begin after its
release time if only some of the immediate predecessors
have completed
– Unfilled squares in the task graph
• Represent conditional branches and joins by filled in circles
• Represent a pair of producer/consumer jobs with a dotted edge
• Use to visualize structure of real time systems
94
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
• Many preemptable jobs have periods during which they
cannot be preempted; for example when accessing certain
resources
95
Functional Parameters (Contd..)
-The context switch time is the time taken to switch between
jobs
• Forms an overhead that must be accounted for
when scheduling jobs
Response to missing a deadline can vary
– Some jobs have optional parts, that can be omitted to save
time (at the expense of a poorer quality result)
– Usefulness of late results varies; some applications
tolerate some delay, others do not
96
Scheduling
Jobs scheduled and allocated resources
according to a chosen set of scheduling
algorithms and resource access-control
protocols
– Scheduler implements these algorithms
• A scheduler specifically assigns jobs to
processors
• A schedule is an assignment of all jobs in the
system on the available processors
97
Scheduling (Contd..)
A valid schedule satisfies the following
conditions:
– Every processor is assigned to at most one job at any
time
– Every job is assigned at most one processor at any time
– No job is scheduled before its release time
– The total amount of processor time assigned to every
job is equal to its maximum or actual execution time
– All the precedence and resource usage constraints are
satisfied
98
Scheduling (Contd..)
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
99
Summary
Outline of terminology and a reference
model:
– Jobs and tasks
– Processors and resources
– Time and timing constraints
• Hard real-time
• Soft real-time
– Periodic, aperiodic and sporadic tasks
– Precedence constraints and dependencies
– Scheduling
100