4.3 Pinwheel Phase Alignment
4.3.1 Minimize the Total Delay
Given two pinwheel schedules for two neighboring nodes
N
j andN
j+1, we dene the phaseh
j as the dierence between the start times ofT
nj andT
nj+1. We choose the start time ofT
nj as the reference point because there is only one unique start time ofT
njin any pinwheel schedule. It must be true that 0h
j< C
nsince the schedule repeats everyC
n. The delay ofX
i betweenN
j andN
j+1,d
ij, is a periodic function ofh
j with periodC
i.d
ij can be dened as follows:d
ij(h
j) = (h
j+ij) modC
i 0h
j< C
n (4.3) whereij is the delay forT
ij whenh
j = 0. For the rest of this chapter, we sometimes used
ij as a shorthand ford
ij(h
j). The total delay of all tasks between nodesN
j andN
j+1 is dened as!
j(h
j) =Pid
ij(h
j).!
j has the following property.Theorem 4.3
If the total delay!
j(h
j) between nodesN
j andN
j+1 has the minimum value whenh
j =t
, it must be true that 9i
,d
ij(t
) = 0.52
0 2 4 6 8 10 12 14 16 18 20
0 5 10 15 20 25 30 35 40 45 50
phase hj
delay dij
d11 d21 d31 d41
d51 delay function for d31 total delay function minimum total delay
Figure 4.4: Delay functions and their sum
Proof: Assume
h
j =t
0 is the optimal phase for!
j and none of thed
ij(t
0)'s is equal to 0,8
i
. Suppose the minimum of thed
ij(t
0)'s isd
kj(t
0). If we set the phase tot
0;d
kj(t
0), alld
ij's will be reduced byd
kj(t
0). So, at this new phase,t
0;d
kj(t
0), the total delay is less than that at the phaset
0 by the amountn d
kj(t
0), thus a contradiction. 2Representing the Delay Function
Before we present the algorithm for nding the minimum total delay, we rst show how to eciently represent the delay function in our algorithm. The
d
ij function dened in Equation (4.3) is a set of discontinued line segments (e.g.d
31 in Figure 4.4). Between discontinued points,d
ij increases linearly withh
j. At each discontinued point,d
ij drops fromC
ito zero. When severald
ijfunctions are combined, the resulting function is a serrated line. In a serrated line, the function value monotonically increases, with a constant slope, between discontinued points. In other words, each serrated line can be dened as a set of line segments with a constant slope. The delay functions and their total function for the example of Figure 4.2 is shown in Figure 4.4.Suppose the total delay
!
j(h
j) has the minimum value whenh
j =t
. To ndt
, we need to inspect all line segments in the serrated line Pid
ij(h
j). From Theorem 4.3, we know that the minimum!
j(h
j) occurs ath
j =t
when at least one of thed
ij(t
) is 0, where itis discontinued. By searching through all discontinued (or drop) points in 0
C
n), we cannd the
t
value. Unfortunately, there are many drop points in 0C
n). For example, if8i
, 1i < n
,C
i+1=C
i = 2, there will be 2n;1 drop points. We would like to reduce the number of drop points to be searched.We use a special data structure to cut down the domain size of a serrated line while keeping all signicant drop points (i.e. those with lower
!
j values). For example, to reduce the domain size of a serrated linef
(t
) from 100 to 25, we denef
0(t
) = minff
(t
)f
(t
+ 25)f
(t
+ 50)f
(t
+ 75)gfor 1
t
25. Conceptually, the serrated line is cut into equal portions, and only the minimum values of relative points in the portions are kept. To keep track of the originalh
j value, each point in our representation has two domains: the current domain and the original domain. Throughout the algorithms, the serrated line will be cut many times and only a subset of the original!
j(h
j) function is kept. However, each point in the nal serrated line has its uniqueh
j value in the original domain. The data structure SLINE is dened below.Denition: An SLINE
S
=fs w
(x y
) f(p
1a
1p
01) (p
2a
2p
02):::
ggis dened by 1.s
is the slope of the line segments2.
w
is the width, the current domain size3. (
x y
) is the origin coordinates in the original domain4. (
p
ia
ip
0i)'s are a sequence of drop points. For each point,p
i is its current domain value,p
0iis its original domain value, anda
iis the drop amount. The points are sorted on thep
i value.2
Suppose
S
is an SLINE withv
drop points and domain widthE
k, andF
1::: F
u are delay functions with periodE
w. Three operations have been dened for SLINE: SUM, MAX and CUT.54
Figure 4.5: Cutting SLINE (S=CUTfW,4g)
1. SUMf
S F
1::: F
ug is an SLINE that has the sum of all function values.2. MAXf
S F
1::: F
ug is an SLINE that has the maximum of all function values.3. CUTf
S E
wg is an SLINE withS
's domain size cut toE
w but keeps the minimum values inS
.Figure 4.5 shows the CUT operation of SLINE. In the gure,
W
andS
are SLINE's whereW
= f1 8 (0 2) f(3 5 3) (6 2 6)ggandS
=CUT
fW
4g= f1 4 (4 1) f(2 2 6) (3 2 3)gg. Both SUMfS F
1::: F
ug and MAXfS F
1::: F
ug can be done inO
(v
+u
lgu
) time. The time complexity of CUTfS E
wgisO
(v
lg(E
k=E
w)). The detailed denitions and algorithms for these SLINE operations are included in the Appendix C.Minimizing the Total Delay Between Two Nodes
Again let
X
be a set ofn
transactions in a distributed system ofm
processors.T
ij is the task ofX
i on nodeN
j with execution timee
ij. We group tasks according to their period values. Suppose there arel
dierent period values, tasks with the shortest period,E
1, are in groupG
1 and tasks with the longest period,E
l, are in groupG
l. jG
kjis the number of tasks in groupG
k andE
k is the period value of task groupG
k. Therefore Plk=1jG
kj=n
. For any taskT
ij in groupG
k, the value ofd
ij(h
j) is the same as the value ofd
ij(h
j+E
k).Moreover, the sum of all
d
ij(h
j)'s for all tasks inG
k is also a periodic function ofh
j with periodE
k. We therefore may combine all delay functions of the same task group in oneSLINE.
We would like to nd the
h
j that minimizes Pni=1d
ij(h
j). Instead of searching through every point in the domainE
l, we use the CUT operation to reduce the search domain but keep all potentialh
j values. In our algorithm, we add the delay functions (using SUM) one group at a time, until all groups are added, to form the subtotal delay functionS
. Before each SUM operation, we use the CUT operation to reduce the subtotal functionS
to the next (smaller) domain size.Let kj(
h
j) be the sum of alld
ij(h
j)'s in the groups fG
k,G
k+1::: G
lg. By denition, we know that kj(h
j) is a periodic function with periodE
k, sinceE
kjE
i, fork
+ 1i
l
. We design theminsum
algorithm for nding the minimum total delay as follows.Algorithm minsum
(j
)Input:
E
1::: E
l are the period lengths forG
1::: G
ld
ij is the delay function forX
i betweenN
j andN
j+1.1
S
=f0E
l (0 0) g //S
is an SLINE representing the current subtotal function.2
S
=SUM
fS F
lgwhereF
l=fd
ij jd
ij 2G
lg //F
l is a collection of delay functions.3
for k
=l
;1downto
1do
f4
S
=CUT
fS E
kg5
S
=SUM
fS F
kgwhereF
k =fd
ijjd
ij 2G
kg6 g
7 return
t
whereS
(t
) is the minimum.In the
minsum
algorithm kj(h
j) is implemented as an SLINES
with widthE
k. By applying CUT(S E
k),S
keeps all the points with the minimal kj(h
j) value and also keeps track of their positions in the original domain.Algorithm Complexity
Since the width of
S
isE
k, eachd
ij inG
k will only contribute one drop point inS
. The number of new drop points added will be at most jG
kj. Because Plk=1jG
kj isn
, the number of drop points inS
will be no greater thann
. The complexity of line 2 and line 5 isO
(Plk=1(n
+jG
kjlgjG
kj)), the complexity of line 4 isO
(Plk;1=1n
lg(E
k+1=E
k)), and the56 complexity of line 7 is
O
(n
). Since the (E
k+1=E
k)'s for a system are constants, the overall complexity of the algorithm isO
(n
lgn
+nl
).Minimize the Total End-to-End Delay
For a sequence of nodes, the phases