You are on page 1of 28

Chapter 2

Hard versus Soft Real-Time Systems

2.1 Important Concepts


2.1.1 JOBS & TASKS
For the purpose of describing and characterizing different types of real-time systems and methods for
scheduling and resource management, it is more convenient for us to speak of all kinds of work done by
computing and communication systems in general terms.

2.1.1.1 Jobs
A job is a unit of work that is scheduled and executed by a system.
The basic component of any real-time application is jobs.
The operating system treats jobs as a unit of work and allocates processors and resources.
Examples:
Computation of a control-law, computation of a Fast Fourier Transform (FFT) on sensor data,
transmission of a data packet, retrieval of a file.
Every job executes on some resource. For example, the jobs mentioned above execute on a CPU, a
network, and a disk, respectively.
Job parameters
A job Ji is characterized by many parameters:
execution time
deadlines
preemptivity
resource requirements.
2.1.1.2 Task
A task is a set of related jobs which jointly provide some system function.
Example:
The set of jobs that constitute the maintain constant altitude task, keeping an airplane flying at a
constant altitude.
Includes jobs like monitor cruise speed, adjust engine revolution, monitor wind speed.

1
2.1.2 SYSTEM RESOURCES
We divide all the system resources into two types:
Processors
Resources
2.1.2.1 Processors
Processors have some autonomous processing capabilities.
They carry out machine instructions, move data from one place to another, retrieve files, process queries,
and so on.
Sometimes called servers or active resources such as computers, data links, database servers etc.
Every job must have one or more processors in order to execute and make progress toward completion.
A processor, P, is an active component on which jobs are scheduled.
Two processors are of the same type if they are functionally identical and can be used interchangeably.
Hence two transmission links with the same transmission rate between a pair of sender and receiver
are processors of the same type.
Processors have attributes such as preemptivity, context switch time, speed.
Each processor has a speed attribute which determines the rate of progress a job makes toward completion.
The rate of progress a job makes depends on the speed of the processor on which it is running. i.e., how
long a job takes to complete does not depend on the speed of any resource it uses during execution.
May represent instructions-per-second for a CPU, bandwidth of a network, etc.
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
2.1.2.2 Resources
Resources specifically mean passive resources such as file systems, main memory, sequence numbers,
mutual exclusion locks, semaphores etc.
Jobs may also need some resources in addition to the processor in order to make progress.
Resources are of different types and sizes but they do not have a speed attribute.
Resources are usually reusable, and are not consumed by use.
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, and then release it.

2
A resource is plentiful if no job is ever prevented from executing by the unavailability of units of the
resource.
We generally use the letter R to denote resources.
2.1.3 EXECUTION TIME, RELEASE TIMES, DEADLINES, & TIMING CONSTRAINTS

2.1.3.1 Execution Time


Execution time ei is the amount of time required to complete Ji, when it executes alone and has all
resources it needs.
The execution time ei depends on speed of processor and complexity of job, but may vary due to
Caches, pipeline, conditional branches.
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.
Especially for hard-real time systems ei often denotes the maximum execution time i.e., ei+.
2.1.3.2 Release Time
The release time of a job is the instant of time at which the job becomes available for execution.
The job can be scheduled and executed at any time at or after its release time whenever its data and control
dependency conditions are met.

2.1.3.3 Response time


The response time is the length of time from the release time of the job to the time instant it completes.
Not the same as execution time since may not execute continually.
Response time = Job completion time Job release time.

2.1.3.4 Deadlines
The deadline of a job is the instant of time by which its execution is required to be completed.

3
Relative deadline
The maximum allowable response time of a job is called a relative deadline.
It is the time interval between the start of the job (release time or arrival time) and the instant at which
the deadline occurs.
It is the length of time between the release time and absolute deadline of each job of that task.
Absolute deadline
The absolute deadline of a job is the absolute time value (counted from 0) by which its execution must
be completed. It is equal to the interval of time between the time 0 and the actual instant at which the
deadline occurs.
The instant of time by which a job is required to be completed (often called simply the deadline).
absolute deadline = release time + relative deadline.

Example: Heating furnaces


System monitors and controls several heating furnaces (ovens).
System takes 20ms to initialize.
After initialization, every 100ms, the system
Samples and reads each temperature sensor.
Computes the control law of each furnace to determine flow rates of fuel, air and coolant.
Adjust flow rates.
The control law computations are periodic and can be stated in terms of release times of the control-
law computation jobs J0, J1,. . . Jk, . . .
So, the release time of the job Jk in this job stream is 20 + (k 100) ms, for k = 0, 1...
We say that jobs have no release time if all the jobs are released when the system begins execution.
So release times are 20 ms , 120 ms ,220 ms.respectively.
Suppose that in the previous example, each control-law computation job must complete by the release
time of the subsequent job.
4
Then, deadlines (absolute deadline) for control law computation jobs J0, J1,are 120 msec, 220 msec,
and so on, respectively.
Hence the relative deadline of every control-law computation job mentioned above is 100 ms. (How?)

2.1.3.5 Tardiness and Lateness


