feedback control of cyber-physical systems with multi...

11
Feedback Control of Cyber-Physical Systems with Multi Resource Dependencies and Model Uncertainties Lindberg, Mikael; Årzén, Karl-Erik Published in: [Host publication title missing] DOI: 10.1109/RTSS.2010.14 2010 Link to publication Citation for published version (APA): Lindberg, M., & Årzén, K-E. (2010). Feedback Control of Cyber-Physical Systems with Multi Resource Dependencies and Model Uncertainties. In [Host publication title missing] (pp. 85-94) https://doi.org/10.1109/RTSS.2010.14 General rights Unless other specific re-use rights are stated the following general rights apply: Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain • You may freely distribute the URL identifying the publication in the public portal Read more about Creative commons licenses: https://creativecommons.org/licenses/ Take down policy If you believe that this document breaches copyright please contact us providing details, and we will remove access to the work immediately and investigate your claim.

Upload: others

Post on 09-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Feedback Control of Cyber-Physical Systems with Multi ...lup.lub.lu.se/search/ws/files/6063298/8168912.pdf · Feedback control of cyber-physical systems with multi resource dependencies

LUND UNIVERSITY

PO Box 117221 00 Lund+46 46-222 00 00

Feedback Control of Cyber-Physical Systems with Multi Resource Dependencies andModel Uncertainties

Lindberg, Mikael; Årzén, Karl-Erik

Published in:[Host publication title missing]

DOI:10.1109/RTSS.2010.14

2010

Link to publication

Citation for published version (APA):Lindberg, M., & Årzén, K-E. (2010). Feedback Control of Cyber-Physical Systems with Multi ResourceDependencies and Model Uncertainties. In [Host publication title missing] (pp. 85-94)https://doi.org/10.1109/RTSS.2010.14

General rightsUnless other specific re-use rights are stated the following general rights apply:Copyright and moral rights for the publications made accessible in the public portal are retained by the authorsand/or other copyright owners and it is a condition of accessing publications that users recognise and abide by thelegal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private studyor research. • You may not further distribute the material or use it for any profit-making activity or commercial gain • You may freely distribute the URL identifying the publication in the public portal

Read more about Creative commons licenses: https://creativecommons.org/licenses/Take down policyIf you believe that this document breaches copyright please contact us providing details, and we will removeaccess to the work immediately and investigate your claim.

Page 2: Feedback Control of Cyber-Physical Systems with Multi ...lup.lub.lu.se/search/ws/files/6063298/8168912.pdf · Feedback control of cyber-physical systems with multi resource dependencies

Feedback control of cyber-physical systems with multi resource dependencies andmodel uncertainties

Mikael LindbergDepartment of Automatic Control

Lund [email protected]

Karl-Erik ArzenDepartment of Automatic Control

Lund [email protected]

Abstract—The problem of modeling and controlling re-sources in a system with interaction between hardware andsoftware is considered. A model encompassing both hardwareand software dynamics is developed together with an on-line estimation scheme in order reduce dependence on a-priori information. A control structure is presented in ord erto control performance under constrained resource situationsand to reduce effects of estimation errors and disturbances.The approach is applied to a conversational video case andevaluated through simulations.

I. I NTRODUCTION

The main characteristic of Cyber-Physical Systems (CPS)is the need to simultaneously consider both the computingand communication processing and the physical system, andtheir interactions. During recent years a number of challeng-ing applications have emerged within areas such as smartpower grids, intelligent homes, environmental monitoring,and transportation systems, see [21] [22] [13] [26]. Many ofthese applications base their functionality on wireless com-munication, either in the form of sensor/actuator networksor based on mobile cellular communication systems.

In addition for mobile communications to being an en-abling technology for CPS, the components of a mobilecommunications, i.e., the cellular phones themselves, alsocan be viewed cyber-physical systems, such as illustrated inFigure 1. For the modern, typically multi-core, processorsemployed in smart phones efficient thermal managementis essential in order to not overheat the system. The chiptemperature dynamics is governed by a continuous-timedifferential equation model which takes as an input thepower generated by the CPUs, which in term is decidedbased on the CPU utilization. An efficient solution forthis requires an integrated or holistic approach, i.e., a CPSapproach, encompassing both the temperature dynamics andthe computations.

Another central characteristic of modern cellular phonesis the focus on multimedia applications. Multiple synchro-nized audio and video streams are required in order to,e.g., support conversational video applications. Multimediastreaming applications are rate-based applications wheretheexecution time each cycle typically changes stochastically

depending, e.g., on the type of video frame being processedor due to cache effects.. Correct synchronization betweenthe streams, e.g., between the video and audio stream isessential from a usability perspective.

The uncertainty in execution times is just one out ofseveral sources of uncertainty in these types of systems.The temperature dynamics may vary drastically dependingwhether the phone is exposed to the sun or not. Thelimited heat tolerance of the processor imposes restrictionson resource availability in a way that needs to be consideredfor mobile devices, which working conditions can be hardto predict. The classical approach in real-time systems whensubject to dynamic variations in resource consumption isto do a worst-case design. However, in addition to theproblem of deriving the worst-case numbers, the resultingover-provisioning of resources is in general not acceptablein these types of mass-market products.

