Volume 6, Number 1
A NOTE ON OPTIMAL PREE
INFORMATION PROCESSING LETTERS
PTIVE SCHEDUL!!‘k: a;O% TW
February 1977
PROCESSOR SYSTEMS
Andrzej ROWICKI lnsitute of Mathematical Machines, Krzywickiego 34, 02-078 Warszawa, l’obrrd Received 23 October 1976, revised version received 13 December 1976 Execution time, network, preemptive scheduling
1. introduction The purpose of this note is to consider an algorithm for optimal preemptive scheduling of two-processor systems. We shall consider systems in which there are two identical processors and assume that the computations submitted to the systems are composed of tasks with arbitrary execution time. Moreover, we assume that preemption times are completely unconstrained. As a model of computation we assume a weighted directed graph with arbitrary node weights which is connected and contains no circuit and has one terminal vertex. This model can be interpreted as follows: The attachement of tasks of the computation to the vertices of the graph is such that the order of execution of the tasks is in accordangz with the succession relation of the vertices of the graph. A weight is associated with each node of the graph and determines the execution time of corresponding task. In [ 1 ] an algorithm for optimal preemptive scheduling of two-processor systems has been presented. It was assumed that all tasks of the computation have the mutually commensurable execution times. On the other hand in [2] an algorithm for optimal nonpreemtive scheduling of two-processor systems has been presented. It was assumed that all tasks of tl:e computation have the same execution time. Moreover, it was considered an extension of the non-preemptive algorithm for preemptive case by assumption that all tasks of the computation have the mutually commens8urable execution times. The problem of determining the execution time of the computation was not considered in [l] and [2]. In this note we present an algorithm for optimal
preemptive scheduling of two-processor systems which has no constraints on execution time given in [i] and [2]. That is, we assume that the tasks of the computation have arbitrary execution time. More,>ver, this algorithm determines the execution time of the computation and is optimal in the sense that the total execution time is minimized. The algorithm presented in this note is so general that can be extended for multiprocessor systems [6] and it can be treated as an extension of the algorithm considered in [3], [4] and [S].
2. Basic notions and definitions Let us consider a weighted graph G = (X, r, t, x0), where X is a finite set of vertices, I? is a relation defined on the set X, t is a function which associates with every vertex of the set X a positive number and x0 is a terminal vertex of the graph 6, that is such a vertex that I’(xo) = 8, where @is a void set. The graph G = (X, r, t,xo) will be called a network if an only if it is connected, contains no circuits and has one terminal vertex. In further considerations we confine ourselves to networks. The networks will be denoted by a capital S. Let S = (X, r, t,xo) be an arbitrary but fixed network. Let L’(i) for i = 1,2, .. .. be a of X fined by in the way (i) =x0, (ii) x E and t(x) min,EZi (t(y)}, xE 25
til we determine a set D(0) of mutually independent :rer*ices with the vertices belonging to the set M(O,n). Thr:n we create a set W(0) as follows
where Zi is a subset of X deiined as follows i-l 2, = {HEX:
February 1977
INFORMATIONPROCESSINGLETTERS
Volume 6, Numbc: 1
xE x -
u L’cj) n r(x) c 1
f-1 If L’(f)}
l
AP(O) = M(0, n) U D(0) ,
Let p be a natural
On the other hand, if the cardinality of the set M(O,n) is greater than one, we set W(0) = M(0, n) .
i) , will be called the ith level of the network S. IA Si = i)and S = (X, F, t. ~0) be arbitrary but fixed networks such that X C Xi. The network Si is said to be a direct extension of the network S (in symbols S 5 Si) if and only if there exist such two vertices Si and sT that si E X n Xi and st E Xi - X satisfying the following conditions (i) ri(Si) = ST and r(si) = ri(sf), (ii)?&)= ti(Si)+t,{Sf), (iii) if x E X and x # si then I’(X) = ri(x). The vertex si will be called a singular vertex of the network S1 with respect to the network S. If the network Si contains more than one singular vertex then the network Sf is said to be an extension of the network S. It should be noted that if the network Si is any extension of the network S then the network S is not a reduct of the network Si and if si # ~0 then ~0 = xoi.
3. Description of the algorithm To describe the algorithm some notions will be needed. To make the understanding of the essential notions easier we will fist sketch the basic step of the algorithm. Certain details will be omitted here, so as not to obscure the basic idea. Let the network So be a model of computation and pi denotes the number of levels of the network So. In the first step we analyse the elements of the sequence LO(~), .... &An),
....Loo7o)
(1)
of levels of the network So until we determine the smallest set M(0, n) of mutually independent vertices of the network So, that is, such a smallest set that :jo two vertices from this set are connected by a path. If the set M(O,n) consists of one vertex then we continue analysing the terms of the sequence (1) un26
Next, we create such a smallest extension # of the network So that all immediate successors of vertices from the set M(O,n) are contained in the same level of the network Sf. If it is possible, then we create a disjoint two eleml:nts partition {P(O), W(0) - 40)) of the set W(0) in such a way so as to satisfy the following relation $(x) JCE,P(q)
=f
xEg(o) t?(x) *
l
If it is impossible, then we choose according some rules a task from the set of tasks corresponding to the set of vertices W(0) and split it in two parts in such a way so as to have been satisfied the relation (2). Of course, if we split any task then the model of computation varies. In this case a new model will be 4 a direct extension of the network S$? The tasks corresponding to the sets p(O) and M*(O) - p(O) are executed by different processors. Next steps of the algorithm proceed in a similar way as in the first step just described provided that relevant models of computation have been used. The notions needed to describe the algorithm can be defined formally as follows Let S = (X, I’, t,xo) be an arbitrary but fixed network and Si =
M(i, n) = b Li(i) - I; F(i) , where L&is thejth tvel of the network Si and Fi(i) is a subset of the set Xi, precisely defined in further considerations. Let 12and g be functions defined as follows n(i) = the smallest i C n C pi such that T’i(M(i,n)) n Li(Pl+ l)#@, n(i) = i otherwise,
Volume 6, Number 1
INFORMATION PROCESSING LETTERS
I+bruary
1977
g(i) = the smallest n(i) < n G pi such that 11 Li(tl,) - (Q(M(i, n - 1)) U lJb F(f)) 112 1 , g(i) = n(i) otherwise,
fl9 = 1xxEM*(i) r?(X) ),,ti) = fnc’Xx EM*(i) {f(X)] .
where Il.Xlldenotes the cardinality of the set X and
following convention
pi is a natural number satisfying the following relation
C tifx) = t/(X) . XEX Now, we distinguish some subset p(i) of the set M*(i) defined in the following way
Uf’Lltic) = Xi, that is pi determines the number of levels of the network S’ie Let D(i) C Xi be a set defined in the following way D(i) = Licg(i)) - (ri[*(i,g(i)
- l)] U iJ Fc)) .
3
2
!t? d?r
ffi) = 1~ E M*(i):
[CVV)u
0
should be noted that in some cases the set D(i) is empty. In the set D(i) we distinguish a subset D*(i) satisfying the following conditions (0 ID*(i) II= 1 (ii) if x E D*(i) then Ti(x) = maxyE D(i) {7i(_v)}, where ?i is a function defined as follows if x =XOi, Ti(X) = ti(X) if X # XOi . Ti(X) = ti(X) + maxY E rdx) (rib)} For the sake of conciseness of description of the algorithm we introduce some additional notions. LRt Si =
9.
It is easy io verify that not for every network Si there exists an extension induced by the set M(i,n(i)). It can be shown that if Si is m-extension of the network SJ and Xs is the set of singular vertices of the network Sj with respect to the network Si then Lj(?2(i) + 1) = Li(n(i) + 1) U qx,). For the sake of convenience, by fl will be denoted m-extension of the network Si or the network Si so far as there exists no m-extension for it. Let M*(i) C Xi be a set defined in the following way
= M(i, n(i))
if IIM(i,n(i)) II> 1 , W(i) = M(i, n(i)) U D*(i) if IIM(i,n(i)) II = 1 . Let Tand 7’, be functions defined as follows
W(i)
the notation
&P(i))
WC adopt t]le
< 7Q) A [1 VJ*EM*(i) .-P(i)]
W) g a(i)]1 .
It is easy to verify that- if IIM*(i)II = 1 then p(i) = 9. Weare now in a position to describe the process of
It
r,(y) n Li(n(i) + 1) Z
to silnplify
creation the sets F(i) and assignment of extensions Si to the network S. This process will be called as initial sequencing algorithm. The initial sequencing algorithm is defined by induction as follows 1. Basic step. F(0) = 9 and So = S. 2. Induction step. Gzse I. If IIM*(i)II= 1 then F(i t 1) = M*(i) and Si+r = Si* C&se2. If IlW(i) II > 1 and a) if fli) = T,,(i) then F(i + 1) = .W*(i) and Si +I = Sy, b) if T(i) < T,,(i) then F(,itl) = H*(i) and Sy 5 St+l and {si+l) = M*(i) - fli) and ti + 1(si + 1) = tM(p(i)), c) if T(i) > T,,(i) and (i) if tY(fii)) = T(i) then F(i + 1) = W(i) and s i+r =*9 (ii) if fy(fii)) < T(i) then F(i+ 1) = M*(i) U {s?+~} and St’ G Si+ 1 and si+1EM*(i) - p(i) and ti+ r(si+r) = tY [Ip(i)U {iTi+,]]- T(i). Let a sequence S,, S2, .... Sk be the sequence of networks assigned to the network S = (X, I’, f, x0 >iis a result of acting of the initial sequencing algorithm. The network Sk is said to be a terminal extension of the network S if the following relation &
k = u F(j) 1
holds and the number k will ‘0;:called a range of extension of the network Sk. In the following considerations termirral extension of the network Swill be denoted by a capital S”. it should be pointed out that if as a result 01 acting of the initial sequencing algorithm none of the tasks have been splitted then S = S*. As a result of acting of the initial sequencing algorithm we obtain a disjoint par27
INFORMATION PROCESSING LETTERS
Volume 6, Number I tition
that
{fl~}i=1,2,,.,,k of the set X* of the network S*, is, for every i,j < k if i # j then F(i) n F(j) = Q
lJt bu) = A?. If there exists no such a number then the disjoint partition {P(i)]~=r,2,,,_kdetermines the sets of mutually independent tasks of the computation which is represented by the network ,!P and thus the tasks corresponding to the sets F(i) can be concurrently executed. Let TXb: a task attached to the vertex x. In the case where sf E F(i) then between vertices q and sf the relation P&) = STholds. This means that the tasks 7”, and 7”t are dependent and the task 7’q ought to be executed after the execution of the task 7”,, Of course, if x E F(n) and y E F(m) and n < m then the task 7’,,is executed after the execution of the task TX. Frorn definition of initial sequencing algorithm it follows that if ilF(i)li > 1 then it can be created a disjoint pa8rtition{F,(i), F*(i)} of the set F(f) in such a way so as to satisfy the following relation
and
i G k that sf E fli)
t*U5 (0) = WW)
9
which means that if the tasks attached to the sets F, (i) and Fz(i) are assigned to different processors then the total execution time of the computation is minimized. Finally, the total execution time of the computation which is reprexz: ed by network S is given by the
28
February 1977
formula qS)= 6 P(i), 1
where r is the range of extension of the network S* and P is a function defined in the following way if IIF(i)il > 1 , TV) = f t*(fli)) P(i) = t*(F(i)) if llfii)II = 1. It should be observed that the total execution time T(S) of the computation can be determined before assigning processors to the tasks of the computation, that is before creation the disjoint partitions {Fl(i), F&)} of the sets F(i).
References PI R.R. Muntz, E.G. Coffman Jr., Optimal preemptive scheduling on two-processor systems. IEEE Trans. Computers C-18, (1 I) (1969) 1014-3020. PI E.G. Coffman Jr., R.L. Graham, Optimal scheduling for two-processor systems, Acta Informat. 1 (3) (1972) 200293. 131A. Rowicki, AIgxithm phnowania obliczen’ dwuprocesorowych. Race IMM 17 (2) (1975) 65-83. IdI A. Rowicki, A note on optimal scheduling for two-processor systems. Information Processing Lett. 4 (2) (1975) 27-30. ISI A. Rowicki, On optimal scheduling for two-processor systems, Bull. Acad. Polon. Sci. Ser. Sci. Math. Astronom. Phys. 24 (4) (1976) 287-293. 161A. Rowicki, In preparation.