The tardiness and lateness of a job measures how late a job completes w.r.to its deadline.
lateness = completion time absolute deadline.
Delay or earliness of a particular job.
Lateness can be positive or negative.
Positive lateness is tardiness; negative lateness is earliness.
tardiness = maximum (0, lateness)
Exceeding time.
Can only be positive.
Its tardiness is zero if the job completes at or before its deadline; otherwise, if the job is late, its
tardiness is equal to the difference between its completion time (i.e., the time instant at which it
completes execution) and its deadline.
2.2 TIMING CONSTRAINT
A constraint imposed on the timing behavior of a job is a timing constraint. In its simplest form, a timing
constraint of a job can be specified in terms of its release time and relative or absolute deadlines.
It is common to divide timing constraints into two types: hard and soft.
2.2.1 HARD AND SOFT TIMING CONSTRAINTS
They are based on the functional criticality of jobs, usefulness of late results, and deterministic or
Probabilistic nature of the constraints.
In real-time systems literature, the distinction between hard and soft timing constraints is can be stated
quantitatively in terms of the usefulness of results (and therefore the overall system performance) as
functions of the tardinesses of jobs.
2.2.1.1 Hard Timing constraints
A timing constraint or deadline is hard if the failure to meet it is considered to be a fatal fault. A hard
deadline is imposed on a job because a late result produced by the job after the deadline may have
disastrous consequences. This definition is based upon the functional criticality of a job.

5
A timing constraint is hard if the usefulness of the results falls off abruptly at the deadline.
A timing constraint is hard if the user requires validation (formal proof or simulation) that the system
always meets its timing constraint.
If a job must never miss its deadline, then the deadline is hard.
Hard timing constraints are deterministic in nature.
Deterministic constraints
E.g., the relative deadline of every control-law computation is 50 ms.
Examples:
A late command to stop a train may cause a collision, and
A bomb dropped too late may hit a civilian population instead of the intended military target.
2.2.1.2 Soft Timing Constraints
A deadline or timing constraint is considered soft, if the failure to meet it undesirable, but does not lead
to fatal faults.
In contrast, the late completion of a job that has a soft deadline is undesirable. However, a few misses of
soft deadlines do no serious harm; only the systems overall performance becomes poorer and poorer
when more and more jobs with soft deadlines complete late.
If its deadline can be missed occasionally with some acceptably low probability, then its timing
constraint is soft.
The usefulness of a result produced by a soft real-time job (i.e., a job with a soft deadline) decreases
gradually as the tardiness of the job increases.
The deadline of a job is softer if the usefulness of its result decreases at a slower rate.
Soft timing constraints are probabilistic in nature.
Probabilistic constraints
Constraints defined in terms of tails of some probability distributions.
E.g., the probability of the response time exceeding 50 ms is less than 0.2.
2.2.2 Hard Timing Constraints and Temporal Quality-of-Service Guarantees
The timing constraint of a job is hard, and the job is a hard real-time job, if the user requires the validation
that the system always meets the timing constraint.
By validation, we mean a demonstration by a provably correct, efficient procedure or by exhaustive
simulation and testing.
On the other hand, if no validation is required, or only a demonstration that the job meets some statistical
constraint (i.e., a timing constraint specified in terms of statistical averages, e.g., the average number of
missed deadlines per minute is two or less) suffices, then the timing constraint of the job is soft.
This way to differentiate between hard and soft timing constraints is compatible with the distinction
between guaranteed and best-effort services.

6
If the user wants the temporal quality (e.g., response time and jitter) of the service provided by a task
guaranteed and the satisfaction of the timing constraints defining the temporal quality validated, then the
timing constraints are hard.
On the other hand, if the user demands the best quality of service the system can provide but allows the
system to deliver qualities below what is defined by the timing constraints, then the timing constraints are
soft.
Some Reasons for Requiring Timing Guarantees
Many embedded systems are hard real-time systems. Deadlines of jobs in an embedded system are
typically derived from the required responsiveness of the sensors and actuators monitored and controlled
by it.
As an example, we consider an automatically controlled train. It cannot stop instantaneously. When the
signal is red (stop), its braking action must be activated a certain distance away from the signal post at
which the train must stop. This braking distance depends on the speed of the train and the safe value of
deceleration. From the speed and safe deceleration of the train, the controller can compute the time for the
train to travel the braking distance. This time in turn imposes a constraint on the response time of the jobs
which sense and process the stop signal and activate the brake. This timing constraint should be hard and
that its satisfaction must be guaranteed.
Similarly, each control-law computation job of a flight controller must be completed in time so that its
command can be issued in time. Otherwise, the plane controlled by it may become oscillatory (and the
ride bumpy) or even unstable and uncontrollable. For this reason, we want the timely completion of all
control-law computations guaranteed.
2.3 HARD REAL-TIME SYSTEMS
A hard real-time task is one that is constrained to produce its results within certain predefined time bounds.
The system is considered to have failed whenever any of its hard real-time tasks does not produce its
required results before the specified time bound.
An application (task) with hard timing constraints a hard real-time application and a system containing
mostly hard real-time applications a hard real-time system.
Examples:
An example of a system having hard real-time tasks is a robot.
The robot cyclically carries out a number of activities including communication with the host
system, logging all completed activities, sensing the environment to detect any obstacles present,
tracking the objects of interest, path planning, effecting next move, etc.
Now consider that the robot suddenly encounters an obstacle. The robot must detect it and as soon
as possible try to escape colliding with it. If it fails to respond to it quickly (i.e. the concerned tasks
are not completed before the required time bound) then it would collide with the obstacle and the