Feedback and estimation are generally very good ways tohandle uncertainties in physical systems. This also holds forresource-related uncertainties in embedded real-time com-puting system. Using feedback the allocation of resourcesis based on measurement of actual resource consumptionand resource availability. This results in a resource manage-ment system that dynamically adapts the behavior of thesystem. Dynamic resource management is often combinedwith bandwidth server or reservation techniques such as,e.g., constant bandwidth servers (CBS) [2] that enforce theabstraction of virtual processors in which an application isguaranteed a certain share of the total CPU resource.

A challenge for CPS is the development of a unifiedmodeling formalism that covers both physical phenomenaand computations. Although, a plethora of different hybridmodels have been proposed, they are often overly complexfor the purpose of dynamic resource management. What isrequired is a abstract notion of resources and transformationsof resources.

In this paper a feedback-based resource managementmethod is proposed that unifies thermal management andcontrol of media tasks. A unified model is used that is basedon the dynamics of flows, both physical and virtual. Unlikeprevious approaches the feedback is based on metrics that

Page 3: Feedback Control of Cyber-Physical Systems with Multi ...lup.lub.lu.se/search/ws/files/6063298/8168912.pdf · Feedback control of cyber-physical systems with multi resource dependencies

relate to the application performance, in this case the syn-chronization error between the video and the audio and theencoding latency, rather than just the CPU utilization. It isshown how the use of such metrics enables the attenuation oftransient phenomena, despite being in a resource constrainedsituation.

A. Related Work

Resource management for embedded systems has its rootsin scheduling theory. Many traditional works use ConstantBandwidth Servers [2] or Proportional Share (PS) scheduling[23] to enforce resource reservations. Such mechanisms aretoday widely available for commodity operating systems,such as Linux [19] [5], but assigning shares still requiresknowledge about resource consumption. The approach takenin this paper is that resources are allocated based on run-timemetrics. Such schemes have been proposed by e.g. [4], [1],and [17]. Unlike these works however, this paper considerssystems where the components have dependencies, both inphysical and virtual resources.

[7] studies the coupling between thermal dynamics andsoftware performance, but does this based on the utilizationbound, not application performance.

For resource constrained situations, feedforward alloca-tion is often proposed, with Q-RAM [20] being one ofthe more complete formulations. However, this is mainlyan off-line method and relies on a-priori knowledge aboutexecution times. This paper uses a nominal feedforwardallocation, but based on on-line estimated dynamics andalso applies feedback to reduce effects of estimation errorsand disturbances. Thiele proposes the use of Real-TimeCalculus for resource management in embedded systems[24], but focuses on analysis instead of control. Other worksof interest are [8], [12], [25] and [18].

CPU Core

Resource Control

SW

Task

SW

Task

Scheduler

U

u1

u2

data

T output

load

schedparams

Figure 1. A common CPS, consisting of a CPU and a set of softwarecomponents. The CPU can be utilized to a degreeU that depends on thetemperatureT . The utilization should then be allocated to the softwarecomponent so that the output of the system is optimized in some sense.

Recently event based methods have gathered attention inthe control society, with some examples in [11], [10], [16],because of the way it can improve on the trade-off betweencontrol performance and cost of control action. Event baseddynamics is used in this paper, not to reduce the cost ofcontrol, but to introduce information that is not possible todescribe in flow dynamics. It should be noted that thereare similarities between the problem solved in [9] and thesynchronization problem discussed below due to the use ofevent dynamics.

B. Outline of the paper

First the problem of modeling both physical and softwaredynamics is discussed in Section II, where the cyclic taskmodel is introduced together with a model of the CPUthermal dynamics. This section also introduces the examplesystem, a conversational video pipeline, and the relevantperformance metrics. The control structure used is discussedin Section III and the simulation environment and simulationresults are then presented in Section IV. A discussionon future directions follows in Section V and then someconcluding remarks in Section VI.

II. SYSTEM MODEL

One important objective of this paper is to model asystem where there is noticeable interaction between thesoftware components and the hardware components. Theapproach taken is to see it as a system which performanceis governed by the flow of resources.Resourceis here takento mean a quantity, bounded and non-negative, that througha system component is converted into another resource.The system performance is then expressed in terms of thistransformation.

A resource flowis the exchange of a resource between twocomponents of the system. In a CPS, a flow can be physical(e.g. heat or power) or virtual (computations or data). Inthis work physical flows are consideredL2 functions whilevirtual flows are eitherL2 or a sequence of Dirac-spikes,with finite density. This is similar to the notion of discreteevent signals described in [14]. Formally, letU denote theset of generalized functions onR such that ifu(t) ∈ U and,t1, t2 ∈ R then

∫ t2

t1

u(t)dt (1)

exists and has the sign oft2 − t1. The rationale behindresource flows as Dirac-spikes is that many important virtualresources are generated in an event-like manner. As anexample, letnCPU (t) denote the number of completedinstructions in a CPU andntask(t) the number of times asporadic task running on that CPU has executed. Obviously,ntask(t) depends onnCPU (t). In order to analyze theperformance of the task, e.g. to check if it completes cyclen

before a certain time, it is necessary to study howntask(t)

Page 4: Feedback Control of Cyber-Physical Systems with Multi ...lup.lub.lu.se/search/ws/files/6063298/8168912.pdf · Feedback control of cyber-physical systems with multi resource dependencies

PhysicalSystems

SoftwareSystems

Continuous

Dynamics

Discrete

Flow

Dynamics

Event

Dynamics

Figure 2. A diagram showing how the domains of physical and softwaresystems have their own unique dynamics, but share the discrete flowdynamics.

