Preemptive Scheduling of Uniform Processor Systems - CiteSeerX

3 downloads 0 Views 548KB Size Report
KEY WORDS AND PHRASES. uniform processors, preemptive schedules, optimal fimsh time ..... In line 9 s is updated to m + 1 in case the slowest processor Pm.
Preemptive Scheduling of Uniform Processor Systems

TEOFILO

GONZALEZ

The Pennsylvama State Umversay, Umverstty Park, Pennsylvama AND SARTAJ SAHNI Umverstty of Mmnesota, Mtnneapohs, Mmnesota AaSTRACT An O(n) t~me algorithm is presented to obtain an opt,mal fimsh time preemptive schedule for n independent tasks on m uniform processors This algorithm assumes that the tasks are lnmally ordered by task length and that the umform processors are ordered by processor speed KEY WORDS AND PHRASES. uniform processors, preemptive schedules, optimal fimsh time schedules, mdependent tasks CR CATEGORIES" 4 32, 5 39

1. Introduction Let P1, P2, ..- , Pm be a system of m u m f o r m processors and let the speed of P, be s,. W t t h o u t loss of generality we may assume sl >- s2 -- • • • -> s,,. n i n d e p e n d e n t tasks are to be scheduled on these m processors. Let t, be the length of (or processing t i m e r e q u i r e d by) task i. W e assume that tl >- t2 -> • • • >- tn. T h e e x e c u t i o n of task i on processor Pj requires t,/s~ time, 1 -< i -< n and 1 --< 1 -< m . T h e fimsh time of a schedule is the t i m e at which all tasks h a v e b e e n e x e c u t e d . A p r e e m p t i v e schedule is a schedule in which o n e may suspend the e x e c u t i o n of a task b e f o r e its c o m p l e t i o n and r e s u m e its e x e c u t i o n at a later time (possibly on a different processor). In a nonpreemptive schedule the processing of a task on a given processor cannot be s u s p e n d e d until its c o m p l e t i o n . A n opttmal fimsh ttme ( O F T ) p r e e m p t i v e ( n o n p r e e m p t i v e ) schedule is a p r e e m p t i v e ( n o n p r e e m p t i v e ) schedule with m i n i m u m finish time a m o n g all feasible p r e e m p t i v e ( n o n p r e e m p t i v e ) schedules for the given i n d e p e n d e n t tasks and u n i f o r m processors. T h e r e a d e r is r e f e r r e d to [2] for a m o r e prectse definition of these terms. T h e p r o b l e m of o b t a i n i n g O F T n o n p r e e m p t t v e schedules for a uniform p r o c e s s o r system with rn -> 2 processors is k n o w n to be N P - c o m p l e t e (see K a r p [7]). Liu and L m [8] present worst-case b o u n d s on a simple heuristic that obtains a p p r o x i m a t e l y optimal O F T schedules. G o n z a l e z , Ibarra, and Sahni [3] analyze the p e r f o r m a n c e of an L P T (largest processing time first) type h e u n s t t c for obtaining n e a r o p t i m a l O F T n o n p r e e m p tive schedules. F u r t h e r a p p r o x i m a t i o n m e t h o d s to obtain n e a r o p t i m a l schedules for uniform processors are given by H o r o w i t z and S a h m [5]. In this p a p e r we are c o n c e r n e d solely with obtaining O F T p r e e m p t i v e schedules. F o r this p r o b l e m Liu and Y a n g [9] have o b t a i n e d the following b o u n d on the length of an This research was supported m part by the National Science Foundation under Grants DCR74-10081 and MCS76-21024 Authors' addresses. T Gonzalez, Department of Computer Science, The Pennsylvama State Umverslty, Umverslty Park, PA 16802, S Sahm, Department of Computer Science, Umversity of Minnesota, Minneapolis, MN 55455 Journal of the Assoclauonfor ComputingMachinery,Vol 25, No 1, January 1978,pp 92-101

Preempttve Scheduling o f Uniform Processor Systems

93

O F F schedule. Let w be the length of an O F F preemptive schedule, let T~ = ~1~,~ t, let S: = ~ l ~ j s,, and let n -> m ; then w -> m a x _I max {T~/S~}, T,,/SmlJ . . . .