7
robot would be considered to have failed. Therefore detecting obstacles and reacting to it are hard
real-time tasks.
Another application having hard real-time tasks is an anti-missile system.
An anti-missile system consists of the following critical activities (tasks). An anti-missile system
must first detect all incoming missiles, properly position the anti-missile gun, and then fire to
destroy the incoming missile before the incoming missile can do any damage. All these tasks are
hard real- time in nature and the anti-missile system would be considered to have failed, if any of
its tasks fails to complete before the corresponding deadlines.
2.4 SOFT REAL TIME SYSTEMS
A soft real-time system is a system containing only soft real-time tasks.
A system in which jobs have soft deadlines is a soft real-time system. Soft real-time tasks also have time
bounds associated with them. But these time bounds are probabilistic in nature.
However, unlike hard real-time tasks, the timing constraints on soft real-time tasks are not expressed as
absolute values. Instead, the constraints are expressed either in terms of the average response times
required.
Examples:
On-line transaction systems and telephone switches, as well as electronic games, multimedia system,
web browsing.
Normally, after an URL (Uniform Resource Locater) is clicked, the corresponding web page is fetched
and displayed within a couple of seconds on the average. However, when it takes several minutes to
display a requested page, we still do not consider the system to have failed, but merely express that the
performance of the system has degraded.
Another example of a soft real-time task is a task handling a request for a seat reservation in a railway
reservation application. Once a request for reservation is made, the response should occur within 20
seconds on the average. The response may either be in the form of a printed ticket or an apology
message on account of unavailability of seats.
2.5 SUMMARY

2.5.1 Basic Parameters


arrival time or release time: ai
Time when a task becomes ready for execution also denoted release time, request time: ri.
computation time: Ci
Time necessary for completion of a task.
absolute deadline: di
Time before which a task should be completed.
start time: si

8
Time at which a task starts its execution.
finishing time: fi
Time at which a task finishes its execution.
Criticality(timing constraints)
typically hard/soft

2.5.2 Derived Parameters


relative deadline
Di = di - ai
response time
Ri = fi - ai
lateness
Li = fi - di,
Delay of a task (can be negative).
tardiness (exceeding time)
Ei = max(0; Li )
slack time (laxity)
Xi = di - ai - Ci
Maximum time a task can be delayed on its activation to complete within deadline.
Problem

Determine response time, absolute deadline, relative deadline, lateness of each job (in your schedule).

9
CHAPTER3
A Reference Model of Real-Time Systems

3.1 INTRODUCTION
Reference model for real-time systems is characterized by:
A workload model that describes applications running on the system/supported by the system.
A resource model that describes the resources available to those applications.
A scheduling algorithm that define how the applications execute and use the resources.
Why reference model?
Forms the base for specifying and achieving timing behavior of the real time systems.

3.2 PROCESSORS AND RESOURCES


Discussed in previous chapter (Refer, Chapter 2 for more details).

3.3 TYPES OF TASK IN REAL-TIME SYSTEMS


There are various types of task:
Periodic Task
Aperiodic
Sporadic

3.3.1 PERIODIC TASK MODEL


The periodic task model is a well-known deterministic workload model.
This model characterizes accurately many hard real-time applications, such as digital control, real-time
monitoring, and constant bit-rate voice/video transmission.
Many scheduling algorithms based on this model have good performance and well-understood behavior.
In this model, each computation or data transmission which is executed repeatedly at regular or semi-
regular time intervals is modeled as a periodic task.
3.3.1.1 Periodic Task
A set of jobs that are executed repeatedly at regular or semi-regular time intervals is called periodic task.
In other words, a periodic task is one that repeats after a certain fixed time interval.
A common use of periodic tasks is to process sensor data and update the current state of the real-time
system on a regular basis.
Generally, periodic tasks have regular arrival times and hard deadlines but in some applications the
deadlines can be soft.
Periodic tasks, typically used in control and signal-processing applications, have hard deadlines.
At all times, the period and execution time of every periodic task in the system are known.

10
Assume that the tasks in the system are T1, T2, . . . , Tn.
Each periodic task Ti is a sequence of jobs Ji, j (i.e., Ji,1, Ji,2, , Ji, n), and can be represented by a 4 tuple(i,
pi, ei, Di), where;
i called the phase of Task Ti,
It is equal to ri, 1, i.e. it is the release time of the first job Ji,1 in the task Ti.
That is, i = ri, 1.
pi is called the period of task Ti
It is the minimum length of all time intervals between release times of consecutive jobs (minimum
inter-release interval between jobs) in Ti.
ei is called the execution time (or worst case execution time) of Ti.
Maximum execution time of all the jobs in task Ti.
Di is called the relative deadline of the task Ti.

Hyperperiodi (H) of Tasks


The hyperperiod of a set of periodic tasks is the least common multiple of their periods. It is denoted by
H. In other words, a time interval of length H is called a hyper-period of the periodic tasks.
H = LCM (pi) for i = 1, 2 n.

The (maximum) number of jobs N in each hyperperiod is equal to
=1 .

Example:
The length of a hyperperiod of three periodic tasks with periods 3, 4, and 10 is 60.
The total number of jobs in the hyperperiod (N)=41 (HOW?).