and nCPU (t) evolve over time but due to their stair casenature, ift0 denotes some specific time,

limh→0

ntask(t0)− ntask(t0 − h)

h(2)

is either 0 or undefined. Therefore the dynamics of a systeminvolving virtual flows must be expressed in discrete time,here called adiscrete flow dynamic.

Forming such a description for physical systems canbe done through sampling. Note however that while thesampled system description says nothing about the systembehavior between sample points, signals likenCPU (t) andntask(t) are defined for allt. Because of this, it is possibleto talk about exactly when the changes inn occur. Theseinstantaneous changes, referred to as events (see e.g. [10]),contain important information about the system that can beexploited in control.

To summarize, the dynamics of a physical system is oftenmodeled through differential equations. These can be dis-cretized or sampled to give a discrete time model. Softwaresystem are usually modeled through event based dynamics,but these can be re-formulated as discrete flow dynamics,comparable with the discretized continuous model. Thisgives a common model domain with which to express theentire system dynamics. Figure 2 show how the two domainsand the dynamic descriptions relate.

A. Cyclic Task model

To derive both discrete flow and event dynamics of a soft-ware task, this paper introduces a variant of the periodic taskmodel. In order to accurately express the event dynamics, theexact completion time of each job is important and thereforeexplicitly part of what will be referred to as thecyclic taskmodel.

A task τi is cyclic if it repeatedly performs a set ofcomputations that output the same form of results, with thenext cycle beginning immediately when the previous ends.The output is a data resource, e.g. encoded video frames,sensor readings or computed control signal. A cyclic taskwill block if and only if it is starved of CPU-time. Thecycle execution time for cyclen is denotedCi(n) and isstochastic. For estimation purposes, it will be assumed thatCi(n)

• has a strictly positive lower bound and

0.0 0.5 1.0 1.5 2.0 2.5 3.0time (s)

0

5

10

15

20

25

30

35

40

n(t

)

n(t)

0.0 0.5 1.0 1.5 2.0 2.5 3.0time (s)

0

5

10

15

20

y(t

)

y(t)

Figure 3. ni(t) and yi(t) for one of the tasks in the simulations. Notethat these are not sampled curves, despite their jaggedness. Both signalsare defined for eacht

• constitutes a weakly stationary stochastic process withE{Ci} < h

From this it follows that if a task is started att0 and executesuntil t1, the expected number of completed cycles becomes

E{t1 − t0

Ci

} ≈t1 − t0

E{Ci}(3)

Let ui(t) denote the fraction of CPU-time allocated toτithrough some resource reservation scheme, such as CBS orPS, over the intervalh = t1−t0. Letni(t) denote the numberof completed cycles forτi at timet. (3) can then be used toapproximate the dynamics ofni(t) as

ni(t+ h)− ni(t) ≈1

E{Ci}hui(t) = hkiui(t) (4)

or in words,ni evolves approximately like a discrete timeintegrator with the unknown gainki and is driven by thevirtual resource flowui(t).

ni(t)−ni(t−h)h

is denotedyi(t)and is referred to as theexecution rateof τi. yi(t) constitutesa discrete flow. Figure 3 shows an example ofni(t) andthe correspondingyi(t) for one of the tasks used in thesimulations.

The other aspect of the cyclic task model is the eventdynamics, i.e. exactly when the contributions to the flowoccur. This has no counterpart in physical flows as contri-butions are spread out continuously over time. For softwaretasks on the other hand, the completion time is often animportant performance metric. In the cyclic task model, thecompletion time for cyclen is denotedxi(n) and modeledas

xi(n+ 1) = xi(n) +Ci(n)

ui(xi(n))(5)

if ui(xi(n)) is assumed to be constant over the interval[xi(n), xi(n+ 1)).

Page 5: Feedback Control of Cyber-Physical Systems with Multi ...lup.lub.lu.se/search/ws/files/6063298/8168912.pdf · Feedback control of cyber-physical systems with multi resource dependencies

While this could be used for traditional deadline drivenscheduling (e.g. keepingxi(n+1) < xi(n)+Di)) it is alsopossible to control other and sometimes more interestingmetrics, such as the synchronization between two non-uniform sequences.

B. Multi-resource dependencies

It is desirable to model tasks that require multiple re-sources to execute. In this paper this is done by assumingthat if a task lacks a supply of any one required resource,it will block until it has enough. This is a generalization ofthe behavior for the dependency on CPU-time introducedpreviously. It is assumed that a task has the capability ofaccumulating incoming flows, e.g. in FIFO queues for dataor execution time deficit accounting in the scheduler for cpu-time. It follows that the task execution rate is limited by therate at which resources are made available to it. Formally,if τi is dependent on the flowsu0, ..., uN

yi = min(ki,0u0, ..., ki,NuN ) (6)

would describe its execution rate, whereki,j denotes thedependency fromuj to yi. From (6) it follows that an alloca-tion strategy should try to keep the incoming flows equal tominimize over-provisioning. Furthermore, it points towardstwo important objectives for maximizing performance ofthese systems

1) calculating a steady state flow that maximizes therelevant performance metric

2) control transient effects that cause blocking

C. CPU dynamics

In order to study how the availability of the CPU influ-ences the software and how the software load affects theavailability of the CPU, this paper uses a model for thethermal dynamics based on [6]. The CPU must not becometoo hot and if there is no active cooling, the temperaturemust be controlled through the power. It is assumed that thesystem studied in this work consists of a computing platformwith one CPU equipped with a thermal sensor. The modelof the dynamics from CPU powerP to CPU temperatureTis

