Preemptive scheduling

Networked Embedded Control System
- Integration of control and computing
Moonju Park
Dept. of Computer Science & Engineering
University of Incheon
1
Introduction

Challenges in embedded systems design
• Time to market puts pressure on design time
• The increased complexity (# of components/lines of code, hetereogeneity,
distributed/networked) demands increased system design productivity
• Quality of new predictable, dependable designs has to improve.
• Moving from feasible to optimal systems requires new radical design
processes and tools.

Control system constitutes an important subclass of embedded
computing systems.
Environmental change:
Networked Embedded Systems
• Embedded systems are
becoming increasingly
networked
• Controller-area-networks
(CAN) bus in automobiles
• Services in large buildings
are now run across networks
• e.g. heating, lighting, security
Control view of NECS
Plant
Node
Node
Actuating
Sensing
Actuating
Sensing
Network
Controller
4
Control systems in computing
system’s perspective

Due to economic considerations, in spite of the fast development of
the computing hardware, embedded systems are resource
constrained
• Limitations on: speed, memory size, communication bandwidth, etc.
• Use of additional resource (CPU, RAM) is not economically justified.
• Cost favors general-purpose computing components over specially designed
hardware and software.

Quality of control (QoC) not only depends on the control theoretic
methods but also efficient management of resources.
• The key to manage resources is “scheduling” resources.
• Conventional design of control systems does not consider resource scheduling.
• Resulting in “implementation-aware control systems.”
5
Computing systems in control
system’s perspective

Computing systems (H/W & S/W) are inherently control systems.
• Computing systems are designed with assumptions, so there are uncertainties in
resource utilization that affect the performance.
• Programs’ execution time
• Users’ requests
• Input data
• Etc.
• Regarding complex computing systems as controlled dynamics with defined error
terms.
• Use of feedback control method to computing systems can increase the flexibility.
• Virtually any of computing applications can be considered.
6
Co-Design of Control and
Scheduling

Given a set of processes to be controlled and a computer with
limited computational resource, design a set of controllers and
schedule them as real-time tasks such that the overall control
performance is optimized.
• K-E. Årzén & A. Cervin. Control and embedded computing: survey of research
directions.
Uni-processor case.

•
Alternative view
• Design and schedule a set of controllers such that the least expensive
implementation platform can be used while still meeting the performance
specifications.
7
Control of computing systems

Conventional approach
• Generation of static schedule
– Problem
• High complexity – longer design time
• Longer response time
• Hard to use in general-purpose computers
• Use of periodic task model
– Problem
• Low utilization due to polling
• Complexity in programming due to resource
scheduling
Applying control theory to
scheduling

Feedback controlled scheduling system
e.g. PID control
Feedback Controlled EDF
Problem: Only applicable to control relative delay
Applying control theory to
computing systems - Example

Web-based applications
• Web Application Server or HTTP server
•
provides services upon requests from network
Users expect real-time response from server
11
Control of dynamic computing
system
Utilization bound for non-periodic tasks:

Implementation: Apache server on Linux (AMD-based PC), HTTP 1.1
From “Schedulability Analysis and Utilization Bounds for Highly Scalable Real-Time Services” by T.F. Abdelzaher and C. Lu,
presented at RTAS 2001
Implementation-aware control
- effects of computing system


A set of digital control loops
Each controller is realized as a separate period task
• The primary goal of co-design approaches becomes optimizing
QoC (Quality of Control) under CPU resource constraints
- maximize
Quality of control
- subject to
Schedulability
• Optimize sampling period, input-output latency subject to performance
specification and schedulability.
13
Effects of sampling period

Sampling frequency affects the system performance
• High frequency  high control performance, but high network utilization  Less
•


number of controllers  high cost
Low frequency  low network utilization and low cost, but low control
performance
The upper bound of sampling period
• Sampling period guaranteeing the stability of the system
• Stability constraint
The lower bound of sampling period
• Scheduling period from schedulability constraint
14
Control loop timing


Main parts of control loop
• Data collection
• Control algorithm computation
• Output transmission
Timing constraints
• Sampling period
• I/O latency (control delay)
• Though sampling frequency at sensor node is fixed, sampling
period at controller may have jitter depending on
implementations
• Scheduling theory can be used to analyze the time variations
and delays in control loops.
15
Example