Utilization (ui)
The ratio of execution time and period is called utilization of a task Ti.
So, ui = ei / pi is the utilization of task Ti.
ui is equal to the fraction of time a truly periodic task with period pi and execution time ei keeps a processor
busy.
Total Utilization (U)
The total utilization of a system is the sum of the utilizations of all tasks in a system.
That is, sum over all ui.
U = =1
Example:
If the execution times of the three periodic tasks are 1, 1, and 3, and their periods are 3, 4, and 10,
respectively, then their utilizations are 0.33, 0.25 and 0.3.
The total utilization of the tasks is 0.88; these tasks can keep a processor busy at most 88 percent of
the time.
11
The number of jobs in the hyperperiod = sum (H/p1 +H/p2)
=sum (15/3+15/5)
=8
Total utilization= sum (e1/p1 +e2/p2)
= sum (1/3+2/5)
=0.733
Advantages, Limitations & Assumptions about Periodic Task Model
A vast majority of the tasks present in a typical real-time system are periodic. The reason for this is that
many activities carried out by real-time systems are periodic in nature, for example monitoring certain
conditions, polling information from sensors at regular intervals to carry out certain action at regular
intervals (such as drive some actuators).
The accuracy of the periodic task model decreases with increasing jitter in release times and variations in
execution times. So, a periodic task is an inaccurate model of the transmission of a variable bit-rate video,
because of the large variation in the execution times of jobs (i.e., transmission times of individual frames).
When the deadline of a task equals its period (i.e. pi=di), we can omit the fourth tuple. In this case, we can
represent the task as Ti= (2000 mSec, 50 mSec, 8 mSec). This would automatically mean pi=di=50 mSec.
Similarly, when i = 0, it can be omitted when no confusion arises. So, Ti = (20mSec; 100mSec) would
indicate a task with i = 0, pi=100mSec, ei=20mSec, and di=100mSec. Whenever there is any scope for
confusion, we shall explicitly write out the parameters.
3.3.2 Aperiodic & Sporadic
Almost every real-time system is required to respond to external events which occur at random instants of
time. When such an event occurs, the system executes a set of jobs in response. The release times of these

12
jobs are not known until the event triggering them occurs. These jobs are called sporadic jobs or aperiodic
jobs because they are released at random time instants.
Example:
For example, the pilot may disengage the autopilot system at any time. When this occurs, the autopilot
system changes from cruise mode to standby mode. The jobs that execute to accomplish this mode
change are sporadic jobs.
An aperiodic job has either a soft deadline or no deadline.
Example:
The task to adjust radars sensitivity is an example. We want the system to be responsive, that is,
to complete each adjustment as soon as possible. On the other hand, a late response is annoying
but tolerable.
A sporadic job has a hard deadline.
Example:
An autopilot system is required to respond to a pilots command to disengage the autopilot and
take over the control manually within a specific time.
Sporadic Task
Each sporadic task is a stream of sporadic jobs.
A sporadic task is an aperiodic task with a hard deadline and a minimum inter-release time. Tasks
containing jobs that are released at random time instants and have hard deadlines are sporadic tasks.
Without a minimum inter-release time restriction, it is impossible to guarantee that a sporadic task's
deadline would always be met.
A sporadic task Ti can be is represented by a three tuple:
Ti = (ei, gi, Di),
Where ei is the worst case execution time of an instance of the task, gi denotes the minimum separation
between two consecutive instances of the task, Di is the relative deadline. gi is the minimum separation
between two consecutive instances of the task. It implies that once an instance of a sporadic task occurs, the
next instance cannot occur before gi time units have elapsed. That is, gi restricts the rate at which sporadic
tasks can arise.

Aperiodic Task
Each aperiodic or sporadic task is a stream of aperiodic or sporadic jobs, respectively.
An aperiodic task is a stream of jobs arriving at irregular time intervals. An aperiodic task has either a soft
deadline or no deadline.
In other words, a task is aperiodic if the jobs in it are released at random time instants, and have either soft
deadlines or no deadlines.

13
A sporadic task Ti can be is represented by a three tuple:
Ti = (ei, ri, Di),
Where ei is the worst case execution time of an instance of the task, ri denotes the release time of the task,
Di is the relative deadline.
The deadline for an aperiodic task is expressed as either an average value or is expressed statistically.

Release times & Execution times of aperiodic/sporadic jobs


So the release times of sporadic and aperiodic jobs are random variables.
The release time for sporadic or aperiodic job can be modeled as a random variable with some probability
distribution, A(x).
A(x) gives the probability that the release time of the job is not later than x, for all valid values of x.
For sporadic/aperiodic task, A(x) can be viewed as the probability distribution of inter-release time (i.e.,
the length of the time interval between the release times of two consecutive jobs in the stream).
A(x) gives the inter-release time of the stream of jobs is equal to or less than x, for all valid values of
x.
Similarly, the execution times of jobs in each aperiodic (or sporadic) task are distributed random variables,
so can be given by the probability distribution B(x).
3.3.3 TEMPORAL PARAMETERS OF REAL-TIME WORKLOAD

3.3.3.1 The number of tasks or jobs in the system