T = a(Ta − T ) + bP + d (7)

where a and b are constants depending on the thermalresistance and heat capacity of the processor andTa theambient temperature.d is a disturbance term which willbe assumed have slow dynamics, such as heat generatedby direct sunlight or by being placed on a heated surface.For of-the-shelves CPUs,a and b are in the order of10−4

and 10−3 respectively (see e.g. [7]), making the dynamicsrelatively slow. It is therefore assumed that it possible tofilter out measurement noise, which is therefore omittedfrom the model.

CPUResourceController

AudioEncoder

NetworkStack

VideoEncoder

Q1

Q2

T

cpu-time

U

u_a

u_n

u_v

y_a

y_v

y_n

Figure 4. An overview of the conversational video pipeline

The relationship between CPU loadU and P is thenmodeled as

P = Pidle + U(Pmax − Pidle) (8)

Sampling the combination of 7 and 8 can then be done underzero-order-hold assumptions.

D. Example system

The prototypical system to be considered is a conversa-tional video pipeline as displayed in Figure 4. The softwarepart consists of three tasks, an audio encoder, a videodecoder and a network stack. The encoders are assumedto have private access to capture hardware and it is alsoassumed that they are capable of variable rate execution.The encoders are connected to the network through FIFO-queues, Q1 and Q2. In order to send a network packet, thestack requires one frame of audio and video.

In order to evaluate the performance of this system, thefollowing metrics are defined

1) Sync error: It is disturbing to the human eye whenvideo and audio is out of sync and therefore it is naturalto consider the difference in encoding timestamp betweenthe corresponding audio and video frames. If both tasks areassumed to be cyclic andxa(n) andxv(n) denotes the en-coding timestamps for audio and video frames respectively,then

xa(n+ 1) = xa(n) +Ca(n)

ua(xa(n))

xv(n+ 1) = xv(n) +Cv(n)

uv(xv(n))

(9)

would be the corresponding dynamics. The sync errores(n)is then defined as

es(n) = xa(n)− xv(n) (10)

2) Latency: Delay in the conversation is also an impor-tant quality metric and for this set up it will be the end toend latency. Ifq1(t) and q2(t) are the number of elementsat time t in Q1 and Q2 respectively, then let theel(t) bedefined as

el(t) =

Ca(n)ua(xa(n))

+ Cv(n)uv(xv(n))

2+(

q1(t) + q2(t)

2+1)

Cn(n)

un(xn(n))(11)

or in words, the computational delay combined with thenetwork backlog in the queues.

Page 6: Feedback Control of Cyber-Physical Systems with Multi ...lup.lub.lu.se/search/ws/files/6063298/8168912.pdf · Feedback control of cyber-physical systems with multi resource dependencies

3) Queue dynamics:Using the cycle dynamics expressedin (4), the dynamics ofq1 andq2 is modeled as

q1(t+ h) = q1(t) + h(ya − yn)

q2(t+ h) = q2(t) + h(yv − yn)(12)

III. C ONTROL DESIGN

The challenges in designing a control scheme for thedescribed system lies in the uncertainty inCi and thethermal dynamics of the CPU. Normally a CPU can onlyoperate properly if the temperature is kept below a certainlevel but if there no active cooling, as is the case in manyembedded platforms, this must be respected through controlof CPU power. The options to do this include voltage- andfrequency scaling and idling, the last of which will be usedin this paper. The main reason for this is that the speedof the CPU directly affectsCi and any on-line estimatesof these parameters will then change due to control action.Controlling the power throughU and then imposing the limit

ua + uv + un ≤ U (13)

simplifies the estimation strategy.The control will be done through assigning a share of the

available CPU-time through a resource reservation frame-work. In the calculations, fluid resource model is assumedand the actual deviations from the ideal share are modeledas part of the stochastic cycle times. This means that theparameters of the reservation framework will influence thenoise levels.

If a CBS framework is used, the server periods should bekept well belowh or the assumption that

∫ t+h

t

ui(t)dt ≈ hui(t) (14)

which is used in (4), will not hold. The server period willalso influence the sync dynamics and therefore should bekept below the shortest cycle time in the system in order tominimize disturbances caused by the scheduler.

A. Thermal control

Given that the temperature is modeled with first order dy-namics with slow disturbances, a PI-controller [3] is a simpleand effective choice, though anti-windup measures must beadded to handle effects from control signal saturation.

The pure PI-controller is defined as

u(t) = K(e(t) +1

Ti

∫ t

0

e(τ)dτ) (15)

By discretization of the dynamics using a forward Eulerapproximation, constraining the control signalU to theinterval [0, 1] and adding an anti-windup tracking term tothe integral part, the resulting control algorithm, describedas pseudo-code, is

e := r - T;

V := K*e + I;U := sat(V, 0, 1);if (Ti != 0) then

I := I + h*e/Ti + h/Tr*(U - V);endif

whereh is the sample interval.

B. Estimation

When faced with model uncertainties such as the parame-terski, there is a choice between either estimating them on-line or applying robust feedback. In constrained situations,knowledge of model parameters is often necessary for trade-off decisions. This paper is therefore based on using anestimation scheme and the resulting estimates are then usedfor both feedforward and feedback design.