Three control tasks
• T1=12ms, T2=8ms, T3=5ms
• Control loop
t=current time
LOOP
END
A/D conversion
ControlAlgorithmExecution
D/A conversion
t=t+h
WaitUntil(t)
• Priorities are given rate-monotonic.
• Execution time is 2ms.
16
Implementation awareness
Preemptive scheduling
T3
T2
T1
I/O latency
Sampling period
Non-preemptive scheduling
Sampling period
T3
T2
T1
I/O latency
Sampling period
17
Preemptive vs. non-preemptive
Preemptive scheduling
• Responsiveness
• Favor high priority tasks
• (generally) Higher utilization
 Non-preemptive scheduling
• Introduce blocking time
• (generally) Lower utilization
• Shorter I/O latency  Control applications’

preference

It is hard to say which one is better
18
Application of computing to
control
• Networked
Embedded Control
System (NECS)
• Feedback control
system wherein the
control loops are
closed through RTN
• Aviation system,
automotive system,
surveillance system,
etc
Networked Control Systems

Competing shared network
• Network bandwidth = mi/hi
• mi = Tc + Tca + Tsc
•
•
•
•
Hi = Transmission period of each control system
Tc : Computation time
Tca : Controller to actuator transmission time
Tsc : Sensor to controller transmission time
mi scheduling


bound
i 1 hi
n
20
Preemptiveness revisited
(short execution time, long network delay)
Preemptive scheduling
Tsc
Tc
(Network is non-preemptive)
Tca
Tsc
Tc
Tca
Error in previous works
Non-preemptive scheduling
Tsc
Tc
Tca
Tsc
Tc
Tca
Error in previous works
21
Preemptiveness revisited
(long execution time)
Preemptive scheduling
Tsc
Tc
Tsc
Tca
Tc
Tca
Higher priority
(Network is non-preemptive)
I/O latency
Non-preemptive scheduling
Tsc
Tca
Tc
Tsc
Tc
Tca
I/O latency
22
Control approach - compensation

Develop compensation method for jitter
• Building up control functions for irregular
•
sampling interval
Offline calculation + online control
w/o compensation
With compensation
23
Scheduling approach

Use of relative deadline different from
period
Jitter is reduced

Drawbacks
• Analysis is complex.
• There can be utilization loss.
24
Use of non-preemptive scheduling

Utilization can be (virtually) arbitrarily
small
• Example:
1 (C1  10, T1  10,000)  2 (C2  2T1  2C1  1, T2 )
19991
0 10
10000
20000
T2  ∞
25
Thread-X package

Dual priority scheme
• Two fixed priorities are assigned to a task.
• Priority
• Threshold: run-time priority
• Only tasks with priority higher than the threshold
of the currently running tasks can preempt.
It can achieve higher utilization than
premptive and non-preemptive scheduling
 Threshold calculation requires complex
calculation – done offline (design time)

26
Quantum-based fixed priority
scheduling

Combination of priority-based and
quantum-based scheduling
• Enhances utilization
• Adopts non-preemptiveness in preemptive
•
scheduling
Can be easily implemented on generalpurpose computers
Quantum-based scheduling vs.
Thread-X
Achieves higher utilization than Thread-X
 Shorter period can be employed
Reducing power consumption

Energy-limited variable voltage microprocessor on which N
independent control tasks run concurrently.
29
Voltage scaling

System Model
• Nominal execution time Ci, sampling period hi
Ci
 h 
i
•  is normalized processor speed

Energy Model
E ( ) ~  2

~ f
f ~V
Dynamic voltage scaling can be employed to reduce the
power consumption.
• By lowering the voltage, the processor can run slowly.
30
Idea of DVS

Sampling period = 50ms, Computation time = 10ms
10ms
50ms
P ~ 3.52 10  122.5
P ~ 0.7 2  50  24.5
50ms
31
Low-power control

Find a balanced engineering solution for a
control system.
• Shorter sampling period  Higher control
•

performance, Higher power consumption
Longer sampling period  Poorer control
performance, Lower power consumption
Work in progress currently
32
Conclusion and Future works

Integration of control and scheduling is an emerging field of
research.
• Application of control theory to computing systems.
• Design of implementation-aware control systems.

Future research directions
• Control perspective
• Event-driven control
• Dynamic models of computing systems
• Modeling of embedded control systems
• Computing perspective
•
•
•
•
Event-driven control
Providing temporal determinism of control tasks
Supporting tools development
Practical implementation
33