Many parameters of hard real-time jobs and tasks are known at all times; otherwise, it would not be
possible to ensure that the system meet its hard real-time requirements.
In many embedded systems, the number of tasks is fixed as long as the system remains in an operation
mode. The number of tasks may change when the system operation mode changes, and the number of
tasks in the new mode is also known.
Take the flight control system as an example. During cruise mode, the system has 12 tasks (i.e., 3 30-
Hz avionics tasks, 3 30-Hz computations and 2 90-Hz computations, plus 180-Hz computation,
validation, output and built-in-test tasks). If the system triply replicates all control-law computations
during landing, the number of tasks increases to 24 when it operates in the landing mode.
Moreover, these numbers are known in a priori before the system begins execution.
In some other systems, however, the number of tasks may change as tasks are added and deleted while the
system executes.
As an example, in an air traffic control system, each surveillance task monitors an aircraft. The number
of such tasks changes as tasks are added and deleted when aircraft enter and leave the coverage area.
But, the number of tasks with hard timing constraints is known at all times.
When the satisfaction of their timing constraints is to be guaranteed, the admission and deletion of hard
real-time tasks are usually done under the control of the run-time system.
14
(e.g., by having the application system for request admission and deletion of tasks).
For this purpose, the run time system must maintain information on all existing hard real-time tasks,
including the number of such tasks.
3.3.3.2 Jobs Characteristics
Each job Ji is characterized by:
Temporal parameters
Its temporal parameters tell us its timing constraints and behavior.
Examples: For job Ji
Release time ri
Absolute deadline di
Relative deadline Di
Feasible interval (ri, di]
The feasible interval is the time interval between release time and absolute deadline.
The notation (ri, di] means the interval that begins immediately after ri and ends at di.
Functional parameters
Its functional parameters specify the intrinsic properties of the job.
Examples:
Preemptivity of jobs.
Criticality of jobs.
Optional Execution.
Laxity type and Laxity Function.
Resource parameters
Its resource parameters give us its resource requirements.
Interconnection parameters
Its interconnection parameters describe how it depends on other jobs and how other jobs depend
on it.
3.3.3.3 Fixed, Jittered, and Sporadic Release Times
In many systems, we do not know exactly when each job will be released. In other words, we do not know
the actual release time ri of each job Ji. But, we know that ri is in a range [ri, ri+].
ri can be as early as the earliest release time ri and as late as the latest release time ri+.
This range [ri, ri+] is called release time jitter in ri. It represents the amount of uncertainty or variation in
release time.
If the release time jitter is very small compared with other temporal parameters, we can approximate the
actual release time by its earliest ri or latest ri+ release time, and say that the job has a fixed release time.
Sporadic jobs/aperiodic jobs are released at random time instants.

15
So the release times of sporadic/aperiodic jobs can be represented by random variables, and can be
modeled as a random variable with some probability distribution, A(x).
A(x) gives the probability that the release time of the job is not later than x, for all valid values of x.
3.3.3.4 Execution Time
Another temporal parameter of a job, Ji , is its execution time, ei.
Execution time ei is the amount of time required to complete Ji, when it executes alone and has all resources
it needs.
Hence, the value of this parameter depends mainly on the complexity of the job and the speed of the
processor used to execute the job, not on how the job is scheduled.
The actual execution time of the job modeling the transmission of a frame is unknown a priori. What can
be determined a priori through analysis and measurement are the maximum and minimum amounts of time
required to complete each job.
In other words, we know that the execution time ei of the job Ji is in the range [ei, ei+], where ei and ei+
are the minimum execution time and the maximum execution time of Ji, respectively. We usually assume
that we know ei and ei+ of every hard real-time job Ji, but the actual execution time of the job is unknown.
For the purpose of determining whether each job can always complete by its deadline, knowing the
maximum execution time of each job often suffices. For this reason, in most deterministic models it is
used to characterize hard real-time applications, the term execution time ei of each job Ji specifically means
its maximum execution time.
3.4 FUNCTIONAL PARAMETERS
Functional parameters specify the intrinsic properties of the job.
For making scheduling and resource access-control decisions, it is very important to consider functional
characteristics of jobs. Because, several functional properties affect these decisions.
The workload model must explicitly describe these properties, using values of functional parameters:
Preemptivity
Criticality
Optional interval
Laxity Type and Laxity Function.
3.4.1 Preemptivity of Jobs
Executions of jobs can often be interleaved.
The scheduler may suspend the execution of a less urgent job and give the processor to a more urgent job.
Later when the more urgent job completes, the scheduler returns the processor to the less urgent job so the
job can resume execution. This interruption of job execution is called preemption.
A job is preemptable if its execution can be suspended at any time to allow the execution of other jobs
and, later on, can be resumed from the point of suspension.
Computation jobs that execute on CPUs are examples of preemptable jobs.
16
A job is nonpreemptable if it must be executed from start to completion without interruption. This
constraint may be imposed because its execution, if suspended and the processor given to other jobs, must
be executed again from the beginning.
Data transmission
Transmissions of data frames. If transmission of a frame is interrupted before it completes, the
partially transmitted frame is discarded by the receiver. The entire frame must be retransmitted
from the start. To avoid wasting bandwidth in this way, we make the execution of this job on the
ring (or bus) nonpreemptable.
During preemption, the system must first save the state of the preempted job at the time of preemption so
it can resume the job from that state. Then, the system must prepare the execution environment for the
preempting job before starting the job.
For example, in the case of CPU jobs, the state of the preempted job includes the contents of its
program counter, processor status register, and registers containing temporary results. After saving the
contents of these registers in memory and before the preempting job can start, the operating system
must load the new processor status register, clear pipelines, and so on. These actions are collectively
called a context switch.
A context switch is the process of storing and restoring the state of a job so that execution can be resumed
from the same point at a later time.
The amount of time required to accomplish a context switch is called a context-switch time.
3.4.2 Criticality of Jobs
In any system, jobs are not equally important. The importance (or criticality) of a job is a positive number
that indicates how critical the job is with respect to other jobs; the more critical the job, the larger its
importance.
Priority and weight are often used to refer to importance; the more important a job, the higher its priority
or the larger its weight.
During an overload when it is not possible to schedule all the jobs to meet their deadlines, it is necessary
to sacrifice the less critical jobs so that the more critical jobs can meet their deadlines.
For this reason, some scheduling and resource access-control algorithms try to optimize weighted
performance measures such as weighted average response time (i.e., the average of response time
multiplied by importance) or weighted average tardiness (i.e., the average of tardiness multiplied by
importance) over all jobs.
Examples:
In a flight control and management system, the job that controls the flight of the aircraft is more critical
than the navigation job that determines the current position relative to the chosen course.
The navigation job is more critical than the job that adjusts the course and cruise speed in order to
minimize fuel consumption.
17
3.4.3 Optional Executions
It is often possible to structure an application so that some jobs or portions of jobs are optional.
If an optional job or an optional portion of a job completes late or is not executed at all, the system
performance may degrade, but nevertheless function satisfactorily.
In contrast, jobs and portions of jobs that are not optional are mandatory; they must be executed to
completion.
Therefore, during a transient overload when it is not possible to complete all the jobs in time, we may
choose to discard optional jobs (i.e., leave them unexecuted or partially executed) so that the mandatory
jobs can complete in time.
The optional parameter of each job indicates the portion of the job that is optional. Marking a job or a
portion of a job optional is way for the designer to indicate that the job is not critical.
By explicitly identifying the optional jobs and using a scheduling strategy that takes advantage of this
information.
3.4.4 Laxity Type and Laxity Function