Periodic sampling and recursive estimation methods couldbe applied on a physical plant (see e.g. [15]), but this wouldbe impractical for use with the event dynamics, which dealwith non-discretized time. The approach taken instead issimply counting the number of cycles completed in a timewindow of lengthtw and then estimateki as

ki(t) =ni(t)− ni(t− tw)

hui

(16)

This estimate however relies onui being constant overtw,which might not be the case. Though a reservation basedscheduling policy is used, if the estimation window appliedis not fitted to the reservation period, the actual amount ofresource can deviate noticeably. However, as most operatingsystem expose the accumulated CPU-time per process, i.e.

∫ t

0

ui(t)dt (17)

through system calls it is therefore possible to reformulatethe estimator as

ki(t) =ni(t)− ni(t− tw)

∫ t

t−twui(t)dt

(18)

tw has been set toh in during simulations but is important tonote that the parameter estimates are expressed in continuoustime.

C. Latency

It follows from (11) and (6) that latency can be controlledthrough minimizing the queue lengths and then keepinga uniform steady state cycle time across all components.The approach taken in this work is to combine a feedforward control based on the total amount of resource witha feedbackre-allocation to reduce queue length. In essencethis is a form of midrange control.

The nominal feed forward controls are computed bycombining (13) with

ya = yv = yn (19)

Page 7: Feedback Control of Cyber-Physical Systems with Multi ...lup.lub.lu.se/search/ws/files/6063298/8168912.pdf · Feedback control of cyber-physical systems with multi resource dependencies

which gives

unoma

unomv

unomn

=

k−1a

k−1v

k−1n

kakvkn

ka + kv + knU (20)

To control the queue lengths, the feed forward controlsare then modified with a feedback termuq. As the controlsystem cannot violate (13),uq will be applied as

ua

uv

un

=

unoma

unomv

unomn

+

kv

ka+kv

ka

ka+kv

−1

uq (21)

subject to the constraints that the resulting controlsui ≥0.

To calculateuq(t), the closed loop dynamics of the queuesare evaluated. It is assumed that the queues will be of equallength in steady state (see the section on sync error) so thefeedback can be designed with any one in mind. Recall

q1(t+ h) = q1(t) + h(ya − yn) (22)

Assume the objective is to drive the queue length to somepredetermined lengthr (e.g. zero). Let

h(ya − yn) = Kq(r − q1(t)) (23)

This converges tor for all 0 < Kq < −2. Substituteya =ka(u

noma + uq

kv

ka+kv

) and yn = kn(unomn − uq) and solve

for uq to obtain the actual controls.

D. Sync error

If Ca

ua

is approximated by(kaua)−1, it follows from the

definition (10) that

es(n+ 1) = es(n) + (kaua)−1 − (kvuv)

−1 (24)

As there is a finite combined flow of CPU resource to theaudio and video encoder, the approach taken here is tointroduceus as a feedback term, modifying the feedforwardallocation so that

es(n+1) = es(n)+(ka(ua+us))−1−(kv(uv−us))

−1 (25)

is driven towards zero. While this seems to interfere withthe queue control, the difference in time scale between theevent-to-event dynamics make its effects on the slower queuecontroller negligible. In fact, it is seen in Section IV-Ethat controlling the sync error actually greatly simplifiesthequeue control. Let

(ka(ua + us))−1 − (kv(uv − us))

−1 = Kses(n) (26)

Under deterministic circumstances the sequencees(n) willconverge to zero for anyKs ∈ (0,−2). Given the variationsin the cycle execution times, some care should be taken whenselectingKs as the noise can drive the system unstable. Asthis work is done without a detailed noise model,Ks ischosen conservatively as -0.5. Then solve forus under theconstraint thatua + us ≥ 0 anduv − us ≥ 0.

The resulting control structure is presented in Figure 5.

Estimator

Queue

Controller

Flow

Controller

Sync

Controller

kini

qi

es

uq

us

ui

Figure 5. The resulting control structure including estimation, feed forwardflow control based on the estimated model parameters and the availableCPU resource and feedback based on queue state and sync error

0 20 40 60 80 100n

0.010

0.015

0.020

0.025

0.030

0.035

0.040

0.045

0.050

rho_i(n)

AudioEncoder VideoEncoder NetworkStack

Figure 6. Generated cycle times used in the simulation examples below.

IV. SIMULATION RESULTS

A. Simulation environment

In order to evaluate controls, a simulation environmenthas been developed in Python. The system dynamics areapproximated by discretization with a time step of 1 ms,which incurs quantization on the cycle completion timestamps. This is however assumed to be of little effect asthe variation due to noise is orders of magnitude greater forthese simulations.

Cycle execution times have been generated asDi+Xi(n)where Di is an a-priori unknown constant andXi(n) ∈exp(0.1Di). The realizations used for the presented sim-ulation results are shown in Figure 6. The randomness ismeant to model both software execution time uncertaintyand the stochastic properties of a modern CPU, includingthe effects of caches, the memory bandwidth gap and deeppipelines. TheDi values were chosen randomly so that theresultingk-parameters would lie between 10 and 100. A real

Page 8: Feedback Control of Cyber-Physical Systems with Multi ...lup.lub.lu.se/search/ws/files/6063298/8168912.pdf · Feedback control of cyber-physical systems with multi resource dependencies

0 20 40 60 80 100 120n

0.0015

0.0020

0.0025

0.0030

0.0035

