14
A Feedback Scheduler for Real-Time Controller Tasks Eker, Johan; Hagander, Per; Årzén, Karl-Erik Published in: Control Engineering Practice DOI: 10.1016/S0967-0661(00)00086-1 2000 Link to publication Citation for published version (APA): Eker, J., Hagander, P., & Årzén, K-E. (2000). A Feedback Scheduler for Real-Time Controller Tasks. Control Engineering Practice, 8(12), 1369-1378. https://doi.org/10.1016/S0967-0661(00)00086-1 Total number of authors: 3 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.

A Feedback Scheduler for Real-Time Controller Tasks Eker

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A Feedback Scheduler for Real-Time Controller Tasks Eker

LUND UNIVERSITY

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

A Feedback Scheduler for Real-Time Controller Tasks

Eker, Johan; Hagander, Per; Årzén, Karl-Erik

Published in:Control Engineering Practice

DOI:10.1016/S0967-0661(00)00086-1

2000

Link to publication

Citation for published version (APA):Eker, J., Hagander, P., & Årzén, K-E. (2000). A Feedback Scheduler for Real-Time Controller Tasks. ControlEngineering Practice, 8(12), 1369-1378. https://doi.org/10.1016/S0967-0661(00)00086-1

Total number of authors:3

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: A Feedback Scheduler for Real-Time Controller Tasks Eker

This is the final, accepted and revised manuscript of this article. Use alternative location to go to the published version. Requires subscription.

A Feedback Scheduler for Real-Time Control Tasks

Johan Eker, Per Hagander, Karl-Erik Årzén, Control Engineering Practice, Volume 8, Issue 12, pages 1369-1378