Laxity or slack time(Xj) is the maximum time that a job can be delayed and still meet its deadline.
Xj = dj -rj - Cj
Xj = Dj - Cj
The laxity type of a job indicates whether its timing constraints are soft or hard.
Laxity function gives the usefulness of the result produced by the job as a function of its tardiness.
Hard RT Jobs: Usefulness becomes zero or negative as soon as job is tardy. Better never than late.
Soft RT Jobs: Usefulness decreases gradually.
Figure below gives several usefulness functions as examples. The ones shown as solid step functions are
usually associated with hard real-time jobs. The dashed and dotted lines associated with soft real time jobs.

Figure: Examples of usefulness functions.


18
An example of jobs that have this kind of usefulness function is a stock price update transaction. It may
be tolerable if the update completes slightly late and the price x written into the database is somewhat old.
However, if the transaction completes so late that the current price differs significantly from x, the result
x can be misleading. By that time, the usefulness of this update becomes negative.

3.5 RESOURCE PARAMETERS OF JOBS AND PARAMETERS OF RESOURCES


Every job requires a processor throughout its execution. In addition to a processor, a job may also require
some resources.
The resource parameters of each job give us the type of processor and the units of each resource type
required by the job and the time intervals during its execution when the units are required.
These parameters provide the information that is needed to support resource management decisions.
3.5.1 Preemptivity of Resources
A resource parameter is preemptivity.
A resource is nonpreemptable if each unit of the resource is constrained to be used serially.
In other words, once a unit of a nonpreemptable resource is allocated to a job, other jobs needing the unit
must wait until the job completes its use.
Otherwise, if jobs can use every unit of a resource in an interleaved fashion, the resource is preemptable.
A preemptable resource is one that can be taken away from the process with no ill effects. Memory is an
example of a preemptable resource.
The lock on a data object in a database is an example of nonpreemptable resource.
Example: lock on a data object in a database
When a job modeling a transaction that reads and writes the data object has acquired the lock, other
jobs that also require this lock at the time must wait. The lock is a nonpreemptable resource.
3.5.2 Resource Graph
The resource graph describes the configuration of the resources.
In a resource graph, there is a vertex Ri for every processor or resource Ri in the system. Generally, we
use letters P for processors and R for (passive) resources.
The attributes of the vertex are the parameters of the resource:
The resource type of a resource tells us whether the resource is a processor or a (passive) resource.
Number gives us the number of available units of that resource.
Edges in a resource graph represent the relationship among resources. Using different types of edges, we
can describe different configurations of the underlying system.
There are two types of edges in resource graphs:
is-a-part-of edge
An edge from a vertex Ri to another vertex Rk means that Rk is a component of Ri.
Example:
19
A memory is part of a computer, and so is a monitor.
The subgraph containing all the is-a-part-of edges is a forest. The root of each tree represents a
major component which contains subcomponents represented by vertices in the tree.

Example:
The resource graph in a system containing two computers consists of two trees. The root
of each tree represent a computer. The children of this vertex include one or more CPUs,
main memory, and so on. Each of these subcomponents is represented by a vertex, and
there is an edge from the computer vertex to each subcomponent vertex.
accessibility edges
Edges in resource graphs which represent connectivity between components are called accessibility
edges.
Example:
In previous example, if there is a connection between two CPUs in the two computers, then
each CPU is accessible from the other computer, and there is an accessibility edge from each
computer to the CPU on the other computer
Each accessibility edge may have several parameters whose values help to complete the description
of the interconnection of the resources.
A parameter of an accessibility edge, from a processor Pi to another processor Pk is the cost for
sending a unit of data from a job executing on Pi to a job executing on Pk.

3.6 PRECEDENCE CONSTRAINTS AND DATA DEPENDENCY