(1)

1 3 1. Horvath, Lam, and Sethl [6] adapt the "critical path" algorithm of Muntz and Coffman [11] to the uniform processor case and obtain an O(mn 2) time algorithm to obtain O F T preemptive schedules. Their algorithm shows that (1) is in fact always an equality, Le. the length w of an O F F schedule always satasfies the equality.

w=maxlm< a~< -mx { T J S ~ } ' T " / S m } t . . . .

(2)

The algorithm of [6] generates schedules with an excessive number of preemptions. For n tasks and m processors, the schedules generated by this algorithm may have as many as n2(m - 1) preemptions. In this paper we first show that for any set of n independent tasks and any uniform processor system w~th m -~ 1 processors, there exists an O F F schedule with at most 2(m - 1) preemptions. Hence, there exasts a large gap between the worst-case n u m b e r of preemptaons using the algorithm of Horvath et al. and the maximum n u m b e r of preemptions needed Our proof that 2(m - 1) is the maximum n u m b e r of preemptions needed is constructive and it leads to an algorithm with this property. The time complexity of the resulting algorithm ~s O(n). The complexity analysis does not include the time to sort the tasks and processors into order by task length and processor speed, respectively. If this ~s to be done then the complexity becomes O(n + m log n) since our algorithm requires only the largest m tasks to be sorted (note that heap sort can be used to obtain the m largest of a set o f n numbers in O(m log n) time). This time can be further reduced to O(n + m log m) since the mth largest task can be found in time O(n) [1]. Having found this task, the m largest tasks can be found in time O(n) and then sorted in tame O(m log m). For the case of adentacal processors, our algorithm reduces to that of McNaughton [10] and so generates OF1~ schedules with no more than (m - 1) preemptions.

2. A Bound for the Martmum Number o f Preempttons In this sechon we show that every uniform processor system can be optimally scheduled using at most 2(m - 1) preemptaons The proof of thas is constructwe. We exhibit an algorithm that generates OFT schedules and show that the resulting schedules have at most 2(m - 1) preemptions Our scheduling algorithm uses four scheduling rules, R 1 R4. It begins by scheduhng tasks one at a tame in order of nonmcreasing task lengths. Rules R 1 - R 3 are used at this stage. The first task considered is one with largest length. This continues untd the next task to be scheduled satisfies one of two conditions (A1) or (A2) (to be specafied later) At thas time, all unscheduled tasks are scheduled using rule R4. The four rules are specified m a semiformal manner. The mathematical detads of the rules are relegated to Section 3, where the algorithm is presented formally. This allows us to concentrate on the important features of the scheduling rules that result m OFT schedules with at most 2(m - 1) preemptions. Throughout this sectaon and Sechon 3, we assume n -> m. In case n < m then only the fastest n processors need be consadered and the remaining discarded. Before presenting the rules, we develop some notation and state the conditions (A1) and (A2) referred to above I = {P,~, P~, ... , P'k} will represent a subset of the m processors. We shall denote by Sz the quantity ~v,~,s,. It will be assumed that the n tasks are ordered such that t~ -> t2 -> • • • -> t,,. Tk wall represent the sum ~k=~ t,. W will be the length of an O F T schedule for the gaven n tasks and m processors w is gwen by (2). By idle tzme

94

T.

GONZALEZ

AND

S.

SAHNI

on processor Ps we shall m e a n time in the interval [0, w ] when processor Pj is n o t processing any task. Thus, idle time is relative to a given partial schedule. W e shall d e n o t e by n p ( i l , i2 . . . . . is) the n u m b e r of p r e e m p t i o n s in the processors P,,, P,z . . . . . P,j. A d i s j o i n t p r o c e s s o r s y s t e m (DPS) is a set of r >- 1 processors P,,, P~, "-" , P,r such that i~ -< i2 -< • • • -< zr a n d processor P,j is idle exactly from uj_~ to uj, 1 -< j -< r, for some uo, u~, ... , Ur with the property u0 = 0, ur = w, a n d u~_~ < us, 1 -< ]