0.0040

0.0045

rho(n

)

MPEG-2 decoder sequence

Figure 7. A sequence of execution times for an MPEG-2 decoderworking on a video stream. This encoding standard interleaves completeimage descriptions with delta descriptions. Decoding a complete image issignificantly harder, causing the high peaks.

sequence of cycle times for a video decoder is provided forcomparison in Figure 7.h is globally defined as 1.

B. Thermal control

The thermal model of the CPU are based on [7], butto make the effects of the thermal dynamics more visiblein the simulations, the parameters have been scaled so thedynamics are faster. This makes the effects of control anddisturbances more prominent. In the simulationsa = 2 andb = 1.5. The main purposes of the thermal model are

• to provide a scenario for the varying availability of CPUresource and

• to show how physical models can be combined withthe software models.

so switching for a more realistic parameters would notchange the design decisions significantly though the thermalcontroller must then be re-tuned. However, as the focus ofthis paper is on the application performance as affected byboth hardware and software, more advanced temperaturecontrol strategies are left for future research.

A scenario where a disturbance enters occurs at 5 secondsis shown in figure 8. This could be a situation where the unitis left in direct sunlight that causes an insolation effect of15 degrees C / s. The controller keeps the temperature bythrottling the available CPU-time.

C. Parameter estimation

Figure 9 shows the estimated execution rates and corre-spondingki-parameter estimates over the simulation. Thediscontinuous nature of the virtual flows is evident in theseplots. Note that it takes some time before the Network Stackstarts to execute and this is because of the queue-controller.It throttles the Network Stack while the queues are filled

0 2 4 6 8time(s)

55

60

65

70

75

80

85

T (

degre

e C

)

T controlledT UncontrolledT ref

0 2 4 6 8time(s)

�0.5

0.0

0.5

1.0

1.5

2.0

U

U=sat(P+I,0,1)P-partI-part

Figure 8. PI control of temperature with a constant disturbance of 15degrees C / s entering at 5s. The uncontrolled dynamics are shown forcomparison.

0 2 4 6 8time(s)

0

20

40

60

80

100

120

140

k_hat

AudioEncoder VideoEncoder NetworkStack

0 2 4 6 8time(s)

0

5

10

15

20

25

30y_hat

AudioEncoder VideoEncoder NetworkStack

Figure 9. Rate and parameter estimation for all three tasks.Rates areestimated by counting events with a sliding time window withlength 1second. The network stack (red) lags behind in the beginningdue to queuecontrol.

and because of this, thek-parameter estimator needs moretime to formkn. This causes the big overshoot in the queuelength before it settles on the desired level.

Even though the actual execution rate changes overtime, the estimate mean remains stable while the varianceincreases at lower rates. This is because a single eventbeing outside or inside the estimation window will affectthe estimate more. The window based estimation schemewill break down when the rate drops below 1 cycle persecond. Section V-B discusses some alternatives that couldbe explored in future research.

Page 9: Feedback Control of Cyber-Physical Systems with Multi ...lup.lub.lu.se/search/ws/files/6063298/8168912.pdf · Feedback control of cyber-physical systems with multi resource dependencies

0 2 4 6 8time(s)

0.0

0.2

0.4

0.6

0.8

1.0

1.2

1.4

late

ncy

ControlNo control

0 2 4 6 8 10time(s)

0

2

4

6

8

10

12

q2

Avg Q w controlAvg Q no controlr

Figure 10. End-to-end latency and average queue length compared withand without control. The uncontrolled case (green) is about2-3 times worsethan what it obtained through control (blue).

D. Latency performance

As there is no information about future demands for theCPU resource, a reasonable strategy is to minimize latencyat all times. This is done by utilizing all available CPU-time while respecting the temperature set-point, therebyreducing the execution time for all tasks and by controllingthe queues. The reason why the queue controller is not tryingto drive the queue lengths to zero is that this could causeblocking in the network stack, which in turn would reducethe accuracy ofkn. This could be treated by designing abetter estimator.

The latency control performance is displayed in Figure 10.A scenario without queue control is provided for comparisonand the problem with this is evident. Even though the systemreaches steady state, an initial transient is left to causesignificantly higher latency.

E. Sync performance

The simulations reveals the importance of the sync con-troller. Figure 11 shows that the sync error while leftuncontrolled will actually drive the system to a stall. Thereason for this is that the queue controller uses the averagequeue length to do the re-allocation. Figure 12 shows thateven before thek-parameter estimates converge, the synccontroller keeps the audio and video stream tightly together.This means that the queue lengths are actually the same,an assumption which can then be safely used by the queuecontroller.

Figure 13 shows how the queue lengths diverge quicklyand the resulting re-allocation by the queue controller actu-ally starves both audio end video encoder. It would theoreti-cally be possible to form a MIMO-controller to handle bothsync and queues in the same control law, but recall that thequeue controller is a discrete time system that uses resource

0 2 4 6 8time (s)

�3.0

�2.5

�2.0

�1.5�1.0�0.5

0.0

0.5

1.0

1.5

e_s

(s)

e_s w control e_s no control

0 2 4 6 8 10time (s)

�0.06

�0.04

�0.02

0.00

0.02

0.04

0.06

e_s

(s)

e_s

Figure 11. Sync error compared with (blue) and without (red)control.In the uncontrolled case, the encoding pipeline stalls which is why theencoding error seems to remain constant after 2.5 seconds.