Data and control dependencies among jobs may constrain the order in which they can execute.
The jobs are said to have precedence constraints if they are constrained to execute in some order.
If the jobs can execute in any order, they are said to be independent.
Examples:
A radar surveillance system
The signal-processing task is the producer of track records, while the tracker task is the consumer.
In particular, each tracker job processes the track records generated by a signal-processing job.
The designer may choose to synchronize the tasks so that the execution of the kth tracker job does
not begin until the kth signal-processing job completes. The tracker job is precedence constrained.
Consider queries to an information server
Suppose that before each query is processed and the requested information retrieved, its
authorization to access the requested information is first checked. The retrieval job cannot begin
execution until the authentication job completes. The communication job that forwards the
information to the requester cannot begin until the retrieval job completes.
20
3.6.1 Precedence Graph & Task Graph
We use a partial-order relation <, called a precedence relation, over the set of jobs to specify the precedence
constraints among jobs.
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.
A shorthand notation to state this fact is Ji < Jk. Ji is an immediate predecessor of Jk (and Jk is an immediate
successor of Ji) if Ji < Jk and there is no other job Jj such that Ji < Jj < Jk.
Two jobs Ji and Jk are independent when neither Ji < Jk nor Ji < Ji.
A job with predecessors is ready for execution when the time is at or after its release time and all of its
predecessors are completed.
A job with precedence constraint becomes ready for execution at/after its release time and when all the
immediate predecessors have completed their execution.
Precedence Graph
A precedence graph is a directed graph G = (J, <) which represents the precedence constraints among
jobs in a set J. Each vertex in this graph represents a job in J. There is a directed edge from the vertex Ji
to the vertex Jk when the job Ji is an immediate predecessor of the job Jk.
Many types of interactions and communications are not captured by a task graph.
Jobs are shown as circles in this figure. The numbers in the bracket above each job give its feasible interval.

FIGURE: Example of precedence graphs.


The task whose jobs are represented by the vertices in the top row has phase 0, period 2, and relative
deadline 7. The jobs in it are independent; there are no edges to or from these jobs. In other words, the
jobs released in later periods are ready for execution as soon as they are released even though some job
released earlier is not yet complete. This is the usual assumption about periodic tasks.
The vertices in the second row of Figure represent jobs in a periodic task with phase 2, period 3, and
relative deadline 3. The jobs in it are dependent; the first job is the immediate predecessor of the second
job, the second job is the immediate predecessor of the third job, and so on. The precedence graph of (the
jobs in) this task is a chain as shown here. A subgraphs being a chain indicates that for every pair of jobs
Ji and Jk in the subgraph, either Ji < Jk or Ji > Jk. Hence the jobs must be executed in serial order.

21
Task Graph
A task graph is an extended precedence graph.
A task graph may contain different types of edges representing different types of dependencies.
It gives us a general way to describe the application system.
As in a precedence graph, the vertices in a task graph represent jobs.
The numbers in the bracket above each job give its feasible interval. The edges in the graph represent
dependencies among jobs. If all the edges are precedence edges, representing precedence constraints,
then the graph is a precedence graph.

FIGURE: Example of task graphs.

Why Task Graph?


A task graph like the example is only really necessary when the system contains components which have
complex dependencies like the subgraph below the periodic tasks.
Many types of interactions and communication among jobs are not captured by a precedence graph but
can be captured by a task graph.
Unlike a precedence graph, a task graph can contain difference types of edges representing different types
of dependencies.

22
3.6.2 Data Dependency
Data dependency cannot be captured by a precedence graph.
In many real time systems, jobs communicate via shared data.
In a task graph, data dependencies among jobs are represented explicitly by data dependency edges among
jobs.
There is a data-dependency edge from a vertex Ji to vertex Jk in the task graph if the job Jk consumes data
generated by Ji or the job Ji sends messages to Jk. A parameter of an edge from Ji to Jk is the volume of
data from Ji to Jk.
Often, the designer chooses not to synchronize producer and consumer jobs. Instead, each producer places
the data generated by it in a shared address space to be used by the consumer at any time.
In this case, the classical precedence graph will show that the producer and consumer are independent
because they are not explicitly constrained to execute in turn.
An example:
In an avionics system, the navigation job updates the location of the airplane periodically. These data
are placed in a shared space. Whenever the flight management job needs navigation data, it reads the
most current data produced by the navigation job. There is no precedence constraint between the
navigation job and the flight management job.
3.7 OTHER TYPES OF DEPENDENCIES

The other types of dependencies among are as follows:


Temporal dependency
AND/OR precedence constraints
Conditional branches
Pipeline relationship.

3.7.1 Temporal Dependency


Some jobs may be constrained to complete within a certain amount of time relative to one another. We
call the difference in the completion times of two jobs the temporal distance between them.
Jobs are said to have a temporal distance constraint if their temporal distance must be no more than some
finite value.
Jobs with temporal distance constraints may or may not have deadlines.
Example:
Consider the display of video frames and the accompanying audio when the video is that of a person
speaking.
To have lip synchronization, the time between the display of each frame and the generation of
the corresponding audio segment must be no more than 160 ms.
In a task graph, temporal distance constraints among jobs are represented by temporal dependency edges.
23
There is a temporal-dependency edge from a vertex Ji to a vertex Jk if the job Jk must be completed within
a certain time after Ji completes.
The temporal distance between the jobs is given by the temporal distance parameter of the edge. The value
of this parameter is infinite if the jobs have no temporal distance constraint, or equivalently, there is no
temporal-dependency edge between the jobs.
3.7.2 AND/OR Precedence Constraints
AND precedence constraints:
If a job having more than one predecessor needs that all the immediate predecessor must have been
completed before its execution can begin, then such jobs are called AND jobs.
All immediate predecessors must complete before execution.
These dependencies are called AND precedence constraints.
AND jobs are represented by unfilled circles in the task graph.

