Computational Delay in Vehicles and Its Effect on Real Time

COMPUTATIONAL DELAY IN VEHICLES
AND ITS EFFECT ON
REAL TIME SCHEDULING
A Thesis Presented
by
ABHINNA JAIN
Submitted to the Graduate School of the
University of Massachusetts Amherst in partial fulfillment
of the requirements for the degree of
MASTER OF SCIENCE IN ELECTRICAL AND COMPUTER ENGINEERING
May 2012
Electrical and Computer Engineering
c Copyright by Abhinna Jain 2012
All Rights Reserved
COMPUTATIONAL DELAY IN VEHICLES
AND ITS EFFECT ON
REAL TIME SCHEDULING
A Thesis Presented
by
ABHINNA JAIN
Approved as to style and content by:
C. Mani Krishna, Co-chair
Israel Koren, Co-chair
Michael Zink, Member
C.V. Hollot, Department Chair
Electrical and Computer Engineering
ACKNOWLEDGMENTS
It has been a great pleasure and privilege for me to work with my advisors Prof. C. Mani
Krishna and Prof. Israel Koren. I thank them for their continuous support and guidance
during the course of this research. Thanks are also due to Prof. Michael Zink for his helpful
suggestions and for kindly agreeing to be member of my thesis committee.
iv
ABSTRACT
COMPUTATIONAL DELAY IN VEHICLES
AND ITS EFFECT ON
REAL TIME SCHEDULING
MAY 2012
ABHINNA JAIN
B.E., SATHYABAMA UNIVERSITY, INDIA
M.S.E.C.E., UNIVERSITY OF MASSACHUSETTS AMHERST
Directed by: Professor C. Mani Krishna and Professor Israel Koren
Present research into critical embedded control systems tends to focus on the computational elements and largely ignore the link between the computational and physical elements.
This link is very important since the computational capability of the computer can greatly
affect the performance and dynamics of the system it controls.
The control computer is in the feedback loop of control systems and contributes to feedback
delay in addition to already existing mechanical delays. While mechanical delays are compensated in control design [3], variable computational delays cause system to underperform
in its intended physical behavior and impose a cost in terms of fuel or time. For this reason,
the scheduler in a real-time operating systems should not focus only on the task deadlines,
but also on efficient scheduling which minimizes the effect of computational delay on the
controlled plant.
v
The proposed work provides a systematic framework to manage and evaluate the implications of computational delay in vehicles. The work also includes cost sensitive real-time control task scheduling heuristics and Dynamic Voltage Scaling (DVS) for better energy/thermal
control. We show through simulations that our heuristic achieves a significant improvement
in cost over the traditional real-time scheduling algorithm Earliest Deadline First (EDF) and
show that it can adjust according to energy constraints imposed on the system.
vi
TABLE OF CONTENTS
Page
ACKNOWLEDGMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
ABSTRACT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. v
LIST OF TABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
LIST OF FIGURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. x
CHAPTER
1. INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1
1.2
Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Modern Control Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.1
1.3
Delays in Critical Feedback Control Systems and Their Effect . . . . . . . . . . 3
Real-time Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2. AIM AND SCOPE OF THIS THESIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3. LITERATURE REVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1
3.2
Impact of Computational Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Dynamic Voltage Scaling (DVS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4. CASE STUDY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.1
4.2
4.3
4.4
System: Vehicle Tracking A Circular Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Vehicle motion on the straight line and zig-zag path . . . . . . . . . . . . . . . . . . . . . . . . 20
System with First Order Hold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Effect of Computational Imprecision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
vii
4.5
4.6
Multivariate Cost Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5. TASK MODEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
6. SCHEDULING HEURISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.1
6.2
6.3
6.4
Offline Heuristic - Targeting Worst Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Offline Heuristic - Targeting percentage of the Worst Case . . . . . . . . . . . . . . . . . . 41
Online Heuristic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Numerical Results and Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.4.1
Cost Function From the Case Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.4.1.1
6.4.1.2
6.4.1.3
6.4.1.4
6.4.2
Example Trajectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
EDF vs GH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
GH vs SA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Effect of Targeting Percentage of the WCET . . . . . . . . . . . . . . . . 50
Polynomial cost function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7. DYNAMIC VOLTAGE SCALING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.1
7.2
7.3
Offline Heuristic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Online Heuristic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Main Results and Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.3.1
Cost Function From the Case Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
7.3.1.1
7.3.1.2
Final cost ratio vs. Energy Budget . . . . . . . . . . . . . . . . . . . . . . . . 58
Actual Consumed Energy Ratio vs. Energy Budget . . . . . . . . . . 60
8. CONCLUSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
BIBLIOGRAPHY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
viii
LIST OF TABLES
Table
Page
4.1
Vehicle Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.2
Cost Functions Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.1
Some notations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
6.1
Vehicle cost function - Greedy vs EDF cases description . . . . . . . . . . . . . . . . . . . . 48
ix
LIST OF FIGURES
Figure
Page
4.1
(a) A 4WS4WD vehicle body (b) Four wheels (c) path-tracking kinematics
(from [1]) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2
Zero order hold period . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.3
Trajectories at different delays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.4
Trajectories at different velocities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.5
Cost functions at different values of radii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.6
Vehicle motion on zig-zag path at reduced straight line stretch . . . . . . . . . . . . . . . 21
4.7
Vehicle motion on zig-zag path @ radius of turns=3m, ZOH=200ms,
Delay=10ms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.8
Cost function curve at radius at turns 3m and ZOH=200ms . . . . . . . . . . . . . . . . . 23
4.9
Vehicle motion on zig-zag path at different velocities . . . . . . . . . . . . . . . . . . . . . . . 23
4.10 Cost function curve at two different velocities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.11 First Order Hold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.12 First Order Hold closed to continuous curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.13 Comparison of ZOH and FOH: Steering control input at radius 15m . . . . . . . . . . 26
4.14 Comparison of Zero and First Order Hold: trajectories at radius 15m . . . . . . . . . 27
4.15 Comparison of ZOH and FOH: Steering control input at radius 20m . . . . . . . . . 27
4.16 Comparison of Zero and First Order Hold: Trajectories at radius 20m . . . . . . . . 28
x
4.17 Steering control input with computational error . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.18 Cost functions with computational error for ZOH . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.19 Bivariate cost function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.1
Greedy Heuristic pseudo code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
6.2
GH example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
6.3
Heuristic targeting percentage of WCET - pseudo code . . . . . . . . . . . . . . . . . . . . . 42
6.4
Online heuristic without DVS - pseudo code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6.6
Comparison of two offline approaches - example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.7
Example - Trajectories for GH and EDF schedule . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.8
Vehicle cost function - Greedy vs EDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.9
Vehicle cost function - Final Cost Ratio:Percentage of WCET vs WCET
(Targeting values from a distribution) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
6.10 Vehicle cost function - Final Cost Ratio:Percentage of WCET vs WCET
(Targeting fixed percentage of WCET) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
6.11 Polynomial cost functions - Greedy vs EDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.1
DVS offline - pseudo code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.2
DVS online - pseudo code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
7.3
DVS heuristics - example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
7.4
Vehicle cost function - Cost and Energy trade-off . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.5
Vehicle cost function - Actual consumed energy ratio vs. Energy Budget . . . . . . 60
xi
CHAPTER 1
INTRODUCTION
1.1
Motivation
Today, microprocessors and microcontrollers are embedded in almost every electronic
appliance we can think of and many that we probably would not. They have become pervasive not only in our home, but in our workplace, our automobiles, airplanes, stoplights,
supermarkets, cell phones, in short in almost every aspect of our lives. Though used in many
applications, embedded systems are still rudimentary as compared to what we envision in
future applications such as advanced automotive systems, distributed robotics (telepresence,
telemedicine), etc.
Real-time control systems of the future demand a focus on the interaction between the
computational elements with the controlled plant. This link is very important, since the
computational capability of the controller and how this capability is used can greatly affect
the physical performance parameters of the controlled plant. Systems which focus on such
links are termed Cyber-Physical Systems (CPS). CPS is the integration of computation with
physical processes. Embedded computers monitor and control the physical process with
feedback loops, where physical processes affect computations and vice versa.
CPS has been an active area of research over the past few years. The research presented
here deals with how to efficiently abstract the needs of the physical plant in terms meaningful
to the computer designer. In addition, we use such an abstraction to design and analyze
real-time scheduling policies in case of cyber physical systems. We start by introducing the
key terms and concepts used in this research.
1
1.2
Modern Control Systems
The ever increasing technological demands of society impose needs for new, more accurate, less expensive and more efficient control solutions to existing and novel problems.
Typical examples are the control demands associated with passenger aircraft, underwater
vehicles, automobiles, space vehicles, chemical processes, robotics and communication networks. A large fraction of engineering designs involve automatic control features. Frequently,
control of complex and expensive applications use a computer-based control design. For example, computer control has been a key enabler in the aerospace and automotive domains.
Design problems have grown from so-called inner loops in a control hierarchy (e.g. regulating
a specified flight parameter) to various outer loop functions which provide logical regulation
of operating modes, vehicle configurations, payload configurations, and system health status.
For aircraft, these functions are collectively called vehicle management. They have historically been performed by pilots or other human operators, but today that boundary is moving
and computers in control systems are increasingly taking on these functions.
Modern control systems are likely to include large collections of distributed entities with
local computation, global communication connections and opportunities to impose centralized control actions. Examples of this trend include the national airspace management problem, automated highway and traffic management, and command and control in the future
battlefield [13], [14].
The rapid growth of communication networks has provided major opportunities and challenges for control, so that even in smaller and more localized system, more and more control
systems will operate over networks. Stability is complicated by the presence of varying time
lags induced due to communication between sensors, controllers and actuators. Uncertainty
and variation in the network may occur through unpredictable changes in network topology,
transmission channels, and traffic demand.
2
A highly dynamic and non-deterministic environment requires autonomous and modern
control systems to behave adaptively and intelligently [9], [10]. For example, there is an
increasing emergence of semi-autonomous systems where increased processing capabilities are
required for compute intensive applications such as collision avoidance, situational awareness,
higher level reasoning and decision making.
1.2.1
Delays in Critical Feedback Control Systems and Their Effect
Feedback delays include both computational and mechanical delay. Controllers /computers are present in the feedback loop of the controlled plant. In practice, sensing plant
state, computing control inputs and delivering them back to the actuators of the physical
system takes non-zero time which contributes to delay in the feedback loop. Mechanical
delay is due to mechanical parts of system such as actuators. Modern control systems for
applications such as vehicles are often a complicated network of feedback controllers and are
multi-objective in nature, e.g., avoid collision with the preceding vehicle, maintain speed on
highways, provide acceptable fuel economy, etc. Computational overhead is considerable in
such cases and contributes to feedback delays.
Delays in embedded feedback control system are inevitable. The control system designer
can incorporate them into the system model; both in sampled-data systems and in continuous
systems [RR08]. However, if a controller is designed within the context of significant feedback delays, it will likely result in a disappointingly slow system response and may degrade
performance considerably. For applications such as automobiles, flight control, tele-presence
etc., excessive delay in closed loops can lead to instability [13].
Thus, computational delay affects plant performance. The extent to which this poses
practical problems depends on the application. In relatively soft applications, such as controlling room temperature, feedback delay is not a significant concern. However, there are
3
many hard control problems, such as the control of an automobile or an aerospace vehicle,
where feedback delay is of great practical concern.
In general, delays in closed-loop feedback systems resemble the effects of lowering sampling frequency [20]. In both cases, the controller is forced to make use of old information
(information about the output at some time in the past, rather than in the present) in
determining the output it supplies to the physical plant.
1.3
Real-time Scheduling
Real-time scheduling is a widely explored topic. Many uniprocessor and multi-processor
scheduling algorithms have been developed, such as Earliest Deadline First (EDF), Rate
Monotonic (RM), Global Rate Monotonic Scheduling etc. Traditionally real-time systems are
defined as systems where the correctness of an outcome does not only depend on the logical
correctness of the implementation but also on when that solution is delivered. Scheduling
policies are developed with an objective to assign resources (CPU, memory etc.) to tasks in
such way that they do not miss their deadlines. If deadlines are associated with task graphs
rather than individual tasks, virtual deadlines are usually associated with the individual
tasks in order to allow traditional deadline-based scheduling protocols to be used.
The implicit assumption in deadline-centric scheduling is that as long as the deadlines
are met, the quality of control provided is adequate (Sometimes when the jitter caused by
an abnormally early execution is unacceptable, the system can artificially delay the output
by buffering). This is a pass/fail approach; a task passes if it meets its deadline and fails
otherwise. The (considerable) advantage of such an approach is its relative simplicity. The
disadvantage is that it fails to take into account the finer-grained dependence of the quality
of control on the actual controller delays. CPS cares for this dependency and therefore,
it adds an additional challenge to develop scheduling policies. Scheduling in CPS should
4
therefore be not just a matter of meeting all hard deadlines; we also need to minimize the
effect of computational delay on the controlled plant.
The rest of the document is organized as follows. Chapter 2 outlines the scope of this
research. A detailed literature review is presented in Chapter 3 which focuses on the state of
the art of the topic area. Chapter 4 describes the autonomous vehicle system used as a case
study. A task model is introduced in Chapter 5. Cost function based scheduling heuristics
without frequency scaling and with offline and online phases are presented in Chapter 6.
Important results are also discussed. In Chapter 7, DVS schemes are described with results.
Chapter 8 concludes this thesis.
5
CHAPTER 2
AIM AND SCOPE OF THIS THESIS
In the previous chapter, sources of delay in the feedback loop and their effect on system
performance were discussed. Our research will provide a systematic framework for quantifying the effect of feedback delay on the controlled plant. In particular, we focus on the
computational delay in the feedback loop; mechanical delay is considered as fixed throughout
the study, and is outside the scope of this work. We address the problem of task scheduling
within the context of a model of the impact of feedback delay on the controlled plant.
Our central case study is that of automotive vehicle system. The control computer computes control inputs required to have the vehicle follow a given trajectory. The quality of
control depends in part on the computational delay. To quantify performance of the control
system as a function of the task response time, cost functions are derived. These describe
the relationship between the effect of the computational delay on the physical plant performance or cost, expressed in terms meaningful to the application. For example, cost might be
expressed in terms of fuel or energy consumption or how precisely a vehicle is able to follow
a given trajectory. We follow the approach in [7], where the cost function of a controlled
process is obtained by the difference in expected performability [23] of the system at zero
response time and performability at some given response time. Performability is a measure
which expresses the probability with which the application achieves each of a specified, user
visible set of accomplishment levels. Cost functions are therefore a mechanism for reflecting
application priorities in a CPS: CPS demands a close scrutiny to the relationship between
computational and physical elements and the cost function captures that relationship. Cost
6
functions incorporate the notion of deadlines as the maximum value of delay for a particular
input parameters set at which system breaks down (does not comply with constraints imposed on it for the desired performance); they also capture the incremental degradation in
the quality of control that results from computational delays less than the specified relative
deadline.
Since the dynamics of the controlled plant and the nature of the operating environment
are both known to some extent, we can derive cost functions offline and schedules associated
with them. In particular, we can identify multiple cases that the controller will have to deal
with (e.g., in case of a vehicle: making a sharp turn, braking, traveling in a straight line, and
dealing with slippery roads or high winds). For each of these, one can derive a cost function
in advance. Based on each of the cases, we can obtain appropriate task schedules to be
followed. These schedules are developed offline and stored for use during operation. These
offline cases will obviously not match the actual situation exactly. Some online adjustments
are required to deal with the particularities of the actual situation, especially the fact that
task execution times are often highly variable.
The focus of this thesis is on obtaining cost functions for a cyber-physical system and
using them for control task scheduling. In particular, we do the following.
1. Using an automotive application as a case study, we show how to quantify the impact
of computer response time on the performance of the vehicle. We demonstrate that cost
functions are often multivariate, reflecting that inherent coupling exists among control tasks.
We also use this example to illustrate the fact that cost functions depend on the state of the
controlled plant.
2. Given the cost functions of individual tasks, we obtain practical heuristics to schedule
tasks in a cost sensitive way. Such heuristics have an offline and an online component.
The offline component uses static information to generate an initial task schedule that acts
as a foundation for the online component. The online components adjusts the schedule in
7
response to runtime events, responding to the following:
(a) Completion of task execution ahead of their worst-case estimated time.
(b) Changes in energy availability, leading to a change in the appropriate supply voltage and
a consequent change in the processor speed.
(c) Change in the controlled plant state, leading to a change in the control task cost functions.
The next chapter, presents a brief survey on research and studies done in area of finding
cost functions (for control applications) and on cost-function-based-scheduling.
8
CHAPTER 3
LITERATURE REVIEW
Modern automobiles rely more than ever on computers for their control. Cars have advanced from manually tuned mechanical/hydraulic technology to computer controlled operation of all major functions including fuel injection, emission control, cruise control, braking
and cabin comfort. The reasons for this change are the ever decreasing cost of modern
computers, the need for sophisticated engine controls to meet emission and fuel-economy
standards, the need for advanced engine diagnostics and repair, more advanced safety features such as collision avoidance, collision response and the demand for new comfort and
convenience features including new entertainment and communication features [13].
The engine and other parts under the hood power the car, but it is the computer/controller
in the control unit that tells it what to do. Examples of the computational modules include
the airbag control module, the engine control module which controls engine functions like
spark timing, obtaining the correct fuel and air mixture to inject into the engine block, the
climate control module, the cruise control module, the transmission control module which
controls the automatic transmission, and the ABS module which controls the anti-lock brakes
and may handle the traction-control and stability-control systems.
Technology advancement brings its own challenges in its wake. As emphasized earlier, the
computer in a control system is part of the feedback loop of the control unit and contributes to
a delay in the loop. For example, Lee in [16] uses the Motorola MC68000 microprocessor for
resolved motion adaptive control for a mechanical manipulator, which executes the adaptive
control scheme in about 17.8 milliseconds.
9
3.1
Impact of Computational Delay
Over the last few years, the impact of computational delay on control has attracted
the attention of several researchers. Rajamani explores its effect on autonomous control
in [3]. In his analysis of the string stability of autonomous vehicles, he explains that the
desired acceleration cannot be obtained instantaneously and this is partly due to the time
lag caused by the lower level controller in the feedback loop. This time lag is incorporated
as a time constant in his work. Thus this delay becomes a control equation parameter and is
constrained under certain conditions to achieve string stability. In [15], Shin and Cui studied
the effect of computational time delay on a robot control system. A quantitative analysis is
presented and the maximum tolerable limit of computational delay corresponding to system
stability is derived. They also classify non-zero computing time as a delay (sampling interval
greater than delay) or loss (delay greater than sampling interval). Based on stochastic control
theory, Nilsson et al. [19] analyzed the stability of a closed loop communication network in
the presence of random delays. They proposed an Linear Quadratic Gaussian (LQG) optimal
controller for the computational delay setup. Loss/error in control input is assumed as the
cost to the system as a result of response time of the controller, and the optimal controller
is compared with sub-optimal controllers using Monte-Carlo simulation. Yang studies a
linear robot control system and observes that an adaptive controller designed under the
assumption of no computational delay is worse than one designed taking a fixed delay into
account [18]. Of course, this does not capture the randomness of computational delay which
only emerges at runtime. Anderson and Reed investigate the effects of computational delay
in the control law of a robotic manipulator operating under model-based/PD control [20].
They demonstrate the destabilizing effects of computational delay in linear control systems.
Wang and Longoria study the effect of computational delay on the performance of a hybrid
adaptive cruise control system [22]. They found that computational delay affects hybrid
control system in terms of peak error, root mean square error (RMSE), and control effort
10
(control energy). An all-pass narrow-band (ramp) predictor is proposed in [21] to be used as
a predictive compensator to compensate for computational delay in real-time control system
and it is observed to perform well. The impact of computational delay has also been studied
in other applications. For example, Zhang,et al. discuss delay issues in Unmanned Aerial
Vehicles (UAVs) and their impact on UAVs which can lead to system instability [4]. They
also illustrate a method to compensate for this delay by introducing a reference model based
state predictive algorithm.
Our literature survey on computational delay in control applications suggests that research in this area has largely focused on analyzing system performance in the presence of
computational delay and on compensation techniques which may improve system performance. However most of the research so far has been done from the perspective of control
systems engineering. By contrast, in real-time systems, the engineering focus is on managing
computational resources in a cyber physical system in a cost sensitive way.
As mentioned earlier, the cost function is our proposed means to couple the control and
cyber sides of a cyber physical application. Shin et al. have a formulation for such cost
functions [8]. The cost function is a function of system state and is defined as the expected
change in an application centric performance index such as consumed energy, fuel, time,
or some other physical parameters associated with the controlled plant as it shifts from
its initial to its final state due to a non-zero controller response time. If controller takes
longer than certain duration (hard deadline), dynamic failures can occur and the cost to the
system will be theoretically infinity, otherwise (response time lesser than hard deadline) cost
function is continuous, monotonically non-decreasing and bounded. The following equation
is the mathematical representation of cost function.
C(ξα ) =


 g(ξα ) if 0 < ξα ≤ Γα

 ∞
if ξα > Γα
11
where C(.) is the cost function for task α with response time ξα and deadline Γα and g(.) is
the continuous function.
An example is provided in [8] for obtaining a cost function for elevator control in the case
of an aircraft in the final stages of descent, just prior to landing. An instantaneous error
measure is chosen as the performance index and a mathematical expression is derived for it.
To get the cost function, the controller response time is varied within an allowed threshold
value for the elevator deflection control task (the only task considered) so as to follow the
desired state trajectory for landing.
Once the impact of computational delay on the performance of the controlled plant is
quantified using cost functions, the next question that arises is how to use it in task scheduling. In contemporary real-time systems, cost is never associated with tasks and the focus
is entirely on meeting deadlines. Applying existing real time scheduling concepts to CPSs,
where both deadline and cost function are crucial, could lead to poor plant performance.
Lee put forth similar arguments about existing real time operating systems concepts [5].
Punnekkat et al. point out that autonomous vehicle control exhibits variable and adaptive
behavior and will require a different type of scheduling scheme to traditional schemes like
priority scheduling or best effort scheduling [10]. Real-time scheduling with cost functions
is a cost optimization problem under deadline constraints. This problem is quite familiar
in Industrial Engineering where the objective is to schedule jobs in a production plant with
release dates and due dates (deadlines) and to optimize a parameter such as production cost
or flow time of jobs (flow time refers to completion time minus release time), completion
time or total tardiness of jobs. These parameters are modeled as weights associated with
jobs that may be linear, non-decreasing or any arbitrary value. Phillips, et al. presents a few
general scheduling algorithms that use the LP (Linear Programming) relaxation technique
to optimize job weights[17]. However these scheduling algorithms, unlike most real-time
time scheduling algorithms, are non-preemptive in nature. Moreover apart from optimizing
12
parameters, the focus is on maximizing the fraction of jobs scheduled by the deadline. By
contrast, in hard-real time systems all the critical tasks need to finish their execution before
their deadline.
In the real time literature not much work has been found on scheduling techniques in
presence of cost functions. Prasad and Burns suggest a value based scheduling scheme to
schedule tasks in an autonomous vehicle system [11]. They report that autonomous vehicle
systems will require more flexibility in scheduling during run time to accommodate changing
environmental factors like weather and road conditions, obstruction due to other vehicles,
computer load(normal or overload condition) etc. So they associate a value with each job.
Scheduling is during run time. To avoid run time overhead, the value is calculated offline
assuming some predefined modes such as day-time, dry and faulty-free mode, night-time, wet
and faulty mode. Analytic Hierarchy Process (AHP) from measurement theory and system
analysis is performed to get the value for a job. For example for a set of jobs, pair-wise
comparisons are performed and utility ratios are generated. Then jobs are compared for the
extent of their relative utility and the one with the highest utility is given preference and
scheduled. In this scheme, values of different types of tasks are calculated offline which is not
useful in case of cost functions, as cost functions involve response times which are generated
during run time. In [12], Hegde describes a scheduling heuristic when each task has a cost
function. This heuristic chooses a task set at each decision point whose formation is based
on a ranking of the cost function slopes. Tasks with higher slopes are more expensive if
delayed than tasks with lesser slopes. Such an approach fails to account for the fact that
the slope of a monotonically increasing cost function can be non-linear and keep changing
at every point.
13
3.2
Dynamic Voltage Scaling (DVS)
DVS in real-time scheduling is not new. Many real-time DVS algorithms are found
in the literature e.g., [24, 25, 26]. Traditionally DVS focus on minimizing the processor
energy consumption (E). Lowering the supply voltage (V) reduces the energy consumption
quadratically (E ∝ V 2 ). In presence of any slack time, DVS algorithms runs the tasks at
lower operating voltage and frequency and thus try to reduce energy consumption. In the
CMOS circuit, the delay td is given by td ∝ V /(V − Vt )ß , where Vt is the threshold voltage
and ß is a velocity saturation index [27], therefore as the supply voltage reduces, response
time (delay) of a task increases due to lower cycle frequency which ultimately increases the
cost. This attribute is not desirable in CPS. Our objective is to lower the response time of
tasks and therefore, lower the total cost under an given energy constraint. Also since cost
sensitivity is not associated with scheduling algorithms, relationship between energy and
cost has not been explored.
Absence of analysis of computational delay in critical real-time control systems for obtaining cost functions and lack of incorporation of these cost functions in real-time task
scheduling and DVS are the shortcomings found during our literature survey. This thesis
addresses these shortcomings.
14
CHAPTER 4
CASE STUDY
This chapter introduces an autonomous vehicle system for the study of the effect of
computational delay on the performance of a controlled plant. This chapter also describes
approaches useful for this study and how system performance is evaluated and results obtained.
4.1
System: Vehicle Tracking A Circular Path
An autonomous four-wheeled steering and four-wheeled drive (4WS4WD) vehicle is considered here. It is a system with more than one physical unit to control i.e., all the four
wheels of the vehicle can be controlled independently. The objective of the vehicle is to track
a given reference path within a pre-specified threshold of wheel slip. We base our study on
Peng’s control-theoretic model [1]. It models the kinematics (study of the vehicle body and
wheel dynamics, taking into account the wheel friction) of a 4WS4WD vehicle in some detail, see Figure 4.1. A bounded controller with integral compensation is introduced. Our
objective is to develop cost functions associated with having the vehicle track a reference
path. We use the same vehicle characteristics as in [1]: see Table 4.1 for the key data (others
can be found in [1]).
15
Mass
Inertial moment about vertical
Distance from CG to front
Distance from CG to rear
Effective width
Height of CG
1480 kg
1950 kg · m2
1.421 m
1.029 m
1.502 m
0.42 m
Table 4.1. Vehicle Parameters
There are five state variables of this system [1].
1. Vehicle Velocity (v)
2. Yaw rate (γ)
3. Perpendicular distance between vehicle body and reference path (Yc )
4. Sideslip Angle (β)
5. Angle between velocity and tangent to path curve (φ)
Figure 4.1 illustrates these variables. The controller receives these variable values and
computes control inputs. The control inputs to the vehicle are:
1. Torque on each wheel
2. Steering angle for each wheel
So there are 8 control inputs in all for four wheels. The following assumptions are made
for this system:
1. The vehicle runs at a constant speed.
2. There are no external disturbances (e.g., wind disturbance or need to avoid other traffic).
These assumptions are made to obtain a first order model and can be relaxed. Based on
these assumptions, the state space equations governing the system dynamics take the form
x’(t) = A*x(t) + B*u(t-τ )
where τ is the feedback delay (Computational + Mechanical) .
16
Figure 4.1. (a) A 4WS4WD vehicle body (b) Four wheels (c) path-tracking kinematics
(from [1])
The sensor sampling period, which is also called the holding period, highlights the fact
that in practice the controller does not sense state variables continuously and can not update
the control input continuously. In the case of Zero Order Hold (ZOH), control inputs are
held constant i.e., the same inputs are supplied to the system for the duration of holding
time. Figure 4.2 explains ZOH. Control input values computed at time (n − 1)T are based
on state variables at that time and then calculated control inputs are held constant for next
T time units, then at time nT , control inputs are computed again based on state variables
at time nT and the process continues.
In a system with feedback delay τ and ZOH T , except for first τ time unit when the
control process starts, at any instant of time t, system gets input/information which is up to
τ time units old and gets no new information for the next T time units. This is one of the
reasons why the vehicle may deviate from the specified trajectory. The introduction of delay
into the system affects system performance, as shown in Figure 4.3. The initial parameter
17
Figure 4.2. Zero order hold period
values for solving differential equations are taken from [1]. Some of these values are γ = 0
rad/s, β = 0 rad, φ = 0 rad, angular velocity = 96.774 rad/s, Yc = 2 m. In Figure 4.3, the
radius of the circular reference path is 10 m. The vehicle is supposed to track the reference
path as closely as possible. The curves show vehicle motion at a given delay and ZOH of
200ms. The vehicle motion at 170 ms delay deviates from the desired trajectory more than
the motion at zero delay or at 100ms. After the delay of 170ms, deviation from the reference
curve is very high. This is the effect of incorporating non-zero delay and holding period. We
express the deviation (cost) in terms of the area between the reference path and the actual
trajectory of vehicle at a delay and a holding period. For the experiments, vehicle speed is
kept at the limiting value above which vehicle will completely skid off the track (calculated
from equation 21 in [1]). Figure 4.4 compares the effect of changing velocity on the vehicle
motion at ZOH of 200 ms and delay of 170 ms. We observe that at 6 m/sec (∼ 13.4 mph),
for the same delay value, the vehicle has less deviation from the reference curve than at 8.2
m/sec (∼ 18.3 mph).
The reference track that the system is following affects the relative importance of different
jobs, and the cost of feedback delay. Figure 4.5 is the cost function curve which shows change
18
Figure 4.3. Trajectories at different delays
Figure 4.4. Trajectories at different velocities
19
Figure 4.5. Cost functions at different values of radii
of cost with respect to the delay at holding period 300 msec for radii 10m, 15m and 20m. As
the feedback delay increases, the cost increases: this increase is more pronounced for the 10m
radius trajectory. Also note that the cost is strongly dependent on the desired trajectory:
the urgency of a task is therefore a function of the objective set for the controlled plant. The
point where the curve shoots up or takes a steep slope is the point where the system can be
regarded as having failed. The cost suddenly increases at that point and it may be possible
that the vehicle essentially has gone out of control. The value of delay at this point can be
used to obtain the hard deadlines of the various control tasks.
The cost function shown in Figure 4.5 assumes a single argument: all the tasks in the
system are assumed to have equal delay. Non-identical delay values for different tasks results
in multivariate cost functions as discussed in Section 4.5.
4.2
Vehicle motion on the straight line and zig-zag path
In our discussions so far, the vehicle has been assumed to be traveling on a circular path
where the steering angle and torques are changing continuously. Consider a situation where
20
Figure 4.6. Vehicle motion on zig-zag path at reduced straight line stretch
the vehicle is traveling on a nearly straight line for a long time and then suddenly takes a
turn. The control effort now changes from non-urgent to urgent since while the vehicle is on a
straight line, steering and torque will remain mostly constant; the situation change abruptly
when the turn is taken. Figure 4.6 illustrates the vehicle motion under this scenario.
Figure 4.6 shows a desired trajectory where vehicle first travels 20 m on the sloped
straight line, and then wishes to take a sharp 3m turn. The zero order holding period is 100
msec and two different delay values are considered. When the vehicle takes a sharp turn
after a 20 m long straight line stretch, it goes off the track for a while before returning to the
straight line track. If the straight line stretch after turn is short and there is another turn
then there is a possibility that vehicle never returns to the desired trajectory. Figure 4.6
indicates that the delay should be kept below about 60ms. The vehicle velocity here is 5
m/sec. Figure 4.10 shows the cost function curve for this case.
21
Figure 4.7. Vehicle motion on zig-zag path @ radius of turns=3m, ZOH=200ms, Delay=10ms
Figure 4.7 shows what happens when the holding period is increased to 200 ms. The
straight line stretch here is 100 m long. A longer straight line trajectory, after sharp turns,
allows the vehicle to better track the desired trajectory. The cost function curve in Figure 4.8
shows that limiting value of delay is 10ms for this case.
Figure 4.9 shows vehicle motion at fixed 100 ms ZOH, 60 ms delay, 3m radius at turns
and at two different velocities 5m/sec and 3m/sec. As might be expected, a vehicle cruising
at slower velocities does not deviate much from the desired trajectory. A cost function curve
is plotted in figure 4.10 for 20 m straight line, 3m radius at turns and 100 ms ZOH to
obtain limiting value of delay for two velocities 4m/sec and 5m/sec. A greater deviation
from desired trajectory at velocity of 5m/sec results in higher cost in presence of delay.
The discussion in Section 4.2 illustrates that the cost and task deadlines are functions of
system state. When the vehicle is traveling on the straight line trajectory, control delay has
very little impact on its behavior since control needs are almost unchanged. As a result, tasks
22
Figure 4.8. Cost function curve at radius at turns 3m and ZOH=200ms
Figure 4.9. Vehicle motion on zig-zag path at different velocities
23
Figure 4.10. Cost function curve at two different velocities
can have higher deadlines but when the vehicle takes a sharp turn, due to abrupt change in
control needs, old information leads to degradation of performance and higher cost and thus
the relevant control tasks increase in urgency. Changing trajectory parameters like straight
line stretch length, radius at turns will also affect the cost and task deadline. Another system
state parameter which governs cost function and task deadline is the velocity of the vehicle
and road conditions.
4.3
System with First Order Hold
So far we have considered ZOH. ZOH has significant impact on the system performance.
In ZOH, after every holding period, system states are sampled and control inputs calculated,
which are then hold over the holding period duration. Another option is to extrapolate the
control input values from the two previous calculated control input values and supply that
value of control input to the actuator. Figure 4.11 illustrates First Order Hold (FOH).
Control inputs are extrapolated for next T time units based on values at nT and (n − 1)T .
24
Figure 4.11. First Order Hold
Now consider Figure 4.12. If the first order hold leads the curve closer to the continuous ideal case (without delay) then we can see substantial improvement in the system
performance. This provides adequate motivation to test this case for the system under
consideration. Figure 4.13 shows some results.
In Figure 4.13, the behavior of the steering control input in the case of continuous, ZOH
and FOH are compared at 15m radius of the reference path, period of 300 ms and at 200 ms
delay. The continuous case assumes zero delay. Figure 4.13 compares steering control input
Figure 4.12. First Order Hold closed to continuous curve
25
Figure 4.13. Comparison of ZOH and FOH: Steering control input at radius 15m
for different type of control. The Figure 4.14 shows that FOH performs better than ZOH
i.e., less cost associated with FOH trajectory than ZOH trajectory.
The FOH case is also tested with different values of reference path radius. Figure 4.15
shows one such case, at radius 20m, period 300 ms and at delay of 200 ms. Steering control
input in FOH shows big swings as compared to ZOH. Figure 4.16 follows this result and
vehicle start jerky motion. As the radii of reference path increases, big swings are observed
in control inputs. One significant point to notice here is that the vehicle is operating at its
limiting velocity in all cases.
From above discussions it is clear that if the vehicle is operating at limiting velocity in
order to avoid skidding, use of FOH at higher radius of reference curve will lead to undesirable
performance i.e., the system may have a high cost.
26
Figure 4.14. Comparison of Zero and First Order Hold: trajectories at radius 15m
Figure 4.15. Comparison of ZOH and FOH: Steering control input at radius 20m
27
Figure 4.16. Comparison of Zero and First Order Hold: Trajectories at radius 20m
4.4
Effect of Computational Imprecision
To study the impact of computational imprecision on the plant performance through
simulation, we introduce an error model, where error is uniformly distributed over a fixed
percentage of the control input. While solving control equations, once a control input is
computed, we randomly select an error value from this distribution, randomly assign a sign
(positive or negative) to it, add it to the control input, and then continue our calculations.
For example, Figure 4.17 shows steering control input with 10% error range for 15 m radius
of the reference path, 200 ms delay and 300 ms ZOH.
Consider Figure 4.18, We can observe the impact of the computational imprecision from
the cost functions corresponding to those errors at ZOH of 300ms and 15 m radius of reference
curve. The value corresponding to each delay value is generated by performing experiments
till standard deviation is lesser than 0.01. We can observe that 15% error range affects the
system performance most and cost difference is higher for delays greater than 200 ms.
28
Figure 4.17. Steering control input with computational error
Figure 4.18. Cost functions with computational error for ZOH
29
4.5
Multivariate Cost Functions
In real-time control systems, tasks are usually correlated i.e., the system performance
is the result of the vector of delays encountered by two or more tasks. Now the cost is a
function of the response time of more than one task, i.e., it is multivariate. As for example
in a vehicle controller, the braking and steering tasks can have different delays. Each wheel
has braking and steering task so two groups can be formed, one for steering tasks and one
for braking tasks. Braking and steering tasks are not independent; the delay of one affects
the performance of the other. The cost function equation presented in [8] can be extended
for multivariate cost functions as follows:
C(ξ1 , ξ2 , ....ξn ) =


g(ξ1 , ξ2 , ....ξn ) if 0 < ξi ≤ Γi


∞
if
ξi > Γi
where i ∈ {1, 2...to n}, ξ1 , ξ2 ....ξn are response times and Γ1 , Γ2,..... Γn are deadlines of n tasks,
respectively and g(.) is a continuous, monotonically non-decreasing function.
More precisely, let the control tasks be T1 , · · · , Tn . Denote by F (x, ξ1 , · · · , ξn ) the cost
or performance functional value associated with the plant starting in state x over a given
residual period of operation, Toper , and the assumption that each iteration of task Ti has
response time ξi , for i = 1, · · · , n. Then, the cost function associated with these response
times is given by
C(x, ξ1 , · · · , ξn ) = F (x, ξ1 , · · · , ξn ) − F (x, 0, · · · , 0)
(4.1)
Note that F () may be any functional that captures the aspects of performance relevant
to the user; no restriction is placed on its form. Note further that this is only defined when
task response times do not exceed their respective deadlines.
Remark 1: Since the plant state-space may be very large, it is not practical to try to evaluate
30
this cost function at each point. Instead, one breaks down the state-space into subspaces and
associates a cost function associated with each subspace. This may be obtained, for example,
by selecting a certain number of random samples over that subspace and averaging the cost
function values for those samples. The finer the granularity of the division into subspaces
and the greater the number of samples taken, the more accurately the cost functions reflect
the actual behavior of the system; however, this is at the cost of an increased number of cost
functions overall and more (offline) computational work.
Remark 2: In reality, the response times of different iterations of individual task are certain
to vary. To obtain an exact characterization of the impact of the delay of any individual
iteration, we would have to calculate the impact on the performance functional of each of the
response times of the thousands to millions of iterations executed over any reasonable period
of operation, Toper . This is clearly impractical and so in our calculations of the cost function,
we use a single reference value, ξi , for the response time associated with each iteration of
an individual task, Ti , i = 1, · · · , n. This cost function is then used as an approximation of
the impact on the control plant performance of task Ti . Note that because the cost function
is also a function of the plant state and the plant state encompasses the impact of all the
control delays up to that point, this is an acceptable approximation.
Remark 3: The cost function is a multivariate function. We will see later that in many cases,
cost functions have cross terms, i.e., product terms like xi xj for i 6= j. This reflects the fact
that the response time of one task can affect the sensitivity of the plant to the response time
of another.
Remark 4: If the controlled plant operation has well-defined distinct phases, each with its
own demands and task loading (e.g., in an aircraft, takeoff, cruise, landing flare, landing),
one can define cost functions over these individual phases rather than over the entire period
of operation. If the plant operates essentially forever, we can set any practical horizon (e.g., a
31
Figure 4.19. Bivariate cost function
day) over which the performance functional is evaluated. If a shorter time horizon is desired
(e.g., just a few seconds), that can be implemented as well. The point is that our assessment
of the impact of a nonzero controller delay is entirely within the control of the user and can
respond fully to the particular needs of the application.
Figure 4.19 provides an example of this multivariate cost function. Such multivariate cost
functions will form the optimization criteria for the scheduling of tasks. Using regression
techniques, the cost function shown in Figure 4.19 can be approximately expressed as:
f(x1 , x2 )= 48.33 - 52.37x1 - 141.07x2 + 1436.55x21 + 1806.37x22 - 2423.43x1 x2
where x1 is the delay for torque tasks and x2 is the delay for steering tasks and they are in
time unit of second. Radius of reference curve is 15 m and zero order holding period is 300
ms.
We have observed in case of a single delay for all the tasks, system performance is affected
by the nature of the control, radius of the reference path, holding period etc. Multivariate
cost functions also change with these parameters. Table 4.2 shows cost function comparisons
32
Radius
of
ref.
curve (in
m)
Period = 100 ms
Period = 300 ms
ZOH
FOH
ZOH
FOH
10
0.74
0.14x0.13
1 x2
−0.31
3.59x0.37
1 x2
58.8x1−0.34 x0.14
2
3.9x10.17 x20.036
35
0.15
6.4x0.12
1 x2
5.6E − 07x4.9
+
1
16.7x0.25
2
0.92e0.017x1 +0.86E −
04x22 + 0.088x1
11.74x10.12 x20.80 −
0.2E + 03
Table 4.2. Cost Functions Comparison
at different radii and type of control. Equations derived are approximated and a better fit
may be obtained. The tool used for curve fitting is LAB Fit and this tool uses the LevenbergMarquardt method to solve nonlinear regressions. Here x1 and x2 values are in milliseconds.
We can make the following observations from this table.
• Both the reference (i.e., desired) trajectory and the vehicle speed play a large role
in determining the cost function; the cost functions are quite different for different
trajectories and speeds.
• Whether ZOH or FOH is used also has a substantial impact on the impact of the task
delays.
• In several instances, we have cross-terms, i.e., terms involving a product of x1 and x2
terms. This indicates that the marginal performance of one task is affected by the
response time of the other.
We should emphasize that we assumed only two response times, x1 and x2 , for ease of
exposition. In the general case, each of the four torque tasks and each of the four steering
tasks can have a different execution time; the cost function will then have eight response-time
arguments.
33
4.6
Discussion
We have observed that a cost function depends on the system state. Particularly in our
case, it depends on the holding period, radius of reference path, initial parameters such as
speed, type of reference path (e.g., circular or straight), type of control, computational error
etc.
In principle, the vehicle computer should have a library of cost functions for standard
inputs such as tracks with different radii, road conditions etc. Based on the particular control
and driver inputs, the appropriate entry from the library must be selected; the cost function
of that entry will be used for scheduling purposes. The actual trajectory of the vehicle cannot
obviously be determined a priori. However, we can reasonably assume that it is composed of
multiple segments, stitched together, and obtain various possibilities for each segment. At
a minimum two types of segments: straight lines and arcs (of varying radii) are sufficient.
Cost functions associated with each of these can be derived offline. Scheduling can be done
over each such segment: since a vehicle is a mechanical object, the duration of each segment
is obviously large with respect to the control task periods. Each segment can therefore be
treated as an individual phase in the operation of the vehicle. Offline task schedules for such
segments can be generated for standard segment types; the one closest to the actual track
selected by the driver is used A handful of such segments is all that is required. For example,
the cost function for a straight-line segment of length 40 m is not very different from that
of length 100 m. In much the same way, for other controlled plants, the period of operation
can be divided into segments or phases.
Lastly, cost functions are multivariate in practice, the completion time of one task affects
the performance of the others. This dependence means that adjusting the frequency or
execution rate of one task will likely change the urgency or quality of one or more other
control tasks. This is a departure from conventional real-time scheduling, where each task
is treated in isolation, with its own deadline specified without regard to others.
34
CHAPTER 5
TASK MODEL
This chapter describes a task model for cost function based real-time scheduling heuristics
presented in Chapter 6. These heuristics are generic and are not centered around any specific
case.
Our task model consists of n periodic tasks T1 , T2 , ... Tn in a task set (TS). A task Ti
where i ∈ 1 to n, has parameters like deadline (di : relative deadline), period (pi ), and Worst
Case Execution Time (ei ) and a multivariate cost function is associated with the task. A
task Ti has to be executed periodically i.e., in every pi time units, an iteration of the task
is released and it has to finish at most ei units before its deadline di . The mth iteration of
Ti is represented as m. ri,m denotes the release time of the mth iteration of Ti . Pre-emption
of a task is allowed so a task may not finish its allocated execution time when another task
arrives. We denote the remaining execution time of a task Ti by er,i . f inishi,m denotes
the finishing time of mth iteration of Ti and its response time is calculated by expression:
f inishi,m − ri,m .
A typical approach in scheduling involves tasks assignment to processors and then uniprocessor scheduling on each of the processor to decide when a task will execute. A task set is
allocated to a processor such that its utilization (U ) is less than or equal to some specified
P
value (Usp ) i.e., U = ni=1 peii ≤ Usp ≤ 1. Thus tasks are assigned to individual processors
so that the set of tasks assigned to each processor can be feasibly scheduled. In this thesis,
we focus on the problem of uniprocessor scheduling. Each schedule is generated over major
period (H) which is the LCM of all task periods’, and it repeats every H time units. We
35
Table 5.1. Some notations
Notation
ei
er,i
m
ri,m
H
schedulet
Z
M Bi
Ti
TS
CS
Explanation
Worst case execution time of task i
Remaining execution time of current iteration task i
mth iteration of task i
Release time of mth iteration of task i
Major period : LCM of all tasks’ periods
Task scheduled at time t
Decision point : Completion or arriving time of any task
Marginal benefit for task i
Task i
A set consists of execution execution time and period of tasks
A set of cost functions
denote the task scheduled at any time t by schedulet . The scheduler makes a decision about
which task to run at every decision point (Z), which is a completion or arriving time of any
task. A cost function associated with the tasks Ti ,..Tj ,..Tk is represented as f(xi , ..xj , ..xk )
where tasks Ti ..Tj ..Tk are dependent and xi ,..xj ,..xk are their response times, respectively.
The objective of the scheduling policy is to schedule tasks in order to meet deadlines and
minimize the total cost over H.
36
CHAPTER 6
SCHEDULING HEURISTICS
In this chapter, we describe scheduling heuristics assuming the processor speed is fixed.
We develop heuristic for offline and online phases. In the offline phase of the algorithm all
the information about a task, such as execution time, is provided ahead of scheduling. In the
online phase, when the scheduler cannot afford heavy computation and Actual Execution
Times (AETs) of tasks are not known in advance, the scheduler uses the task order from the
offline phase and responds to the actual execution times of completed tasks, latest finishing
times and arrival of tasks.
6.1
Offline Heuristic - Targeting Worst Case
Knowing in advance how much cost a task will incur if run without violating any deadline
constraint and then making scheduling decisions is fairly straightforward. Among all available tasks, tasks can be scheduled in descending order of costs incurred. However, tasks are
not independent and the dependency of tasks through multivariate cost functions limits the
total cost calculation until the response times of all the correlated tasks are known. This in
turn limits the scheduling decisions. For example, if two tasks, X and Y , are in the system
at a time and no deadline constraints are violated, the scheduler has no basis of deciding
whether to schedule X or Y first since it does not know their response times and thus cannot
compare costs. Knowledge of response times ahead of time will work if X and Y are independent but if they are dependent (as in our case) and the scheduler decides to run based on
a cost comparison, it will not work as we need both tasks’ response time before knowing the
37
actual cost. Information about response times can be useful if the scheduler can quantify
the effect of changing response times on the total cost and then tasks can be scheduled in
order from more impact to less impact on the total cost (effect in terms of reducing total
cost). We call it marginal benefit and it is for a task is the partial differentiation of the cost
function w.r.t its response time. This idea is the basis for our heuristic.
Our heuristic starts with an EDF schedule which is obviously not cost sensitive but
ensures that the deadline constraints are satisfied. The EDF schedule provides the response
time of all tasks, thereby allowing us to evaluate the cost function. In the next step, our
heuristic swaps tasks in a cost sensitive way adhering to deadline constraints. This swapping
is done at the beginning of every decision interval. The heuristic decides which task to
run(swap) based on marginal benefits, which is calculated from the response times of tasks
from the EDF schedule or from the updated response times of tasks if they have finished
in the current schedule. Marginal benefit signifies the effect a of change in response time of
the task on the cost: if this change is higher, then corresponding task is more cost sensitive
than others and could contribute to higher cost if delayed. So it should be scheduled earlier
to minimize total cost value. Thus, at every decision point, we will have a task scheduled
with the highest marginal benefit at the moment subject to deadline constraints. This is a
greedy approach. Figure 6.1 shows the pseudo code for the Greedy Heuristic (GH) taking a
task set (TS) and a cost functions set (CF) as input.
38
Heuristic Offline Greedy(TS,CF)
1. Run EDF and collect response time of tasks
T otalCost = 0
for t = 0 to H
Run EDF
upon completion of iteration m of Ti
collect response time, xi,m = f inishi,m − ri,m
T otalCost = T otalCost + costxi,m ,xw,m ,....xy,m
// Tasks Tw ,..Ti ,...Ty are correlated and xw,m ,...xi,m ,...xy,m are their latest response times,
respectively
EdfCost = T otalCost
2. Find marginal benefits and swap tasks
T otalCost = 0
for t = 0 to H
At a decision point Z
(i) Generate set A of available tasks, A = Ti ∈ TS : ri,m ≤ t and er,i >0
for all Ti ∈A, calculate Marginal Benefit (M B i ) :
M Bi =
∂f (xp,m .., xi,m .., xj,m )
∂xi,m
(ii) Select task Tk such that M B k = max of all M B i
Tedf [] = tasks between scheduleZ and scheduleZ+er,k
CostpreSwap = Total cost based on the current schedule
// swap Tk and tasks in Tedf []
scheduleZ = k
scheduleprevious position of Tk = Tedf []
Update response times of Tk and Tedf []
CostpostSwap = Total cost based on the updated schedule
if (CostpostSwap > CostpreSwap ) or (a deadline is missed)
Revert schedule,go back to pre-swap state
Update response times of Tk and Tedf []
Remove M B k and go to (ii)
T otalCost = T otalCost + costxk,m ,xw,m ,....xy,m
HeuristicCost = T otalCost
Figure 6.1. Greedy Heuristic pseudo code
39
Figure 6.2 illustrates GH through an example. {W CET, period} of 3 tasks are as follows:
{4, 8},{2, 12},{3, 12}. Cost functions assumed are x1 x22 and x23 , where x1 , x2 and x3 are
response times of T1 , T2 and T3 , respectively. We show swapping at time 0 : decision made
based on MB values. Finally we see that GH reduces the cost.
EDF Schedule
cost=0
Arrival
cost=0+144
T1
T11
0
1
2
4
5
7
8
T1,T2,T3
T1 2
9
cost=405+45
T1
T3 1
6
cost=225+180
T3
T2 1
3
cost=144+81
T2
j
T i = iteration j of task i
Departute
10
T2
12
13
3
T3
14
15
T2,T3
T1
T1
2
T2 2
11
cost=450+36
17
18
T3
= 586
T3 2
T1
16
cost=486+100
19
20
21
time
22
23
24
T1
GH Schedule
At time=0: x1=4, x2=06, x3=9
MB1 = x2.x2 = 36, MB2 = 2.x1.x2 = 48, MB3 = 2.x3 = 18
cost=0
cost=0+24
T2
cost=24+81
cost=105+20
T3
T1
cost=125+45
T1
cost=206+100
=306
T3
cost=170+36
T2
T1
Swapped
T11
T2 1
0
1
2
3
4
T3 1
5
6
7
8
T1,T2,T3
Final Schedule
T2 1
0
1
T1,T2,T3
T1
2
3
10
6
12
13
7
8
T1
14
T3 2
15
T2,T3
T1
9
3
10
2
11
16
17
18
19
20
21
T1
T2 2
12
T3 2
T1
13
T2,T3
T1
14
2
15
T3
T3
16
T1
Figure 6.2. GH example
40
time
22
23
24
cost = 217
T2 T1
T3 1
5
11
T2 2
T3
1
4
9
T1
T1
T2
T1 2
T1
2
17
3
T1
18
19
20
time
21
22
23
24
6.2
Offline Heuristic - Targeting percentage of the Worst Case
GH in Section 6.1 is based on WCETs. During run time, actual execution times are
usually less than WCETs. Online heuristics may not be very effective in terms of cost since
tasks are running at AETs while the offline schedule is cost sensitive for WCETs. There is
an alternative. Instead of minimizing cost for WCETs (targeting WCET), we assume that
a task runs to x% of its WCET, where x is the user-selected parameter and minimize the
cost for these execution times (targeting percentage of the WCET). In particular, we take
the following approach. We consider a static priority scheme which assigns priorities to each
iteration: priority set π = {πi,m for i = 1,2,.....} and generate a schedule based on these
priorities. Note that these are priorities assigned to task iterations, i.e., a unique number
is assigned to each iteration of each periodic task that is issued over the major period and
not to all the iterations of the same task (as is the case in a static priority scheme like RM).
Note further that throughout, we ensure that deadlines will continue to be met even if all
iterations run to their WCETs.
The optimization problem can now be stated as follows. Assign priorities πi to each task
iteration over a major period such that the expected cost is minimized subject to the need
to keep the deadlines satisfied even if every task runs to its WCET. Figure 6.3 contains the
pseudo code explaining the algorithm in more detail. We use Simulated Annealing (SA) to
determine how to alter priorities (i.e., how to swap priorities) so as to lower the expected
cost, while ensuring that the new priority allocation is still feasible for WCETs.
41
Heuristic Offline target perc WCET(TS,CF)
1. Assign static priorities in inverse order of finishing times of the tasks from the EDF
schedule
(SA takes these priorities as the starting point)
2. Generate schedules for the priority assignment:
(i) Generate SW assuming that it runs to its WCET
(ii) if no deadline miss occurs
Generate SE assuming that each task iteration runs to its targeted execution time.
Calculate cost for SE
3. Change priorities:
In the each step of SA, change the priority assignment by randomly swapping two priorities
where each iteration of each task has equal probability of being swapped.
4. if search is successful, SA will provide a better solution, i.e., a feasible solution where cost
of SE is smaller and no deadline miss in SW even if all tasks run to WCET.
else call the GH and use its solution
Figure 6.3. Heuristic targeting percentage of WCET - pseudo code
6.3
Online Heuristic
The basic idea here is that if any time is reclaimed during operation, we try to schedule
a task which has the highest marginal benefit value subjected to the fact that a task starts
its execution at a time no later than its start time at the offline. This ensures that task will
not miss its deadline. Our online heuristic will be invoked upon completion of a task. The
pseudo code for the online heuristic (nodvsONH) is in Figure 6.4.
Figure ?? provides an example for nodvsONH. {W CET, period} of 3 tasks are as follows:
{4, 8},{2, 12},{3, 12}. AETs of a task are represented as {1st iteration, 2nd iteration, ...}
and are as follows: {2.1, 3.6, 0.8}, {1.8, 0.4}, {0.6, 1} for T1 , T2 and T3 , respectively. Cost
functions assumed are x1 x22 and x23 , where x1 , x2 and x3 are response times of T1 , T2 and T3 ,
respectively. The key observation is that the first iteration of T2 finishes early at time unit
42
of 1.8 and reclaimed time is 0.2 which is given to T3 which has higher MB than T1 at time
1.8.
Given:
1. treclaimed is the time reclaimed upon completion of a task.
2. ton is the current online time.
Heuristic Online(treclaimed ,ton )
if treclaimed == 0 , return
else
{
while treclaimed != 0
{
Generate set A of available tasks, A = Ti ∈ TS : ri,m ≤ ton and Ti is alive
Calculate marginal benefits based on response times from online schedule if available
(or) from offline schedule response times and pick Tk with the highest marginal benefit
if A is not empty
{
count = min (time duration after ton for which Ti is alive , treclaimed )
treclaimed = treclaimed − count
}
else
return
}
// while-end
}
Figure 6.4. Online heuristic without DVS - pseudo code
Figure 6.6 provides an example which compares two offline approaches. {W CET, period}
of 4 tasks are as follows: {2, 6},{2, 8},{1, 12} and {3, 12}. AETs of a task are represented
as {1st iteration, 2nd iteration, ...} and are as follows: {1.4, 1.4, 1.4, 1.4}, {1.4, 1.4, 1.4, 1.4},
{0.7, 0.7}, {2.1, 2.1} for T1 , T2 , T3 and T4 , respectively. Cost functions assumed are x21 x32 x3
and x24 , where x1 , x2 , x3 and x4 are response times of T1 , T2 , T3 and T4 , respectively. Two
43
offline schedules are shown. In one case, we are targeting WCET and in other, targeting
70% of the WCET. Here actual execution times are 70% of the WCET and we observe that
targeting 70% of the WCET in the offline gives significant improvement in cost over targeting
WCET.
44
j
Arrival
Departure
Ti
= iteration j of task i
GH Schedule : Offline Phase : Targeting WCET
cost = 3412
T1
T1
1
0
T2
1
T2 1
2
T3
T3 1 T41
4
5
6
3
T1,T2,T3,T4
T1
T2
8
T2 2
9
10
2
T1
7
T1
T4
T41
11
T1
3
T2
2
T1
12
T3
13
T3 2 T4
15 16
T2 3
17 18
T2
T1
14
T1,T3,T4
T2
T1
4
T4
2
T1
19
20
T4
21
cost = 761.04
Offline Phase : Targeting Percentage of WCET
T3
T3 1
0
T2
T1
T2 1
1
T1
2
1
T41
4
3
T4
5
6
T1,T2,T3,T4
T1
T1
7
8
T1
2
9
T2
T2
10
11
T3
T1
3
2
T3 2 T4
T1
12
13
15
14
T1,T3,T4
T2
T2
2
16
3
T2
17
T2
T4
T4
18
2
T1
4
T1
19
20
T1
1
0
T2
T3
T2 1 T3 1
1.4
T4
T1
T41
2.8 3.5
T1
5.6 6
T1,T2,T3,T4
T2
2
T2
7.4
T1
T1
3
2
8
T1
9.4
T2
12
T2 T4
2
2
T4 T3 2 T4
T2
16
3
T4
2
4
time
T1
19.4
T2
T2 1
T3 1
0 0.7
T1,T2,T3,T4
T1
2.1
T1
1
T4
T4
3.5
1
T1
T1
5.6 6
T1
cost = 205.93
T2
2
T2
7.4 8
T2
T1
2
3
T1
9.4
24
T1
Online Phase : Targeting Percentage of WCET
T3
24
T1
17.4 17.6 18
T2
T1,T3,T4
22 23
cost = 445.11
T3
13.4 14 14.7
time
21
T1
GH Schedule : Online Phase : Targeting WCET
T1
time
22 23 24
12
T3
T2 T4
2
2
T4 T3 2 T4
13.4 14 14.7
T1,T3,T4
16
T2
T2
3
T4
2
17.4 17.6 18
T1
4
T1
19.4
24
T1
Figure 6.6. Comparison of two offline approaches - example
6.4
Numerical Results and Discussion
We have developed simulators in C programming language for the following purposes :
1. Solving delayed differential equations to obtain cost functions.
The inputs to the simulator are the initial value of the vehicle system state variables,
delay value for tasks, holding period and time of travel. For a given time of travel, the
45
simulator calculates the cost corresponding to the given delay values. The cost is calculated
for different combinations of delay values.
2. For implementing scheduling heuristics.
We take a task set and cost functions as inputs and generate a schedule and cost value
corresponding to that schedule. A task set is generated for a specific utilization/work load.
It is generated by first randomly selecting worst case execution times and periods from a set
and then normalizing them to achieve a target utilization value. Release time of the first
iteration (ri,0 ) of all the tasks is assumed to be at time zero. We determine the relative
deadline of a task to be equal to its period. So only one iteration of a task will be alive at
a time. We assume that there is no scheduling and context switching overhead. AETs are
generated based on a given input distribution.To calculate the total cost of the schedule, we
consider the latest response times of tasks.
Extensive simulations were carried out to assess the quality of our heuristics. To get
each point on the curve, we perform a certain number of experiments. Choice of number of
experiments is influenced by standard deviation value. We aim to get a very low deviation
value (< 0.01), so that the cost ratio is stabilized.
Numerical results are obtained for two types of cost functions:
6.4.1
Cost Function From the Case Study
These numerical results were generated for 5 tasks in the vehicle system considering
individual steering on all four wheels and a single torque task for the vehicle. We derive
a multivariate cost function as per the discussion about cost functions in chapter 4, the
following cost function is derived: eax1 +bx2 +cx3 +dx4 +ex5 +f where x1 is the response time of the
torque task, x2 , x3 , x4 , x5 are response times of steering task on the left front wheel, right
front wheel, left rear wheel, right rear wheel, respectively, and a = 2.4, b = 1.2, c = 1.3, d =
1.26, e = 1.4, f = 2.3. We assumed a 10 m radius of reference curve and holding periods of
46
150 ms and 200 ms for torque and steering tasks, respectively. For simulations, we randomly
select WCETs from set {5 − 60}ms and interleaved periods from set {10, 20, 40, 80, 160}ms.
To check the quality of the resultant schedule (offline followed by online), we obtain the
vehicle trajectory that would follow from this schedule. Therefore, cost ratios shown in the
results are ratios of the cost obtained from the vehicle simulator. We call it final cost/final
cost ratio. This is needed to establish the usefulness of the cost functions, to demonstrate
that they do indeed capture the control issues involved.
6.4.1.1
Example Trajectory
In Figure 6.7, we show an example of the comparison between the result of EDF against
the cost function approach (GH) by showing the trajectory that results in each case and
calculating the total divergence (between the reference and the actual tracks) for each case.
The vehicle speed is 8.2 m/sec and start 2 m away from the trajectory pointing in the upward
direction. The task set has the online utilization of 0.52 and {W CET, period} of 5 tasks are
as follows: {20, 150},{40, 200},{40, 200},{40, 200},{40, 200}. We can see that GH performs
better than EDF : Cost of GH reduces by ∼ 25%.
6.4.1.2
EDF vs GH
Figure 6.8 compares final costs of EDF and GH. Each experiment consists of a different
task set. AETs are generated based on normal distribution with mean = 80% of the WCET
and standard deviation = (WCET - mean)/2, subject to the condition that the unconditional
normal distribution has values over (−∞, ∞).
The plot shows variation of cost ratio with four different cases. Each case shows three subcases. For sub-case 1, average online utilizations for case 1,2,3 are 0.5,0.6,0.7, respectively.
For sub-case 2 and sub-case 3, average online utilizations in case 1,2,3 are 0.4,0.48,0.56,
respectively. More details regarding sub-cases are provided in Table 6.1:
47
Figure 6.7. Example - Trajectories for GH and EDF schedule
Table 6.1. Vehicle cost function - Greedy vs EDF cases description
sub-case 1
Tasks run to their
case WCETs in the online.
1,2,3 Online heuristic for GH
is nodvsONH
sub-case 2
Tasks run to their AETs
in the online.
Online
heuristic for GH is
nodvsONH
48
sub-case 3
Tasks run to their AETs
in the online.
Online
heuristic for GH does
not schedule tasks with
higher marginal benefit
during reclaimed time. It
simply run next available
task or idle the processor
in case no task is available.
Figure 6.8. Vehicle cost function - Greedy vs EDF
We observe that for sub-case 1, on an average (considering all the cases), the GH final
cost improves by ∼ 27 % over EDF final cost and for sub-case 2, this improvement is ∼ 22%.
At higher utilization,in the offline phase, GH has less flexibility for making changes in the
schedule due to deadline constraints which results in the poor offline result and thus higher
final cost compare to a lower utilization. Comparing sub-case 3 with sub-case 2 shows how
nodvsONH performs. As the utilization goes up, nodvsONH does more online adjustments
as the offline solution is not good and performs better than a simple online heuristic which
does not take advantage of the reclaimed time. On an average nodvsONH improves the cost
by ∼ 10% .
6.4.1.3
GH vs SA
GH solution is not optimal. We need an optimal algorithm to check its closeness to
the optimal solution. Due to its complexity dynamic programming is impractical to use as
an optimal baseline algorithm. We use a search algorithm such as simulated annealing to
search an improvement over GH cost if exist. For any task set, we first obtain the GH cost
49
and schedule and make it as initial configuration for SA. Our experiments shows 3 - 4%
improvement over the GH cost. A high temperature depreciating factor for SA is chosen to
allow it to cool down slowly and search for a longer duration. The small improvement over
GH suggests that the GH solution is good.
6.4.1.4
Effect of Targeting Percentage of the WCET
Figures 6.9 and 6.10 describe the effect of targeting some percentage of the WCET in
the offline over targeting WCET. The final cost ratio is calculated for both cases for same
AETs. In each experiment, we take different task sets and different target execution times
and AETs. AETs are generated based on normal distribution. These are normal under the
condition that they lie within a given range. Mean of the distribution lies exactly half way
between some percentage of WCET and WCET i.e., mean = (W CET − x%.W CET )/2.
Standard deviation is set as half of difference between WCET and mean. In figure 6.9
targeted execution times are generated based on a normal distribution which holds the same
property as the distribution for AETs i.e., they have same mean and standard deviation as
the distribution for AETs. Cost ratios are plotted for varies offline utilization values and
for different values of the mean and standard deviation for a limited normal distribution
curve. We observe that as the standard deviation decreases, final cost improves more for
the heuristic targeting percentage of the WCET due to the closeness of targeted execution
times to AETs. As the work-load increases, less flexibility leads to poor offline results and
thus the improvement in the online is smaller.
Figure 6.10 shows the impact of targeting a fixed percentage of the WCET at utilization
of 0.6. We observe that if we target at values far from the average, the improvement in the
final cost is lesser than targeting values closer to the average and for a normal distribution
of AETs, improvement in the final cost is more when we target values obtained from a
distribution compare to targeting fixed percentage of the WCET.
50
Figure 6.9. Vehicle cost function - Final Cost Ratio:Percentage of WCET vs WCET (Targeting values from a distribution)
Figure 6.10. Vehicle cost function - Final Cost Ratio:Percentage of WCET vs WCET
(Targeting fixed percentage of WCET)
51
6.4.2
Polynomial cost function
Our heuristics are general and therefore applicable to variety of cost functions. This subsection shows an example for polynomial cost functions. Cost functions here are artificial and
unlike the previous case, are not derived from any application. Figure 6.11 is generated for
WCET set {1 − 6} and interleaved periods set {5, 10, 20, 40, 80}. Task set consists consists
of 10 tasks. Tasks with polynomial cost functions are grouped as follows: 4 Groups, 1
independent task
1st group cost function: f (x1 , x2 ) = x1 x22
2nd group cost function:f (x4 , x5 ) = x34 x5
3rd group cost function:f (x6 , x7 , x8 ) = x6 x27 x8
4th group cost function:f (x9 , x10 ) = x29 x10
Independent task cost function: f (x3 ) = x23
where xi is the response time of Ti . The assignment of each task to a group and polynomial
selections are random and mean to serve just as an example.
In Figure 6.11 we observer a similar trend to that observed for the vehicle cost function
when comparing GH and EDF. However, the improvement in cost is significantly different:
On an average ∼ 30 % for both sub-case 1 and sub-case 2. The Online heuristic performs ∼
35 % better than the base algorithm.
The type of cost functions plays an important role and the result here suggests that the
cost functions chosen in this case are closer to perfect monotonically increasing functions
which suits to the idea behind developing cost sensitive heuristics.
52
Figure 6.11. Polynomial cost functions - Greedy vs EDF
53
CHAPTER 7
DYNAMIC VOLTAGE SCALING
The available energy for computation is often limited. In some applications, energy is a
scarce commodity to begin with. Some other applications are not energy-limited, but have
constraints on the amount of heat that can be dissipated: such constraints also translate to
energy bounds.
The traditional real-time DVS algorithms tries to reduce energy consumption. However,
in our case, the energy-sensitive scheduling algorithm has a different objective. The difference
lies in the way in which we handle tasks that complete ahead of their projected worstcase execution times. In a traditional real-time DVS algorithm, slack time that is thereby
released is consumed to run other tasks at a slower pace, thereby reducing the total energy
consumed. In this problem, we use energy as a constraint, not as an optimization criterion.
Our optimization criterion remains the quality of control provided to the plant, as expressed
through our cost functions. In our case, when a task completes early, it provides additional
slack in both energy and time. Both are then used to reduce task response times to improve
control quality: time slack allows tasks to start earlier, energy slack allows tasks to run faster
(obviously, up to a certain limit).
We present energy constrained-cost sensitive DVS schemes where given an energy budget,
the heuristic tries to find a minimum cost value for the task set. We assume that when
task arrives with WCET, it is run at the maximum operating frequency of the processor.
Therefore running GH (presented in Chapter 6) for a given task set with WCETs should give
maximum energy (Emax ) that can be consumed and a corresponding cost value claimed to
54
be minimum achievable by GH. This gives upper bound on energy. Energy budget for DVS
is now set at a value Ebudget where Ebudget <Emax . Heuristic in the offline phase is claimed to
meet energy budget when energy of schedule Esched is less than and closer to Ebudget .
The task model for DVS is the same as that described in Chapter 5. For the energy model,
we consider a set of processor operating frequencies (f1 , f2 , ...fn ) and operating voltages
(V1 , V2 , ...Vn ) corresponding to those frequencies, respectively. If a capacitance of C is charged
and discharged by a clock signal of frequency f , peak supply voltage V and α is the activity
factor, then the energy dissipated per cycle, or the dynamic power is given by α.C.V 2 .f and
the energy consumed over the time t is given by α.C.V 2 .f.t [28].
7.1
Offline Heuristic
The offline DVS heuristic (DVSoffH) under the energy constrain Ebudget on a task set is
as shown in Figure 7.1.
Heuristic Cost Function Offline DVS(TS,CF)
1. Run Simulated Annealing (SA) on EDF until it meets energy budget Ebudget .
(i) Start SA with EDF configuration at WCETs and in each step, allocate one of the operating frequencies to each iteration of tasks, chosen uniformly over set of operating frequencies
s.t. no deadlines is violated.
(ii) Find EDF schedule and energy.
2. If Ebudget is not meet // solution is invalid.
return
3. Call Heuristic Cost Function Offline Greedy(TS,CF) with changed execution
times which will be cost sensitive.
Figure 7.1. DVS offline - pseudo code
55
7.2
Online Heuristic
The idea used in the online version of the DVS (DVSonH) is similar to what was discussed
for the online heuristic without DVS. First of all, the scheduler takes task orders from the
offline phase to run. We then follow a greedy approach where we give any extra energy
released to the next task in schedule and allow it to run at a higher operating frequency if
possible. This heuristic will be invoked every time a task finishes to select a frequency for
the next task to be scheduled. Figure 7.2 shows the pseudo code for DVSonH.
Figure 7.3 shows an example for DVS schemes. {W CET, period} of 3 tasks are as follows: {1, 6},{1, 12},{1, 6}. AETs of a task at maximum operating frequency are represented
as {1st iteration, 2nd iteration, ...} and are as follows: {0.6, 0.5}, {1, 0.6}, {0.6, 0.8} for T1 ,
T2 and T3 , respectively. Cost functions assumed are x1 x22 and x23 , where x1 , x2 and x3 are
response times of T1 , T2 and T3 , respectively. Relative operating frequencies and corresponding voltages are 1, 0.75, 0.5 and 1, 0.9, 0.83, respectively. Energy consumed if every task
runs at maximum operating frequency is 5 units. Energy budget is 75% of the maximum
energy i.e., 3.75 units. We see that offline heuristic scale frequencies in order to meet the
energy budget and online heuristic tries to increase frequency whenever energy is released
due to early completion of a task, for example first iteration of T2 and second iteration of T3
run at higher frequency than their frequencies at the offline phase. , This is unconventional
compare to most of the traditional real-time DVS.
7.3
Main Results and Discussion
For the heuristics with DVS, for a given task set and energy budget, the simulator
gives out a minimum cost. Simulations are run for {1, 0.5, 0.25} as the relative operating
frequencies and {1, 0.9, 0.83} volt as the corresponding voltages. We choose a constant
activity factor of 0.5 and assume that there is no interval of switching processor operating
frequency and voltage (no switching overhead). AETs of tasks are chosen uniformly between
56
Given:
1. Ereleased is the energy released upon completion of a task. This energy is obtained by
comparing offline specifications to the actual energy used.
2. Eavailable is the total energy available for a task to run in order to be close enough to the
energy budget. Eavailable for a task is sum of the energy from the offline specification and
Ereleased by the previous task.
Heuristic Online DVS(Ereleased ,Eavailable )
if Ereleased == 0, return
{
else
{
//Select frequency fon for next task Ti to be scheduled
// Assume that task will run at WCET and find frequency s.t. energy consumption is
as close as possible to Ea
Emax = −∞
for all operating frequencies fj and corresponding
voltages Vj
Ej = α ∗ C * Vj2 * fj * (ei *fmax /fj )
if Emax < Ej && Ej ≤ Eavailable
Emax = Ej
if Emax == −∞
fon = frequency as per offline specification
else fon = frequency correspond to Emax
}
Figure 7.2. DVS online - pseudo code
57
Arrival
j
Ti = iteration j of task i
Departure
GH Offline: Without DVS
T1
T2
T3
T1
T3
Energy Consumed = 5 units
f
fmax= 1
Cost = 21
1
1
0
2
T2 1 T3
T1
1
2
2
T1
3
4
5
T1, T2,T3
6
T3
7
8
9
T1
f
1
T2
T3
T1
1.3
T3
T1
6
8
1
0.75
0.5 T11
0
0.8
T1, T2,T3
9.3 10
11
12
T1,T3
Energy Consumed = 2.91 units
DVS Online
T1
T3
2
2
T3
T2 1
2
3.3
4.6
T1, T2,T3
f
12
Energy Consumed = 3.74 units
Cost =67.98
1
T1
0
11
T1,T3
DVS Offline
1
0.75
0.5
10
Cost = 19.58
T2 T3
T2 1
T1
1
2
T3
2.1 2.9
T1
4
5
6
T3
2
T3
7 7.8
9
10
11
12
T1,T3
Figure 7.3. DVS heuristics - example
40% of WCET to 100% of WCET. Here all the results are at the processor level i.e, cost
and energy is obtained from the schedule, therefore the final cost is the cost of the schedule
obtained from the offline heuristic followed by the online heuristic.
7.3.1
7.3.1.1
Cost Function From the Case Study
Final cost ratio vs. Energy Budget
Figure 7.4 shows the cost-energy trade-off at two different offline utilization values. We
take the ratio of DVSonH cost (Offline heuristic:DVSoffH) and DVSonH cost at the maximum
frequency (Offline heuristic: GH). We obtain the average of cost ratio for the successful
58
experiments for an energy budget and repeat this for different energy budgets. Figure 7.4
shows curves for 0.35 and 0.49 average online utilizations. The curves show the trend between
energy and cost. For a lower energy budget, we get higher cost ratio and this is due to the
fact that at the lower energy budget, tasks will run at lower frequencies, and therefore will
have higher response times which will give a higher cost. As the energy budget get closes
to the 100 percentage of the maximum energy, curve approaches towards the cost ratio of
1, indicating closeness to the maximum energy scenario i.e., there will be hardly any scaling
in the offline and online, so DVS solution will be much closer to without DVS solution. For
a given energy budget, the cost ratio for a higher task utilization is more than for a lower
utilization and this is for the reason that after scaling task’s execution times for an energy
budget, heuristic at the higher utilizations has less flexibility for swapping tasks compare to
heuristic at the lower utilizations. So we get a poor offline solution which results in the poor
final result.
Figure 7.4. Vehicle cost function - Cost and Energy trade-off
59
Figure 7.5. Vehicle cost function - Actual consumed energy ratio vs. Energy Budget
7.3.1.2
Actual Consumed Energy Ratio vs. Energy Budget
Figure 7.5 shows ratio of the actual energy consumed when running DVS and the energy
consumed without DVS. It shows the non-traditional behavior of our DVS heuristic. The
actual energy consumed with DVS is close to the fraction of the maximum energy set by
the energy budget parameter. For a utilization, as the energy budget increases, energy ratio
closer to 1 signifies that with DVS and without DVS solutions are close.
60
CHAPTER 8
CONCLUSION
This thesis is part of an attempt to devise better interfaces between the control plant
and the control computer of a given cyber-physical-system. We have used multivariate cost
functions to represent to the computer side the sensitivity of the controlled plant to controller
delays. Such cost functions can then be used for scheduling the controller tasks.
Our scheduling algorithm represents an advance over traditional real-time scheduling.
In traditional scheduling, the aim is solely to ensure that all critical deadlines are met. In
our approach, while meeting deadlines remains a constraint, the focus is on ordering task
executions so that the quality of control provided is improved.
An obvious extension to this work would be to extend it to multiprocessor systems. With
multicore processors emerging, this would be of practical importance.
61
BIBLIOGRAPHY
[1] S.T. Peng, ”On one approach to constraining the combined wheel slip in the autonomous
control of a 4WS4WD vehicle,” IEEE Trans. Control Syst. Technol., vol. 15, no. 1, pp.
168-175, May 2007.
[2] W. B. Cleveland, ”First order hold interpolation digital-to-analog converter with application to aircraft simulation,” NASA technical note, National Aeronautics and Space
Administration, Washington DC, Nov 1976.
[3] R. Rajamani, Vehicle Dynamics and Control. New York : Springer-Verlag, 2008.
[4] J. Zhang, X. Zhu, Z. Zhou, ”Design of time delayed control systems in UAV using model
based predictive algorithm,” Informatics in Control, Automation and Robotics (CAR),
2nd International Asia Conference, pp. 269-272, March 2010.
[5] E. Lee, ”Cyber-Physical Systems- Are computing foundations adequate?,” NSF workshop on cyber-physical systems, October 2006.
[6] J. Nilsson, ”Real time control systems with delays,” Thesis published by Department
of Automatic Control, Lund Institute of Technology, Sweden,1998.
[7] C.M. Krishna, ”On the Design and Analysis of Real-time Computers,” Ph.D. dissertation, Electrical Engineering, University of Michigan, 1984.
[8] K.G. Shin, C.M. Krishna, Y.H. Lee, ”A Unified Method for characterizing Real-time
Computer Controller and Its Applications,” IEEE Trans. Automatic Control, pp. 357366, 1985.
[9] J.W. Wendorf, ”Implementation and Evaluation of a Time-driven Scheduling Processor,” Real-time Systems Symposium, pp. 172-180, 1988.
[10] R. Davis, S. Punnekkat, N. Audsley, A. Burns, ”Flexible Scheduling for Adaptable
Real-time Systems,” Real-Time Technology and Applications Symposium, pp. 230-239,
1995.
[11] D. Prasad, A. Burns, ”A Value Based Scheduling Approach for Real-time Autonomous
Vehicle Control,” Robotica, Cambridge University Press, pp. 273-279, May 2000.
[12] M. U. Hegde, ”Optimal Scheduling in Real-time Systems Operating in Hazardous Environments,” M.S. thesis, Electrical and Computer Engineering, University of Massachusetts Amherst, 1991.
62
[13] R. M. Murray, ”Future Directions in Control, Dynamics, and Systems: Overview, Grand
Challenges, and New Courses,” European Journal of Control, Pasadena, USA, March
2003.
[14] R. K. Yedavalli, R. K. Belapurkar, ”Application of wireless sensor networks to aircraft
control and health management systems,” Department of Mechanical and Aerospace
Engineering, Ohio State University, Ohio,2011.
[15] K.G. Shin, X. Cui, ”Computational Time Delay and Its Effects on Real-Time Control
Systems,” IEEE Transactions on Control System Technology, vol. 3, no. 2, pp. 218 -224,
1995.
[16] C.S.G. Lee, B.H. Lee, ”Resolved Motion Adaptive Control for Mechanical Manipulators,” Journal of Dynamic Systems, Measurement, and Control, vol. 106, no. 2, pp.
134-142, 1984.
[17] C. Phillips, R. N. Uma, J. Wein, ”Online Admission Control for General Scheduling
Problems,” 11th SODA, ACM and SIAM, 2000.
[18] T.C. Yang, ”On Computational Delay in Digital and Adaptive Controllers,” Proceedings
of the International Conference on Control, vol. 2, pp.906-910,1994.
[19] J. Nilsson, B. Bernhardsson, B. Wittenmark, ”Stochastic Analysis and Control of Realtime Systems with Random Time Delays,” Automatica, vol. 34, no. 1, pp. 57-64, 1998.
[20] J.N. Anderson, B.L. Reed, ”The Effects of Computational Delay on the Model-Based
Control of Manipulators,” Proceedings of IEEE Southeast, pp. 103-107, 1990.
[21] S.J. Ovaska, O. Vainio, ”Predictive Compensation of Time-Varying Computing Delay
on Real-Time Control Systems,” IEEE Transactions on Control System Technology, vol.
5, no. 5, pp. 523-526, 1997.
[22] J. Wang , R.G. Longoria , ”Effect of Computational Delay on the Performance of
a Hybrid Adaptive Cruise Control System,” SAE World Congress Detroit, Michigan,
April 2006.
[23] J.F. Meyer, D.G. Furchtgott, L.T. Wu, ”Performability evaluation of the SIFT computer,” IEEE Trans. Computers, vol. C-29, pp. 501-509, June 1980.
[24] P. Pillai, K.G. Shin, ”Real-Time Dynamic Voltage Scaling for Low-Power Embedded
Operating Systems,” Proceedings of eighteenth ACM symposium on Operating Systems
Principles, vol. 35, Dec. 2001.
[25] W. Kim, J. Kim, S. Min, ”A Dynamic Voltage Scaling Algorithm for Dynamic-Priority
Hard Real-Time Systems Using Slack Time Analysis,” Design, Automation and Test in
Europe Conference and Exhibition, pp. 788-794, 2002.
[26] R. Jejurikar, R. Gupta, ”Dynamic Voltage Scaling for Systemwide Energy Minimization
in Real-Time Embedded Systems,” Low Power Electronics and Design, ISLPED, pp.
78-81, Aug. 2004.
63
[27] T. Sakurai, A. Newton, ”Alpha-power Law MOSFET Model and Its Application to
CMOS Inverter Dealy and Other Formulars,” IEEE Journal of Solid State Circuits, vol.
25, no. 2, pp. 584-594, April 1990.
[28] N. Weste, D. Harris, CMOS VLSI Design: A Circuits and Systems Perspective. 4th ed.,
Addison-Wesley, chapter 5, pp.185-194, 2010.
64