Minimizing Code Size and Guaranteeing Real-Time Requirements
Download
Report
Transcript Minimizing Code Size and Guaranteeing Real-Time Requirements
Embedded System Design Framework for
Minimizing Code Size and
Guaranteeing Real-Time Requirements
Insik Shin, Insup Lee, & Sang Lyul Min
CIS, Penn, USA
CSE, SNU, KOREA
Agenda
Background
Period Calibration Method (PCM)
Code size reduction technique
Design framework overview
Optimization problem formulation
Heuristic solutions and evaluations
Conclusion
2
Period Calibration Method (PCM)
Design methodology that transforms realtime system requirements into real-time
task scheduling parameters
Example
Drawback : it may not generate
schedulable solutions
R. Gerber et al. “Guaranteeing End-to-End Timing
Constraints by Calibrating Intermediate
Processes”, RTSS ’94.
3
Code Size Reduction Technique
Code size is a critical design factor for
many embedded systems.
Reduced bit-width instructions
ARM microprocessor
normal mode : 32-bit instruction set
Thumb mode : 16-bit instruction set
code size can be reduced by 30%, while # of
instructions can increase by 40%.
4
Code Size vs Execution Time Tradeoff
A program contains both 16/32 bit
instructions in functions or basic blocks.
Compile-time tradeoff between code size
(s) and execution time (e) of a task
s
e
5
Tradeoff Function
Tradeoff function for each task
i
s = fi(e) (linear or discrete)
s
A
B
e
6
Embedded Real-Time System Design
Problem: design a system satisfying realtime system requirements while minimizing
the total code size of the task system
Real-time System
Requirements
X1
X2
1
2
d1
d2
3
4
Tradeoff
…
Y1
F(Y1|X1)=30, F(Y1|X2)=25,
C(Y1|X1,X2) = 4,
u(Y1)=40, l(Y1)=30
Task 1 Task 2
Task n
7
Design Framework
Goal : deriving task code size and scheduling
parameters while minimizing the system code
size and guaranteeing real-time requirements
Real-time System
Requirements
X1
1
d1
X2
2
d2
Design Framework
Task Scheduling Parameters
3
Y1
4
F(Y1|X1)=30, F(Y1|X2)=25,
C(Y1|X1,X2) = 4,
PCM
0
5
10
0
5
10
u(Y1)=40, l(Y1)=30
Tradeoff
…
Task 1 Task 2
Task n
8
Design Framework Overview
Real-Time System Requirements
Min. Task Exec. Time
Design Framework
PCM
Task Scheduling
Parameters
Task Tradeoff
Feasibility
Analysis
Feasibility
Constraints
Task Exec. Time
Task Code Size
Optimization
Framework
Task Code Size & Scheduling Parameters
9
Design Framework Overview
Real-Time System Requirements
Min. Task Exec. Time
Design Framework
PCM
Task Scheduling
Parameters
Task Tradeoff
Feasibility
Analysis
Feasibility
Constraints
Task Exec. Time
Task Code Size
Optimization
Framework
Task Code Size & Scheduling Parameters
10
Optimization Problem Formulation
Given linear or discrete tradeoff functions and
task scheduling parameters, determine task
execution time solving the following
optimization problem:
Optimization problem:
objective: minimizing
constraint: feasibility
n
n
s f
i
i 1
e
i( i)
i 1
11
Feasibility Analysis
Task model : asynchronous periodic tasks with
pre-period deadlines under EDF scheduling
For the task model, an exact feasibility
condition is
n
(t , t ) e t
i
1
2
i
2
t1
i 1
for all 0 t1 t 2 2TLCM O max , where i (t1, t 2) is
the number of jobs of task i that must be
completely scheduled in [t1, t2).
Feasibility Analysis is NP-hard [Baruah ’90].
12
Feasibility Analysis
Our contribution: another exact feasibility
condition that can be more efficiently
evaluated.
n
(t , t ) e t
i
1
2
i
2
t1
i 1
for all (t1, t2) ODALL , where ODALL is a set of
possible pair of (offset, deadline) between 0
and 2TLCM + Omax.
13
Optimization Framework
Optimization Problem
Objective : minimizing
n
Constraint :
n
s
i
i 1
(t , t ) e t
for all (t , t ) OD .
i
1
2
i
n
fi ( ei )
i 1
2
t1
i 1
1
2
ALL
Complexity of optimization problem
Linear tradeoff : the optimization problem
can be solved through linear programming.
Discrete tradeoff: we prove the problem is
NP-hard and present three heuristics.
14
Heuristic Algorithms
Consider the following three tasks
Ti
ei
1
2
3
9
2
7
1
5
2
1
2
3
0
5
10
15
20
15
Heuristic Algorithms
Each job can increase its execution time if there
is an empty slot in its execution window
EDF Schedule
0
5
10
15
20
0
5
10
15
20
1
2
3
16
Heuristic Algorithms
Each job can increase its execution time if there
is an empty slot in its execution window
EDF Schedule
0
5
10
15
20
0
5
10
15
20
1
2
3
17
Heuristic Algorithms
Each job can increase its execution time if there
is an empty slot in its execution window
Cumulative amount of execution time each job can
increase
1
2
3
0
5
10
15
20
18
Heuristic Algorithms
Each job can increase its execution time if there
is an empty slot in its execution window
The maximum amount of execution time a task can
increase is the maximum amount of execution time all
of its jobs can increase together.
1
2
3
0
5
10
15
20
19
Heuristic Algorithms
Highest Best Reduction-Ratio First (HBRF)
reduction ratio
fi (ei ) fi (ei i )
i
1
choose a task with the highest reduction ratio
i
ei
2
0
5
10
15
20
20
Heuristic Algorithms
Longest Period First (LPF)
choose a task with the longest period.
In general, increasing the execution time of
this task has the least impact on the
schedulability of task set
T1
1
2
T2
0
5
10
15
20
21
Heuristic Algorithms
Highest Best Weighted-Reduction-Ratio First (HBWF)
Weighted reduction ratio
Ti
TLCM
fi (ei ) fi (ei i )
i
choose a task with the highest weighted
reduction ratio
T1
1
i
ei
2
T2
0
5
10
15
20
22
Evaluation of Heuristic Algorithms
Closeness to OPT
S(init) – initial system code size
S(alg) – system code size obtained with
an heuristic algorithm
S(opt) – optimal system code size
Closeness to OPT
S (init ) S (alg )
S (init ) S (opt )
23
Performance of algorithms with 8 tasks
BEST
HBRF
HBWF
LPF
1
Density
0.8
0.6
0.4
0.2
0
60
70
80
90
Closeness to OPT (%)
100
24
Performance of BEST with various task numbers
1
Density
0.8
0.6
4 tasks
6 tasks
8 tasks
10 tasks
12 tasks
0.4
0.2
0
60
70
80
90
Closeness to OPT (%)
100
25
Conclusion
Design framework taking advantage of
the code size vs. execution time tradeoff
Future work
Energy consumption is another critical design
factor of embedded systems.
Extends this framework so as to utilize
tradeoffs among code size, execution time,
and energy consumption.
26
Real-Time System Requirements
Task graph
dataflow & task precedence
End-to-end timing constraints
freshness from input to output
input correlation
output separation
27
Task Graph
Dataflow & task precedence
X1
1
d1
4
X2
2
d2
5
X3
3
Y1
d4
d3
6
Y2
28
End-to-end timing Constraints
Freshness from input to output: F(Y1|X1)
Input correlation : C(Y1|X1,X2)
Output separation : u(Y1), l(Y1)
X1
1
d1
X2
2
d2
4
Y1
29
Example – System Requirements
X1
1
d1
4
X2
2
d2
5
X3
3
Y1
d4
d3
F(Y1|X1)=30, F(Y1|X2)=30,
F(Y2|X2)=20, F(Y2|X3)=15
C(Y1|X1,X2)=3,
C(Y2|X2,X3)=4
l(Y1)=21, u(Y1)=32,
l(Y2)=29, u(Y2)=41
6
Y2
e1=2, e2=2,
e3=1, e4=3,
e5=2, e6=3
30
Example – Solution Process
1. deriving the period of each task
ei
minimizing utilization (
)
Ti
2. deriving the offset and deadline of each task
3. deriving the fixed priority of each task
31
Example – Task Scheduling Parameters
1
2
3
4
5
6
period
26
13
39
26
39
39
offset
0
0
0
21
0
13
deadline
21
12
13
26
13
15
priority
1
2
3
4
5
6
32
Real-Time Task Scheduling Parameters
Period (Ti)
Offset (Oi)
Deadline (Di)
Fixed priority
Execution time (ei)
33