Figure: AND precedence constraints


These predecessors J4, J5, J6 may execute in any order relative to each other, but they must all be
completed before the job J7 begin.
OR precedence constraints:
If a job having more than one predecessor can begin execution at or after its release time if only one
or some of its predecessor have completed execution, then the job is called an OR job.
This type of dependency constraint is called OR precedence constraint.
OR jobs are represented by unfilled square vertices in the task graph.
A square node is represented by a label (x/y) to indicate that the job can begin execution if x out of y
immediate predecessors complete execution.

24
Note:
3.7.3 In the task Branches
Conditional graph, the in-type of job (i.e., the vertex representing the job) tells us whether all its
immediate predecessors must complete before its execution can begin. By default, the value of this job
If only one of all the immediate successors of a job whose outgoing edges express OR constraints is to
parameter is AND. It can have the value OR, if only one of its immediate predecessors must be completed,
bek-out-of-l,
or executed.if Such
only kaout
jobl of
is its
called a branch
immediate job. In must
predecessor a taskbegraph, therebefore
completed is a join job associated
its execution with each
can begin.
branch
The job.
job parameter out-type tells whether all the jobs immediate successors are to be executed. The
default
These value of the
jobs are out-type parameter
represented of every job is AND, that is, all its immediate successors are to be
by filled circles.
executed.

The subgraph that begins from a vertex representing a branch job and ends at the vertex representing the
associated join job is called a conditional block. Only one conditional branch in each conditional block
is to be executed.
The conditional block in Figure has two conditional branches: Either the upper conditional branch
containing a chain of jobs, or the lower conditional branch containing only one job, is to be executed.
We need lk classical precedence graphs to represent an application system that contains k conditional
blocks if each conditional blocks has l branches.
3.7.4 Pipeline Relationship
Consumer (job) can begin execution when Producer (job) have completed.
A dependency between a pair of producer-consumer jobs that are pipelined can be represented by a
precedence graph.
In this graph, the vertices are the granules of the producer and the consumer. Each granule of the consumer
can begin execution when the previous granule of this job and the corresponding granule of the producer
job have completed.

25
In the task graph, we represent a pipeline relationship between jobs by a pipeline edge, as exemplified by
the dotted edge between the jobs in the right-bottom corner of the graph in Figure.
There is an edge from Ji to Jk if the output of Ji is piped into Jk and the execution of Jk can proceed as long
as there are data for it to process.
3.8 SCHEDULING HIERARCHY

FIGURE: Model of real-time systems.

Figure shows the three elements of model of real-time systems.


The application system is represented by:
A task graph, exemplified by the graph on the top of the diagram.
This graph gives the processor time and resource requirements of jobs, the timing constraints of
each job, and the dependencies of jobs.
The resource graph describes:
The amounts of the resources available to execute the application system.
The attributes of the resources (active or passive, no. of available units )
The rules governing their usage.
Between them are the scheduling and resource access-control algorithms used by the operating
system.

26
3.8.1 Scheduler and Schedules
Jobs are scheduled and allocated resources according to a chosen set of scheduling algorithms and resource
access-control protocols.
Scheduler
It is module that implements scheduling algorithms.
Schedules Jobs.
Allocates Resources to jobs.
Example:
Processors assignment on jobs (or vice versa).
That is, scheduler assigns processors to jobs, or equivalently, assigns jobs to processors.
Schedule
An assignment of all the jobs in the system on the available processors.
Valid schedule
A valid schedule is the 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.
Total amount of processor time assigned to a job is equal to its execution time.
Precedence and resource usage constraints are satisfied.
Feasibility
A valid schedule is a feasible schedule if every job completes by its deadline (or, in general, meets its
timing constraints).
We say that a set of jobs is schedulable according to a scheduling algorithm if when using the algorithm
the scheduler always produces a feasible schedule.
Optimality
A hard real-time scheduling algorithm is optimal if (using) the algorithm (the scheduler) always
produces a feasible schedule if the given set of jobs has feasible schedules.
If an optimal algorithm cannot find a feasible schedule, we can conclude that a given set of jobs cannot
feasibly be scheduled by any algorithm.
Performance Measures
The following are the performance measure of real time system.
Miss rate: percentage of jobs executed but completed late.
Loss rate: percentage of jobs discarded.
Invalid rate: sum of miss and loss rate.
Makespan: If all jobs have same release time and deadline then the completion time of last job is
called the makespan of the schedule.
27
In the case where all the jobs have the same release time and deadline, the problem of
scheduling the jobs to meet their deadline is in essence the same as that of scheduling to
minimize the completion time of the job which completes last among all jobs. The response
time of this job is the response time of the set of jobs as a whole and is often called the makespan
of the schedule.
Lateness: difference between completion time and deadline, can be negative if early.
Or another words
Lateness (L): L = Completion time - deadline (L > 0 if deadline is not met).
Tardiness: Zero if completion time <= deadline, otherwise equals (completion time - deadline).
Tardiness (E): E = max{L, 0} (E = 0 if deadline is met)
Max or average response times.
Max or average tardiness/lateness.

28

You might also like