0 1 2 3 4 5time(s)

0

5

10

15

20

25

30

y_hat

AudioEncoder VideoEncoder NetworkStack

0 1 2 3 4 5time(s)

�5

0

5

10

15

20

25

30

y_hat

AudioEncoder VideoEncoder NetworkStack

Figure 12. Execution rates compared with and without sync control.The curves have been averaged over a window of0.1 s to provide bettervisibility.

flow semantics and therefore cannot in a simple way utilizeinformation about individual events. The sync controller onthe other hand operates on the event sequence and therebyhave access to the cycle completion time stamps.

V. D ISCUSSION AND FUTURE DIRECTIONS

The simulations show that the approach with resourceflow semantics, coupled with specific use of cycle com-pletion timestamps can address situations where there isdirect interaction between physical and virtual resources.The approach also shows promise as a way to model multi-resource dependencies for dynamic resource allocation. Ob-viously the limits on performance will come from thequantity of noise in the systems, which limits the accuracy

Page 10: Feedback Control of Cyber-Physical Systems with Multi ...lup.lub.lu.se/search/ws/files/6063298/8168912.pdf · Feedback control of cyber-physical systems with multi resource dependencies

0 2 4 6 8time (s)

�5

0

5

10

15

20

25

q1, q2

Q1 sizeQ2 size

0 2 4 6 8time(s)

�0.2

0.0

0.2

0.4

0.6

0.8

1.0

1.2

u_i

AudioEncoder VideoEncoder NetworkStack

Figure 13. Queue lengths for a scenario with no sync control.The resultingallocation is based on the average queue length(Q1 +Q2)/2.

on parameter estimates. The example above shows that eventhough this system has no slack in resource use at all, itis possible to control performance metrics with relativelysimple strategies. Below follow conclusions on some specifictopics.

A. Relation between physical and software models

The presented approach lends itself to a way of modelingwhere there is no significant difference between how wecontrol the physical and software components. Both can beseen as transforming a set of flows into other flows andeven though some precision is lost in order to handle thevirtual flows, it seems attractive for modeling larger systems.One observation is that the sync problem is very similarto synchronizing servos in robotics or formation controlfor autonomous vehicles. These are generally resource con-strained environments as well, making them attractive futureapplication areas.

B. Parameter estimation

In the simulations, a window based estimation method isused. This is difficult to combine with knowledge about thecorrelation between execution times, such as displayed inFigure 7. An interesting alternative would be to formulatean estimator working directly on the timestamp series, likethe sync controller does. This would require more detailedmodels of the algorithms and some care when thinking aboutto express the estimates so that they make sense in the flowsemantics.

C. Controller design

The controllers used for this work are all very simple andas there are several constraints in the dynamics, on both stateand control, it would be interesting to see how an MPC-stylecontroller could be designed. This is also a direction where

load models could be used to reserve resources a head oftime, e.g. by reducing CPU temperature in advance so thatit could effectively be over-clocked during a time with highdemand.

D. Non-constant data resource dependencies

In this work, the data resources are produced and con-sumed in deterministic quantities. An extension of interestwould be where for instance the cycle time is kept constantand the consumption quantities varied.

E. Reconfiguration and startup transients

The start up of the system is handled ad-hoc in thisscenario, withk−parameters kept at an initial guess untilenough information is gathered. A problem can arise if aninitial guess would result in a degenerate allocation causinga system stall. A similar situation could arise if the systemis reconfigured at run-time, switching which componentsare active or redirecting resource flows. It is necessarythat formal strategies for preventing such situations fromoccurring are developed before these types of solutions canbe deployed in safety critical environments.

F. Distributed control control

Though the semantics of both physical and softwarecomponents are similar, a controller that must exists in bothworlds can be difficult to build. A distributed formulationwhere minimal communication between hardware and soft-ware could prove necessary.

VI. CONCLUSIONS

This paper has presented a way to model dynamics thatcan be used to express the properties of both software andhardware, which is important to the domain of CPS. It isshown through simulations how such models can be usedto do resource allocation in situations with both uncertaindynamics and task to task dependancies. Furthermore thesimulations shown that the approach works even in resourceconstrained environments, as it does not rely on over-provisioning.

VII. A CKNOWLEDGEMENTS

This research has partially been funded by the VINNO-VA/Ericsson project ”Feedback Based Resource Manage-ment and Code Generation for Real-time System” and partlyby the EU ICT project CHAT (ICT-224428)

REFERENCES

[1] T. F. Abdelzaher, J. A. Stankovic, C. Lu, R. Zhang, and Y. Lu.Feedback performance control in software services.IEEEControl Systems Magazine, 23(3):74–90, 2003.

[2] L. Abeni, G. Buttazzo, S. Superiore, and S. Anna. Integratingmultimedia applications in hard real-time systems. InInProceedings of the 19th IEEE Real-time Systems Symposium,pages 4–13, 1998.

Page 11: Feedback Control of Cyber-Physical Systems with Multi ...lup.lub.lu.se/search/ws/files/6063298/8168912.pdf · Feedback control of cyber-physical systems with multi resource dependencies

[3] Astrom, Karl-Johan and Murray, Richard M.Feedback Sys-tems: An Introduction for Scientists and Engineers. PrincetonUniversity Press, 2008.

[4] Cervin, Anton and Eker, Johan and Bernhardsson, Bo andArzen, Karl-Erik. Feedback–feedforward scheduling of con-trol tasks.Real-Time Syst., 23(1/2):25–53, 2002.