Pergamon: Alternative location: [http://dx.doi.org/10.1016/S0967-0661(00)00086-1]

Page 3: A Feedback Scheduler for Real-Time Controller Tasks Eker

In IFAC Control Engineering Practice 2000

A FEEDBACK SCHEDULER FOR REAL-TIMECONTROLLER TASKS

Johan Eker Per Hagander Karl-Erik Årzén

Department of Automatic ControlLund Institute of Technology

Box 118, S-221 00 LundSweden

Fax: +46-[0]46 13 81 18johan.eker|karlerik.arzen|[email protected]

Keywords Real-time; Feedback scheduling; Linear quadratic control; Opti-mization.

Abstract

The problem studied in this paper is how to dis-tribute computing resources over a set of real-time control loops in order to optimize the to-tal control performance. Two subproblems areinvestigated: how the control performance de-pends on the sampling interval, and how a re-cursive resource allocation optimization routinecan be designed. Linear quadratic cost functionsare used as performance indicators. Expressionsfor calculating their dependence on the sam-pling interval are given. An optimization rou-tine, called a feedback scheduler, that uses theseexpressions is designed.

1. INTRODUCTION

Control design and task scheduling are inmost cases today treated as two separate is-sues. The control community generally assumesthat the real-time platform used to implementthe control system can provide deterministic,fixed sampling periods as needed. The real-timescheduling community, similarly, assumes thatall control algorithms can be modeled as pe-riodic tasks with constant periods, hard dead-lines, and known worst case execution times.This simple model has made it possible for thecontrol community to focus on its own problemdomain without worrying how scheduling is be-

ing done, and it has released the schedulingcommunity from the need to understand howscheduling delays impact the stability and per-formance of the plant under control. From a his-torical perspective, the separated developmentof control and scheduling theories for computerbased control systems has produced many use-ful results and served its useful purpose.

Upon closer inspection it is, however, quiteclear that neither of the above assumptionsneed necessarily be true. Many of the comput-ing platforms that are commonly used to im-plement control systems, are not able to giveany deterministic guarantees. This is especiallythe case when commercial off-the-shelf operat-ing systems, e.g. Windows NT or Linux, areused. These systems are, typically, designed toachieve good average performance rather thanhigh worst-case performance. Many control al-gorithms are not periodic, e.g. internal com-bustion engine control, or they may switch be-tween a number of different fixed sampling pe-riods. Control algorithm deadlines are not al-ways hard. On the contrary, many controllersare quite robust towards variations in samplingperiod and response time. It is in many casesalso possible to compensate for the variationson-line by, e.g., recomputing the controller pa-rameters, see Nilsson (1998). It is also possi-ble to consider control systems that are able

Page 4: A Feedback Scheduler for Real-Time Controller Tasks Eker

FeedbackScheduler Sampling Rates

Desired Load

PerformanceExec. Times

Fig. 1 New sampling rates are calculated based on thedesired CPU load, the execution times of the controllers,and the performance of the controllers.

to do a tradeoff between the available compu-tation time, i.e., how long time the controllermay spend calculating the new control signal,and the control loop performance.

For more demanding applications, requiringhigher degrees of flexibility, and for situationswhere computing resources are limited, it istherefore desirable to study more integrated ap-proaches to scheduling of control algorithms.The approach taken in this paper is based ondynamic feedback from the scheduler to the con-trollers, and from the controllers to the sched-uler. The idea of feedback has been used infor-mally for a long time in scheduling algorithmsfor applications where the dynamics of the com-putation workload cannot be characterized ac-curately. The VMS operating system, for exam-ple, uses multi-level feedback queues to improvesystem throughput, and Internet protocols usefeedback to help solve the congestion problems.The idea of feedback has also been exploitedin multi-media scheduling R&D, recently, underthe title of quality of service (QoS). An applica-tion demonstrating QoS reasoning in a real-timecontrol system is found in Abdelzaher, Atkinsand Shin (1997).In this paper the goal is to schedule a set of real-time control loops in order to maximize theirtotal performance. The number of control loopsand their execution times may change over timeand hence the task schedule must be adjustedto maintain optimality and schedulability. Sincethe optimizer works in closed loop with thecontrol tasks, it is referred to as a feedbackscheduler. The feedback scheduler adjusts thecontrol loop frequencies to optimize the controlperformance while maintaining schedulability.The input signals are the performance levelsof each loop, their current execution times,and the desired workload level, see Fig. 1.Two problems are studied when designing sucha feedback scheduler. The first is to find asuitable performance index and calculate how itdepends on the sampling frequency. The secondproblem is to design an optimization routine. Itis assumed that measurements or estimates ofthe execution times and system workload areavailable from the real-time kernel at run-time.

As a performance index, a linear quadratic (LQ)

formulation is used. The controllers are statefeedback algorithms designed to minimize thisquadratic cost function. The performance indexis calculated as a function of the sampling in-terval. Given this control performance indicatoran optimization routine is designed. The opti-mization routine aims to find the control perfor-mance optimum, given a desired CPU utiliza-tion level (workload) and the execution times forthe tasks. The global cost function that shouldbe minimized consists of the sum of the costfunction of each control loop. The minimiza-tion is performed subject to a schedulabilityconstraint. The minimization of the global costfunction constitutes a nonlinear programmingproblem. The solution of this problem is facili-tated by the knowledge of the first and secondderivatives of the cost functions with respect tothe sampling rate. Expressions for the deriva-tives are calculated and used in the optimiza-tion.

Using a feedback scheduling strategy it is nowpossible to design real-time control systemsthat are more robust against uncertainties inexecution times and workload. When a controltask performs a mode change and this leadsto a change in its execution time the feedbackscheduler adjusts the sampling frequencies sothat the system remains schedulable.

Deadlines may be missed if a change in exe-cution time causes the system to overload. Insuch a situation, the feedback scheduler adjuststhe sampling rates to regain schedulability, butdeadlines may, however, still be missed. If in-stead the feedback scheduler is aware of a forth-coming mode change, it could avoid an overloadby changing the sampling rates in advance. Thiscan be dealt with by establishing a communi-cation channel between the feedback schedulerand the control tasks. The control tasks notifythe feedback scheduler, by sending a request,prior to a mode change and may not proceedwith the mode change until given permission todo so. The module that handles this is calledthe admission controller. It is also responsiblefor handling the arrival of new tasks and thetermination of old tasks. Fig. 2 shows a blockdiagram of the feedback scheduler with the ad-mission controller.

1.1 Outline

An overview of related work is given in Sec-tion 2. Section 3 defines the problem, andthe LQ-based cost function calculation are pre-sented in Section 4. Section 5 describes the de-sign of the feedback scheduler.

Page 5: A Feedback Scheduler for Real-Time Controller Tasks Eker

2. INTEGRATED CONTROL ANDSCHEDULING

In order to achieve on-line interaction betweencontrol algorithms and the scheduler a num-ber of issues must be considered. Control designmethods must take schedulability constraintsinto account. It must be possible to dynamicallyadjust task parameters, e.g., task periods, in or-der to compensate for changes in workload. Itcan also be advantageous to view the task pa-rameters adjustment strategy in the scheduleras a controller. In this section an overview isgiven of the work that has been performed inthese areas. A more detailed survey on controland scheduling can be found in Årzén, Bern-hardsson, Eker, Cervin, Nilsson, Persson andSha (1999).

2.1 Control and scheduling co-design

A prerequisite for an on-line integration of con-trol and scheduling theory is the ability to makean integrated off-line design of control algo-rithms and scheduling algorithms. Such a de-sign process should ideally allow an incorpora-tion of the availability of computing resourcesinto the control design by utilizing the resultsof scheduling theory. This is an area where rel-atively little work has been performed so far.In Seto, Lehoczky, Sha and Shin (1996) an al-gorithm was proposed that translates a systemperformance index into task sampling periods,considering schedulability among tasks runningwith pre-emptive priority scheduling. The sam-pling periods were considered as variables, andthe algorithm determined their values so thatthe overall performance was optimized subjectto the schedulability constraints. Both fixed pri-ority rate-monotonic and dynamic priority, Ear-liest Deadline First (EDF) scheduling were con-sidered. The loop cost function was heuristi-cally approximated by an exponential function.The approach was further extended in Seto,Lehoczky and Sha (1998).

A heuristic approach to optimization of sam-pling period and input-output latency subjectto performance specifications and schedulabil-ity constraints was also presented in Ryu, Hongand Saksena (1997) and Ryu and Hong (1998).The control performance was specified in termsof steady state error, overshoot, rise time, andsettling time. These performance parameterswere expressed as functions of the sampling pe-riod and the input-output latency. An iterativealgorithm was proposed for the optimization ofthese parameters subject to schedulability con-straints.

2.2 Task attribute adjustments

A key issue in any system allowing dynamicfeedback between the control algorithms andthe on-line scheduler is the ability to dynami-cally adjust task parameters. Examples of taskparameters that could be modified are periodand deadline.

In Shin and Meissner (1999) the approach inSeto, Lehoczky, Sha and Shin (1996) is ex-tended, making on-line use of the proposed off-line method for processor utilization allocation.The approach allows task period changes inmulti-processor systems. A performance indexfor the control tasks is used, weighting the im-portance of the task to the overall system, todetermine the value to the system of running agiven task at a given period.

In Buttazzo, Lipari and Abeni (1998) an elas-tic task model for periodic tasks is presented.A task may change its period within certainbounds. When this happens, the periods of theother tasks are adjusted so that the overallsystem is kept schedulable. An analogy witha linear spring is used, where the utilizationof a task is viewed as the length of a springthat has a given spring coefficient and lengthconstraints. The MART (Modification and Ad-justment of Real-time Tasks) scheduling algo-rithm (Kosugi, Takashio and Tokoro, 1994; Ko-sugi, Mitsuzawa and Tokoro, 1996; Kosugi andMoriai, 1997) also supports task period adjust-ments. MART has been extended to also handletask execution time adjustments. The systemhandles changes both in the number of periodictasks and in the task timing attributes. Beforeaccepting a change request the system analyzesthe schedulability of all tasks. If needed, it ad-justs the period and/or execution time of thetasks to keep them schedulable with the ratemonotonic algorithm.

2.3 Feedback scheduling

An on-line scheduler that dynamically adjuststask attributes can be viewed as a controller.Important issues that must be decided are whatthe right control signals, measurement signals,and set-points are, what the correct controlstructure should be, and which process modelthat may be used.

So far, very little has been done in the areaof real-time feedback scheduling. A notable ex-ception is presented in Stankovic, Lu, Son andTao (1999), where a PID controller is used asan on-line scheduler. The measurement signal(the controlled variable) is the deadline missratio for the tasks, and the control signal isthe requested CPU utilization. Changes in the

Page 6: A Feedback Scheduler for Real-Time Controller Tasks Eker

requested CPU are effectuated by two mecha-nisms (actuators). An admission controller isused to control the flow of workload into the sys-tem, and a service level controller is used to ad-just the workload inside the system. The latteris done by changing between different versionsof the tasks with different execution time de-mands. A simple liquid tank model is used asan approximation of the scheduling system.

Using a controller approach of the above kind,it is important to be able to measure the appro-priate signals on-line, e.g., to be able to measurethe deadline miss ratio, the CPU utilization, orthe task execution times.

An event feedback scheduler is proposed in Zhaoand Zheng (1999). Several control loops sharea CPU, and only one controller may be activeat each time instant. The strategy used is toactivate the controller connected to the plantwith the largest error. Similar ideas are foundin Årzén (1999), which suggests an event-basedPID controller that only executes if the controlerror is larger than a specified threshold value.

Execution

Requests

Load

EventsTask Task Task

KernelResourceallocations

Admission

statistics

reference

Feedbackscheduler

controller

Fig. 2 The real-time kernel is connected in a feedbackloop with the feedback scheduler and the admissioncontroller.

3. PROBLEM STATEMENT

Consider a control system where several controlloops share the same CPU. Let the executiontimes of all tasks and the system workload beavailable from the real-time kernel at all times.Furthermore, associate each controller with afunction, which indicates its performance. Theexecution times, the number of tasks, and thedesired workload may vary over time. The aimof the feedback scheduler is to optimize thetotal control performance, while keeping theworkload at the desired level.

Two separate modules are used, see Fig. 2. Thefeedback scheduler adjusts the sampling inter-vals to control the workload. The workload ref-erence is calculated by the admission controller

which contains high-level logic for coordinatingtasks.

The tasks and the feedback scheduler commu-nicate using requests and events. A task cansend a request for more computing resourcesand the scheduler may grant this by replyingwith the appropriate event. The kernel managesthe tasks at the low level, i.e. task dispatch-ing, etc. The feedback scheduler gets executionstatistics, such as the actual execution times ofthe tasks, and the system workload from thekernel. This information is then used to calcu-late how CPU resources should be allocated inan optimal fashion.

Let the number of tasks on the system ben, and let each task execute with a samplinginterval hi (task period) and have the executiontime Ci. Each task is associated with a costfunction Ji(hi), which gives the control cost as afunction of sampling interval hi. The followingoptimization problem may now be formulated

minimize J =n∑

i=1

Ji(hi), (1)

subject to the constraint∑n

i=1 Ci/hi ≤ Uref ,where Uref is the desired utilization level.

4. COST FUNCTIONS

In this section the LQ cost function and itsderivatives with respect to the sampling in-terval are calculated. These functions will beused in the feedback scheduler algorithm, as de-scribed in Section 5.

Let the system be given by the linear stochasticdifferential equation

dx =Axdt+Budt + dvc. (2)

where A and B are matrices and vc is a Wienerprocess with the incremental covariance R1cdt.A continous stochastic system description isused as the goal is to study the cost of samplingthe system at different rates. The sampledsystem is given by

x(kh+ h) =ΦΦΦx(kh) + ΓΓΓu(kh) + v(kh),

where ΦΦΦ = eAh, ΓΓΓ = ∫ h0 eAsdsB, and v(kh) is

white noise with the following property:

Ev(kh)vT(kh) = R1(h) =∫ h

0eAτR1ceATτ dτ .

(3)

Page 7: A Feedback Scheduler for Real-Time Controller Tasks Eker

The cost function for the controller is chosen as

J(h) = 1h

E∫ h

0[ xT(t) uT(t) ]Qc

[x(t)u(t)

]dt,

where

Qc =[

Q1c Q2c

QT2c Q3c

].

The cost per time unit for the discrete LQ-controller is given as:

J = E( 1Nh

∫ Nh

0[xT(t) uT(t) ]Qc

[x(t)u(t)

])

= E( 1Nh

N∑k=0

∫ kh+h

kh[xT(t) uT(t) ]Qc

[x(t)u(t)

]dt)

When time goes to infinity, limN→∞ ,the influ-ence from the initial conditions decreases, andthe cost may be written as

J = E(1h

∫ h

0[x(t) u(t) ]Qc

[x(t)u(t)

]dt)

This means that only the cost in stationarityis regarded, and that the cost is scaled by thetime horizon, i.e. the sampling interval h. Thecontroller u = −Lx(t) that minimizes the cost isgiven by solving the stationary Riccati equationwith respect to the matrices S and L.[

S+ LTGL LTGGL G

]=[ΦΦΦT

ΓΓΓT

]S [ΦΦΦ ΓΓΓ ] +Qd

(4)

where G = ΓΓΓTSΓΓΓ +Q3d, and

Qd =[

Q1d Q2d

QT2d Q3d

]=∫ h

0eΣΣΣT tQceΣΣΣtdt,

ΣΣΣ =[

A B0 0

] (5)

The minimal value of J is given by Åströmand Wittenmark (1997) and Gustafsson andHagander (1991) as:

min J(h) =1h(trSR1 + J), where

J = tr(Q1c

∫ h

0R1(τ )dτ )

In order to use the cost function in the optimiza-tion it is useful to know the derivatives withrespect to the sampling period.

Theorem 1The first derivative of J is given as

dJdh

=1h(tr dS

dhR1 + trS

dR1

dh+ dJ

dh) −

1h2 (trSR1 + J)

where

dSdh

=(ΦΦΦ − ΓΓΓ L)T dSdh(ΦΦΦ − ΓΓΓL) + W,

W =[ΦΦΦ − ΓΓΓL

−L

]T

Qc

[ΦΦΦ − ΓΓΓL

−L

]+

{(ΦΦΦ − ΓΓΓL)TAT − LTBT}S(ΦΦΦ − ΓΓΓL) +(ΦΦΦ − ΓΓΓL)TS{A(ΦΦΦ − ΓΓΓL) − BL},

The matrix R1 is calculated using Lemma 1in the appendix and derivative of R1 is givendirectly from Eq. 3.

dR1

dh=eAhR1ceATh,

dJdh

=trQ1cR1

See Appendix A for the proof. Expression for thesecond derivative of the cost functions is alsogiven there.

Example 1Consider the linearized equations for a pendu-

lum:

dx =[

0 1

αω20 −d

]xdt+

[0

α b

]udt+ dvc

y = [1 0 ]x, R1c =[

0 0

0 ω40

]The natural frequency is ω0, the damping d =2ζ ω0, with ζ = 0.2, and b = ω0/9.81. If α = 1,the equations describe the pendulum in theupright position, and if α = −1 they describethe pendulum in the downward position. Theincremental covariance of vc is R1cdt, whichcorresponds to a disturbance on the controlsignal.

The cost functions J for the closed loop controlof the inverted pendulum as a function of thesampling interval is shown in Fig. 3. The cor-responding function for the stable pendulum isshown in Fig. 4. Fig. 4 clearly demonstratesthat faster sampling not necessarily gives bettercontrol performance. Sampling the pendulum asslowly as this is however unrealistic. The rule ofthumb from Åström and Wittenmark (1997) isto choose the sampling rate as ω0h � 0.2− 0.6.The time scale for Fig. 4 is out of bounds for

Page 8: A Feedback Scheduler for Real-Time Controller Tasks Eker

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.50

5000

10000

15000

Sampling Interval [s]

Cost

Fig. 3 The cost Ji(h) as a function of the sampling intervalfor the inverted pendulum. The plot shows the graph forω 0 = 3.14(full), 3.77(dot-dashed), and 4.08(dashed).

0 0.5 1 1.5 2 2.5 3 3.5 40

200

400

600

800

1000

1200

1400

1600

1800

Sampling Interval [s]

Cost

Fig. 4 The cost Ji(h) as a function of the samplinginterval for the pendulum. The plot shows the graphfor ω 0 = 3.14(full), 3.77(dot-dashed), and 4.08(dashed).The peaks are due to the resonance frequencies of thependulum.

any practical use for the current application. Itdoes however give an indication of what couldhappen in a system with a high frequency me-chanical resonance.

5. A FEEDBACK SCHEDULER

In this section a feedback scheduler, see Fig. 2,for a class of control systems with convex costfunctions is proposed. Standard nonlinear pro-gramming results are used as a starting pointfor the feedback scheduler design. First, an algo-rithm, using the cost functions presented in theprevious section is designed, and then an ap-proximate, less computation-intense algorithmis presented. Simulation results for a systemwith three control loops are also given.

5.1 Static Optimization

For the class of systems for which the cost func-tions are convex, ordinary optimization theory,e.g. steepest decent search or constraint New-ton, may be applied. The optimization criterionin Eq. (1) has nonlinear constraints and is firstrewritten. By optimizing over the frequenciesinstead of the sampling intervals, the followingoptimization problem is given:

minf

V ( f ) =n∑

i=1

Ji(1/ f i),

subject to cTf ≤ Uref

f =[ f1, . . . , fn]T

The Kuhn-Tucker conditions, see for exam-ple (Fletcher, 1987), give that if f = [ f1, . . . , f n]Tis an optimal solution then:

Vf (f) + λc = 0

λ [Uref − cTf] = 0,λ ≥ 0

(6)

where the column vector Vf is the gradient,c = [C1, . . . , Cn]T, and λ is the Lagrange mul-tiplier. Since Vi( f i) = Ji(1/ f i) = Ji(hi), thederivative of Vi is dVi

fi= −h2 dJi

hi. This gives

V Tf = [ dVi

f1, . . . , dVi

fn] = [−h2

1dJih1

, . . . ,−hTn

dJnhn].

5.2 Recursive Optimization

Since changes in the computer load Uref andthe execution times C change the optimizationproblem, they need to be resolved at each stepin time. In principle, one can repeat the solu-tion to the static optimization problem at eachstep in time. However, instead of looking for adirect solution a recursive algorithm will be con-sidered. Assume that there is a solution f (k), atstep k, which is optimal or close to optimal. Nowa recursive algorithm to compute new values forf and λ will be constructed. Let the execution

schedulerrefU (k)

∆Feedback

(k)c(k+1)f

Fig. 5 The feedback scheduler calculates new samplingfrequencies to accomodate for changes in the executiontimes C or in the desired workload level.

time vector C(k) be time-varying. A control loopthat adjusts the sampling frequencies so thatthe control performance cost is kept at the opti-

Page 9: A Feedback Scheduler for Real-Time Controller Tasks Eker

mum is to be designed, see Fig. 5. Let

f(k+ 1) =f(k) + ∆f(k)λ(k+ 1) =λ(k) + ∆λ(k)c(k+ 1) =c(k) + ∆c(k)

Assume that λ > 0, i.e. that the CPU constraintis active. Linearization of Eq. (7) around theoptimum gives

Vf + Vf f ∆f + (λ + ∆λ)(c+ ∆c) = 0

(cT + ∆cT)(f+ ∆f) = Uref

If the quadratic delta terms are disregarded[Vf f c

cT 0

] [ ∆f

∆λ

]=[−(Vf + λc) − λ ∆c

Uref − cTf− ∆cTf

]

is obtained. Now the increments in f and λ aregiven as[ ∆f

∆λ

]=[

Vf f ccT 0

]−1 [ −(Vf + λc)Uref − cTf− ∆cTf

](7)

A solution exists if Vf f is positive (or negative)definite and c �= 0. Note that the matrix Vf f isdiagonal.

Vf f = diak([V2VV f 2

1. . . V2V

V f 2n

,])

Thus, there is a solution to Eq. (8) if V2VV f 2

i> 0, ∀i.

Remark It can be shown that this optimiza-tion routine corresponds to constrained Newtonoptimization, see for example Gill, Murray andWright (1981). The algorithm has mostly beeninvestigated through simulation and it seemsvery stable. In general a constrained Newtonalgorithm would not necessarily converge, butthere may be reasonable assumptions that couldguarantee the convergence seen in simulations.

Example 2A single CPU-system is used to control three

inverted pendulums of different lengths. Everypendulum is controlled by one LQ-controller,designed using the same weight matrix Qc as inExample 1. Each control loop has an executiontime Ci and a sampling frequency = f i. Let theinitial sampling frequencies be f 0

i . One of thetasks operates in two modes with very differentexecution times. The feedback scheduler adjuststhe sampling frequencies for the tasks, so thatthe total control performance is optimized, giventhe current execution times and the workload

reference. The workload reference is given bythe admission controller.

Fig. 6 shows some plots from a simulation,where execution times, sampling frequenciesand load are plotted as functions of the iter-ation steps. From the initial frequencies f0 =[4, 4.5, 5], an optimal solution is found after 7-8iterations. At step 15, Task #2 sends a requestto the admission controller for more executiontime, due to a forthcoming mode change. The ad-mission controller must first lower the workloadreference, before any task is allowed to increaseits execution time, in order to avoid overload.

The new workload reference at step 15 is cho-sen so that there will enough room to allowtask#2 to increase its execution time. The sizeof the CPU reserved for change in task#2 isbased on the current sampling rates. In thisexample C1 = 0.04, C2 = 0.05, C3 = 0.07 andthe frequencies at step 14 are f1 = 5.84, f2 =6.50, f3 = 6.31. If task#2 doubles its executiontime, the workload will increase with approxi-mate 30%. The workload reference is thereforeset to 0.7 to prevent overload. At step 20, theactual workload is sufficiently near the refer-ence and the admission controller grants therequest from Task #2, which then immediatelyperforms a mode change. At the same timethe admission controller changes the workloadreference back to 1. The final frequencies aref = [ 4.822 4.378 5.276 ].

5.3 An approximate version

The feedback scheduling algorithm proposedabove, includes solving both Riccati and Lya-punov equations on-line. This is expensive, anda computationally cheaper algorithm is desir-able. From Fig. 3 it seems that the cost func-tions could be approximated as quadratic func-tions of the sampling interval h. The relationbetween performance and sampling rates forLQG controllers was also discussed in Åström(1963), where it was shown that the cost is in-deed quadratic for small sampling intervals.

Let the approximative cost J(h) be defined as

J(h) = α + β h2.

By choosing a suitable nominal sampling in-terval h0, and using J(h0) = J(h0), Jh(h0) =Jh(h0) the coefficients are given as:

β = Jh(h0)/(2h0)α = J(h0) − β h2

0

The following approximate cost function and

Page 10: A Feedback Scheduler for Real-Time Controller Tasks Eker

5 10 15 20 25 30 350

0.05

0.1

Execution Times

5 10 15 20 25 30 35

4

6

8Sampling Frequencies

5 10 15 20 25 30 35

0.7

0.8

0.9

1

1.1Load

5 10 15 20 25 30 354000

5000

6000Cost

Fig. 6 Plots from Example 2. The top plot shows howthe execution time for task #2 doubles at step 20.The second plot from the top shows how the samplingrates are adjusted by the feedback scheduler (Task #1–full, Task #2–dash-dotted, Task#3–dashed). The loadplot shows how the workload reference (dash-dotted)goes from 100% to 70% at step 15, and back to 100%at step 20. The full line is the actual workload. Thebottom plot shows the sum of the cost functions, i.e.the optimization criterion.

derivate are then obtained:

V(f) =n∑i

α i + β i/ f 2

Vf ( f ) = −2 [ β 1/ f 3, . . . , β n/ f 3 ]TVf f = 6 diag [ β 1/ f 4, . . . , β n/ f 4 ]

Using these approximate functions instead ofthe exact ones will give a much less computationintense problem.

The optimal solution is obtained from Eq. (7),and by inserting the approximative expressionfor Vf

2β i/ f 3i = λ Ci ; f i = (2β i/(λ Ci))1/3

; U =n∑1

Ci f i =n∑1

Ci(2β i/(λ Ci))1/3

is obtained. Now, an explicit expression for theoptimal solution is given by{

λ = (1/U∑n

1 C2/3i (2β i)1/3)3

f i = (2β i/(λ Ci))1/3(8)

Example 2 continuedAgain, consider the system with three pendu-lum controllers. From the explicit analytical ex-pressions in Eq. (9) the following frequenciesare calculated:

f = [ 4.866 4.347 5.29 ]

Note that these frequencies are very close tothose previously calculated in Example 2. Thisexample shows that the approximative costfunctions are sufficient to achieve good opti-mization results for some processes.

A similar approximative version can be de-signed for cost functions that are approximatelylinear in the sampling interval h, i.e. J = α +β h. For example, for short sampling intervalsin Fig. 4 the cost is almost linear.

Comment 1The rate of the feedback scheduler, and hencethe rate of the changes to the sampling frequen-cies, is assumed to be much slower than thesampling frequencies. If the sampling frequen-cies are adjusted at a too high rate there will beproblems with large jitter and possibly stability.

6. CONCLUSION

In this paper a novel feedback scheduler hasbeen proposed. For a class of control systemswith convex cost functions, the feedback sched-uler calculates the optimal resource allocationpattern. The calculation of cost functions andtheir dependence on sampling intervals hasbeen investigated. Formulaes for calculating thecost functions and their derivatives have beenpresented. The feedback scheduler is demon-strated on a three control loops system, and theresult is promising. The algorithm is, however,complex and quite computation-intense. The ex-ecution time needed for solving the optimizationproblem would probably exceed the executiontimes of most control tasks. By instead usingapproximative cost functions good results maybe achieved at much less computational cost.

Many questions have been left out in this pa-per’s discussion on feedback scheduling. Onething that has been neglected is what happensduring the transient phase, when a samplingrate is changed. This problem must be treateddifferently depending on the used scheduling al-gorithm, e.g EDF or RMS.

Using a feedback scheduler approach it wouldbe possible to design real-time, plug-and-playcontrol systems. Tasks and resources are al-lowed to change and the system adapts on-line.

Page 11: A Feedback Scheduler for Real-Time Controller Tasks Eker

REFERENCES

Abdelzaher, T., Atkins, E. and Shin, K.: 1997,QoS negotiation in real-time systems, and itsapplication to flight control, Proceedings of the18th IEEE Real-Time Systems Symposium,San Francisco, CA, USA, pp. 228–238.

Årzén, K.-E.: 1999, A simple event based PIDcontroller, Proceedings of the 14th WorldCongress of IFAC, Vol. Q, IFAC, Beijing, P.R.China, pp. 423–428.

Årzén, K.-E., Bernhardsson, B., Eker, J., Cervin,A., Nilsson, K., Persson, P. and Sha, L.: 1999,Integrated control and scheduling, TechnicalReport ISRN LUTFD2/TFRT–7586–SE, De-partment of Automatic Control, Lund, Swe-den.

Åström, K. J.: 1963, On the choice of samplingrates in optimal linear systems, Technical Re-port RJ-243, San José Research Laboratory,IBM, San José, California.

Åström, K. J. and Wittenmark, B.: 1997,Computer-Controlled Systems, third edn,Prentice Hall, Englewood Cliffs, New Jersey,USA.

Buttazzo, G., Lipari, G. and Abeni, L.: 1998,Elastic task model for adaptive rate control,Proceedings of the 19th IEEE Real-Time Sys-tems Symposium, Madrid, Spain.

Fletcher, R.: 1987, Practical Methods of Opti-mization, second edn, Wiley, UK.

Gill, P. E., Murray, W. and Wright, M. H.: 1981,Practical Optimization, Academic Press, UK.

Gustafsson, K. and Hagander, P.: 1991,Discrete-time LQG with cross-terms in theloss function and the noise description,Technical Report TFRT-7475, Departmentof Automatic Control, Lund Institute ofTechnology, Lund, Sweden.

Kosugi, N., Mitsuzawa, A. and Tokoro, M.: 1996,Importance-based scheduling for predictablereal-time systems using MART, Proceedingsof the 4th Int. Workshop on Parallel andDistributed Systems, Honolulu, Hawaii, USA,pp. 95–100.

Kosugi, N. and Moriai, S.: 1997, Dynamicscheduling for real-time threads by periodadjustment, Proceedings of the First WorldCongress on Systems Simulation, Singapore,pp. 402–406.

Kosugi, N., Takashio, K. and Tokoro, M.: 1994,Modification and adjustment of real-timetasks with rate monotonic scheduling algo-rithm, Proceedings of the Second Workshopon Parallel and Distributed Systems, Cancun,Mexico, pp. 98–103.

Nilsson, J.: 1998, Real-Time Control Sys-tems with Delays, PhD thesis, ISRNLUTFD2/TFRT–1049–SE, Department ofAutomatic Control, Lund Institute of Tech-nology, Lund, Sweden.

Ryu, M. and Hong, S.: 1998, Toward auto-matic synthesis of schedulable real-time con-trollers, Integrated Computer-Aided Engi-neering 5(3), 261–277.

Ryu, M., Hong, S. and Saksena, M.: 1997,Streamlining real-time controller design:From performance specifications to end-to-end timing constraints, Proceedings of theThird IEEE Real-Time Technology and Ap-plications Symposium, Montreol, Canada,pp. 91–99.

Seto, D., Lehoczky, J. P. and Sha, L.: 1998,Task period selection and schedulabilityin real-time systems, Proceedings of the19th IEEE Real-Time Systems Symposium,Madrid, Spain, pp. 188–198.

Seto, D., Lehoczky, J. P., Sha, L. and Shin, K. G.:1996, On task schedulability in real-time con-trol systems, Proceedings of the 17th IEEEReal-Time Systems Symposium, Washington,DC, USA, pp. 13–21.

Shin, K. G. and Meissner, C. L.: 1999, Adap-tation of control system performance by taskreallocation and period modification, Proceed-ings of the 11th Euromicro Conference onReal-Time Systems, York, UK, pp. 29–36.

Stankovic, J. A., Lu, C., Son, S. H. and Tao, G.:1999, The case for feedback control real-timescheduling, Proceedings of the 11th Euromi-cro Conference on Real-Time Systems, York,UK, pp. 11–20.

van Loan, C.: 1978, Computing integral involv-ing the matrix exponential, IEEE Transac-tions on Automatic Control (AC–23), 395–404.

Zhao, Q. C. and Zheng, D. Z.: 1999, Stablereal-time scheduling of a class of pertubedhds, Proceedings of the 14th World Congressof IFAC, Vol. J, IFAC, Beijing, P.R. China,pp. 91–96.

Page 12: A Feedback Scheduler for Real-Time Controller Tasks Eker

APPENDIX A – PROOF AND CONTINUATION OF THEOREM 1

Proof To find out how J depends on the sampling interval it remains to investigate S. Eq. (5) isdifferentiated with respect to h: [

0 0dLdh 0

]T [S 0

0 G

] [I 0

L I

]+[

I 0L I

]T [ dSdh 0

0 dGdh

] [I 0L I

]+[

I 0

L I

]T [S 0

0 G

] [0 0dLdh 0

]=

dQd

dh+[

dΦΦΦT

dhdΓΓΓT

dh

]S [ΦΦΦ ΓΓΓ ] +

[ΦΦΦT

ΓΓΓT

]dSdh[ΦΦΦ ΓΓΓ ] +

[ΦΦΦT

ΓΓΓT

]S [ dΦΦΦ

dhdΓΓΓdh ]

Rearranging the terms yields[0 dLT

dh G0 0

]+[ dS

dh 0

0 dGdh

]+[

0 0

G dLdh 0

]=[ΦΦΦT − LTΓΓΓT

ΓΓΓT

]dSdh[ΦΦΦ − ΓΓΓL ΓΓΓ ] +

[I 0−L I

]T

W[

I 0−L I

](9)

where the block matrix W is defined as

W = dQd

dh+[

dΦΦΦT

dhdΓΓΓT

dh

]S [ΦΦΦ ΓΓΓ ] +

[ΦΦΦT

ΓΓΓT

]S [ dΦΦΦ

dhdΓΓΓdh ]

The following Lyapunov equations for dSdh and dL

dh are obtained by extracting elements from Eq. (10),and introducing ΨΨΨ = (ΦΦΦ − ΓΓΓL).

dSdh

= ΨΨΨT dSdh

ΨΨΨ + [ I −LT ] W[

I−L

]G

dLdh

= ΓΓΓT dSdh

ΨΨΨ + [ 0 I ] W[

I−L

]

The derivative dLdh is needed later for the calculation of the second derivative of J. To calculate W

formulas for dQddh , dΦΦΦ

dt , and dΓΓΓdh are needed. Since[ΦΦΦ ΓΓΓ

0 I

]= exp

([A B0 0

]h)= eΣΣΣh

and Qddh is given from Eq.uation (6) it is straightforward to calculate

dΦΦΦdh

= AΦΦΦ,dΓΓΓdh

=AΓΓΓ +B,dQd

dh= eΣΣΣT hQceΣΣΣh

W can now be written as

W =[ΦΦΦ ΓΓΓ

0 I

]T

Qc

[ΦΦΦ ΓΓΓ0 I

]+

[AΦΦΦ AΓΓΓ + B ]T S [ΦΦΦ ΓΓΓ ] + [ΦΦΦ ΓΓΓ ]T S [AΦΦΦ AΓΓΓ +B ]and now let W be

W = [ I −LT ] W[

I−L

]=[ ΨΨΨ−L

]T

Qc

[ ΨΨΨ−L

]+

{ΨΨΨTAT − LTBT}SΨΨΨ +ΨΨΨTS{AΨΨΨ −BL}.

Page 13: A Feedback Scheduler for Real-Time Controller Tasks Eker

which now leads to the following expression, and dJdh may now be calculated.

dSdh

= ΨΨΨT dSdh

ΨΨΨ +W

GdLdh

= ΓΓΓT dSdh

ΨΨΨ + [ΓΓΓT I ]Qc

[ ΨΨΨ−L

]+ ΓΓΓTS(AΨΨΨ −BL) + (AΓΓΓ +B)TSΨΨΨ

Theorem 2The second derivative is given by

d2Jdh2 =

1h

{tr(d2S

dh2 R1) + 2tr(dSdh

R1

dh) + tr(S d2R1

dh2 ) +d2Jdh2

}− 2

h2

{tr(dS

dhR1) + tr(SR1

dh) + dJ

dh

}+ 2

h3

{tr(SR1) + J

}where

d2Sdh2 =ΨΨΨT d2S

dh2 ΨΨΨ +W2, W2 = dΨΨΨT

dhdSdh

ΨΨΨ +ΨΨΨT dSdh

dΨΨΨdh

+ dWdh

dΨΨΨdh

=AΦΦΦ − (AΓΓΓ + B)L− ΓΓΓdLdh

dWdh

=[ dΨΨΨ

dh

− dLdh

]T

Qc

[ ΨΨΨ−L

]+[ ΨΨΨ−L

]T

Qc

[ dΨΨΨdh

− dLdh

]+

{ΨΨΨTAT − LTBT}(dS

dhΨΨΨ + S

dΨΨΨdh) +

(ΨΨΨT dSdh

+ dΨΨΨT

dhS){AΨΨΨ − BL

} +{dΨΨΨT

dhAT − dLT

dhBT}SΨΨΨ +ΨΨΨTS

{A

dΨΨΨdh

− BdLdh

}

d2Jdh2 =tr(Q1c

dR1

dh), d2R1

dh2 =AΦΦΦR1cΦΦΦT +ΦΦΦR1cATΦΦΦT

Proof Proven with similar techniques as Theorem 1.

Lemma 1The integral ∫ t

0eAτ QeATτ dτ

is calculated using the following equations taken from van Loan (1978). Consider the linear system[x1

x2

]=[−A Q

0 AT

] [x1

x2

], (10)

which has the following solution[x1(t)x2(t)

]= exp(

[−A Q0 AT

]t)[

x1(0)x2(0)

]If [ΨΨΨ11 ΨΨΨ12

ΨΨΨ21 ΨΨΨ22

]= exp(

[−A Q0 AT

]t)

Page 14: A Feedback Scheduler for Real-Time Controller Tasks Eker

then

x1(t) = ΨΨΨ11x1(0) +ΨΨΨ12x2(0)x2(t) = ΨΨΨ21x1(0) +ΨΨΨ22x2(0)

An alternative way of solving Eq. (11) is

x2(t) = eATtx2(0) ; x1(t) = −Ax1(t) +QeATtx2(0)

; x1(t) = e−Atx1(0) + e−At∫ t

0eAτQeATτ dτ x2(0)

Identification of the terms from the different solutions now gives

I(t) =∫ t

0eAτQeATτ dτ = ΨΨΨT

22ΨΨΨ12,

which concludes the lemma.

CommentThe double integral

∫ t0 I(τ )dτ may be calculated in a similar fashion by extending the equations

above and using the following system x1

x2

x3

=−A I 0

0 −A Q0 0 AT

x1

x2

x3

.