[5] D. Faggioli, M. Trimarchi, and F. Checconi. An implemen-tation of the earliest deadline first algorithm in linux. InSAC’09: Proceedings of the 2009 ACM symposium on AppliedComputing, pages 1984–1989, New York, NY, USA, 2009.ACM.

[6] R. P. Ferreira and D. Mosse. Thermal faults modeling using arc model with an application to web farms. InIn Proceedingsof RTS, 2007.

[7] Y. Fu, N. Kottenstette, Y. Chen, C. Lu, X. D. Koutsoukos, andH. Wang. Feedback thermal control for real-time systems. InProceedings of the 16th Real-Time and Embedded Technologyand Applications Symposium (RTAS 2010), pages 111–120,Stockholm, Sweden, 2010.

[8] A. Ghosal, T. A. Henzinger, C. M. Kirsch, and M. A.Sanvido. Event-driven programming with logical executiontimes. In R. Alur and G. J. Pappas, editors,Hybrid Systems:Computation and Control, pages 167–170. Springer Berlin /Heidelberg, 2004.

[9] T. Henningsson and A. Cervin. Comparison of LTI andevent-based control for a moving cart with quantized positionmeasurements. InProceedings of the European ControlConference, Budapest, Hungary, Aug. 2009.

[10] T. Henningsson, E. Johannesson, and A. Cervin. Sporadicevent-based control of first-order linear stochastic systems.Automatica, 44(11):2890 – 2895, 2008.

[11] D. Henriksson, A. Cervin, and K.-E.Arzen. TrueTime: Sim-ulation of control loops under shared computer resources. InProceedings of the 15th IFAC World Congress on AutomaticControl, Barcelona, Spain, 2002.

[12] T. A. Henzinger, C. M. Kirsch, M. A. Sanvido, and W. Pree.From control models to real-time code using giotto.IEEEControl Systems Magazine, 23(1):50–64, 2003.

[13] H. Karl and A. Willig. Protocols and Architectures forWireless Sensor Networks. Wiley-Interscience, 2007.

[14] J. Liu. Continuous time and mixed-signal simulation inPtolemy II. Technical Report UCB/ERL MemorandumM98/74, Dept. of EECS, University of California, Berkeley,CA, USA, 1998.

[15] L. Ljung. System identification : theory for the user / LennartLjung. Englewood Cliffs, New Jersey : Prentice-Hall, 1987.

[16] J. Lunze and D. Lehmann. A state-feedback approach toevent-based control.Automatica, 46(1):211 – 215, 2010.

[17] P. Martı, J. M. Fuertes, G. Fohler, and K. Ramamritham.Improving quality-of-control using flexible timing constraints:Metric and scheduling issues. InRTSS ’02: Proceedingsof the 23rd IEEE Real-Time Systems Symposium, page 91,Washington, DC, USA, 2002. IEEE Computer Society.

[18] M. Mazo, A. Davitian, and P. Tabuada. PESSOA: A toolfor embedded controller synthesis. In T. Touili, B. Cook,and P. Jackson, editors,Computer Aided Verification, volume6174, pages 566–569. Springer Berlin / Heidelberg, 2010.

[19] C. S. Pabla. Completely fair scheduler.Linux J., 2009(184):4,2009.

[20] R. Rajkumar, C. Lee, J. Lehoczky, and D. Siewiorek. Aresource allocation model for qos management. InRTSS ’97:Proceedings of the 18th IEEE Real-Time Systems Symposium,page 298, Washington, DC, USA, 1997. IEEE ComputerSociety.

[21] L. Sha, S. Gopalakrishnan, X. Liu, and Q. Wang. Cyber-physical systems: A new frontier. InSUTC ’08: Proceedingsof the 2008 IEEE International Conference on Sensor Net-works, Ubiquitous, and Trustworthy Computing (sutc 2008),pages 1–9, Washington, DC, USA, 2008. IEEE ComputerSociety.

[22] E. Shih, P. Bahl, and M. J. Sinclair. Wake on wireless:an event driven energy saving strategy for battery operateddevices. InMobiCom ’02: Proceedings of the 8th annual in-ternational conference on Mobile computing and networking,pages 160–171, New York, NY, USA, 2002. ACM.

[23] I. Stoica, H. Abdel-Wahab, K. Jeffay, S. K. Baruah, J. E.Gehrke, and C. G. Plaxton. A proportional share resourceallocation algorithm for real-time, time-shared systems.InRTSS ’96: Proceedings of the 17th IEEE Real-Time SystemsSymposium, page 288, Washington, DC, USA, 1996. IEEEComputer Society.

[24] E. Wandeler, L. Thiele, M. Verhoef, and P. Lieverse. Systemarchitecture evaluation using modular performance analysis:a case study. International Journal on Software Tools forTechnology Transfer (STTT), 8(6):649–667, 2006.

[25] G. Weiss and R. Alur. Automata based interfaces for controland scheduling. In A. Bemporad, A. Bicchi, and G. Buttazzo,editors,Hybrid Systems: Computation and Control, volume4416. Springer Berlin / Heidelberg, 2007.

[26] D. R. Yoerger, M. Jakuba, A. M. Bradley, and B. Bingham.Techniques for deep sea near bottom survey using an au-tonomous underwater vehicle.Int. J. Rob. Res., 26(1):41–54,2007.