Scheduling Algorithms for Multiprogramming in a Hard Realtime Environment

Size: px
Start display at page:

Download "Scheduling Algorithms for Multiprogramming in a Hard Realtime Environment"

Transcription

1 Scheduling Algoriths for Multiprograing in a Hard Realtie Environent C. Liu and J. Layland Journal of the ACM, 20(1):46--61, January 1973.

2 2 Contents 1. Introduction and Background 2. The Environent 3. A Fixed Priority Scheduling Algorith 4. Achievable Processor Utilization 5. The Deadline Driven Scheduling Algorith 2

3 3 Introduction and Background The use of coputers for Tie-critical control and onitoring of industrial processes Two scheduling algoriths are studied Both are priority driven and preeptive The processing of any task is interrupted by a request for any higher priority task The first one Fixed priority assignent algorith The second one Dynaic priority assignent 3

4 4 The Environent Five assuptions (A1) The request for all tasks for which hard deadlines exist are periodic (A2) Deadlines consist of run-ability constraints only Each task ust be copleted before the next request for it occurs (A3) The tasks are independent in that requests for a certain task do not depend on the initiation or the copletion of requests for other tasks (A4) Run-tie for each task is constant for that task and does not vary with tie. Run-tie here refers to the tie which is taken by a processor to execute the task without interruption (A5) Any nonperiodic tasks in the syste are special; they are initialization or fault-recovery routines; they displace periodic tasks while theselves are being run, and do not theselves have hard, critical deadlines 4

5 5 A Fixed Priority Scheduling Algorith (1) Task and scheduling odel Deadline of a request The tie of the next request for the sae task Overflow of a request Unfulfilled request by its deadline Feasible algorith If tasks are scheduled so that no overflow ever occurs Response tie of a request The tie span between the request and the end of the response to that request Critical instant of a task An instant at which a request for that task will have the largest response tie Critical tie zone for a task The tie interval between a critical instant and the deadline of the corresponding request of the task 5

6 6 A Fixed Priority Scheduling Algorith (2) Theore 1. A critical instant for any task occurs whenever the task is requested siultaneously with requests for all higher priority tasks Proof. Advancing the request tie copletion of t 2 will not speed up the 6

7 7 A Fixed Priority Scheduling Algorith (3) Iportant value of Theore 1 A siple direct calculation can deterine whether or not a given priority assignent will yield a feasible scheduling algorith Exaple: two tasks T1 2, C1 1 T, C and 2 7

8 8 A Fixed Priority Scheduling Algorith (4) The following inequalities ust be et for feasibility 1 If is the highest priority task (ethod 1) (1) 2 If is the highest priority task (ethod 2) (2) It follows fro (2) that Whenever T1 T 2 and 2 has the highest priority, Ineq.(2) iplies Ineq.(1) Ineq.(1) is a weaker condition If a task set is schedulable by ethod 2, then it is also schedulable by ethod 1 8

9 9 A Fixed Priority Scheduling Algorith (5) Reasonable rule of priority assignent Assign priorities according to request rates, independent of run-ties Tasks with higher request rates will have higher priorities Rate-onotonic priority assignent Optiu in the sense that no other fixed priority assignent rule can schedule a task set which cannot be scheduled by the rate-onotonic priority assignent Theore 2. If a feasible priority assignent exists for soe task set, the rate onotonic priority assignent is feasible for that task set Proof. By an inter-change arguent 9

10 10 Achievable Processor Utilization (1) Utilization factor The fraction of processor tie spent in the execution of the task set The utilization factor is equal to one inus the fraction of idle processor tie Utilization factor can be iproved by Increasing run-ties and decreasing periods However, utilization factor is upper bounded by the requireent of feasibility (eeting deadlines) How large the processor utilization factor can be? 10

11 11 Achievable Processor Utilization (2) Full utilization of processor A set of tasks is said to fully utilize the processor if the priority assignent is feasible for the set and if an increase in the run-tie of any of the tasks in the set will ake the priority assignent infeasible LUB (least upper bound) of utilization factor The iniu of utilization factor over all sets of tasks that fully utilize the processor For all task sets whose utilization factor is below this bound, there exists a fixed priority assignent which is feasible 11

12 12 Achievable Processor Utilization (3) Schedulable Utilization Bound 12

13 13 Achievable Processor Utilization (4) Theore 3. For a set of two tasks with fixed priority assignent, the least upper bound to the 1/ 2 processor utilization factor is U 2(2 1) Proof. See Theore 4 13

14 14 Achievable Processor Utilization (5) Theore 4. For a set of tasks with fixed priority order, and the restriction that the ratio between any two request periods is less than 2, the least upper bound to the processor utilization factor is 1/ U (2 1) Proof. (1) We first show that the LUB can be found when C1 T2 T1 Ck, Tk 1 Tk, and C T 2( C C... C ) T T (2) We then copute the LUB 14

15 15 Achievable Processor Utilization (6) We first show that the LUB can be found when C T C T T C 2T T 2 1,, and 1 T k k 1 k 1 Proof (1). For 0 (1) Suppose that C1 T2 T1 and the task set S fully utilize We can construct another set S such that ' ' C1 T2 T1, C2 C 2, and C ' k Ck ' ' S fully utilize since C1 C2 C1 C2 U U / T1 / T2 0 (2) Suppose that C1 T2 T1 and the task set S fully utilize We can construct another set S such that ' ' C1 T2 T1, C2 C2 2, and C ' k Ck S fully utilize U U / T1 2 / T2 0 Siilarly, we can show that C T T k k 1 k 15

16 16 Two Task Case - all fully utilize (7) C1 C2 C1 C2 C / /3 = 5.1/ C1 C2 C1 C2 C /2 + 1/3 = 5/6 LUB case! C1 C2 C1 C2 C / /3 = 5.1/6 16

17 17 Achievable Processor Utilization (8) Illustration Case (1) Case (2) Delta To increase C 1 by Delta, we need to decrease C 2 by 2 Delta Case for LUB 17

18 18 Achievable Processor Utilization (9) We next copute the LUB Using the previous results, we can write U ( T2 T1 ) / T1 ( T3 T2 ) / T2... (2T1 T ) / T T2 / T1 1 T3 / T T1 / T 1 T2 / T1 T3 / T2... 2T1 / T Let R i Ti 1 / Ti T1 T1 T 1... T3T 2 T 1T 2... T3T 1 1/ R 1R 2... R T T T... T T T T... T T U R1 R2... Ri... 2 /( R 1... R1 )

19 19 Achievable Processor Utilization (10) Given U R1 R2... Ri... 2 /( R 1... R1 ) To find the iniu, we solve the following 2 U / R 1 2( R... R )/( R... R... R ) 0 i R i i 1 2 /( R 1R 2... R2R1 ) This iplies R1 R2... R Finally it follows that U ( 1)2 ( 1) , thus 2 /(2 ) ( 1) (2 1) R i 1 1/ 2 2 /(2 1 1 ) 19

20 20 Achievable Processor Utilization (11) For =3, U For large, 1/3 3(2 U ln 2 1) 0.78 The restriction that the largest ratio between request period less than 2 can be reoved Theore 5. For a set of tasks with fixed priority order, the least upper bound to processor 1/ utilization is (2 1) 20

21 21 Achievable Processor Utilization (12) Outline of proof of Theore 5 The idea is that if a set of tasks fully utilizes the processor and for soe i, i < then we can always construct another set of tasks that will (1) fully utilize the processor, (2) and (3) the utilization of the new set is less than the original one 21

22 22 The Deadline Driven Scheduling Algorith Priorities are assigned to tasks according to the deadlines of their current requests A task will be assigned the highest priority if the deadline of its current request is the nearest At any instant, the task with the highest priority and yet unfulfilled request will be executed This ethod of assigning priorities is a dynaic one We want to establish a necessary and sufficient condition for the feasibility of the deadline driven scheduling algorith 22

23 23 The Deadline Driven Scheduling Algorith Theore 6. When the deadline driven scheduling algorith is used to schedule a set of tasks on a processor, there is no processor idle tie prior to an overflow Proof. Shifting a, b,.., c to t 2 leads to a contradiction 23

24 24 The Deadline Driven Scheduling Algorith Theore 7. For a given set of tasks, the deadline driven scheduling algorith is feasible if and only if U C T C / T... C / T 1 1 / Proof. (1) To show the necessity, copute the total deand of coputation tie between 0, T, T... T ] [

25 25 The Deadline Driven Scheduling Algorith Proof of Theore 7. (2) To show the sufficiency, assue that the algorith is not feasible and U C1 / T1 C2 / T2... C / T 1 There will be an overflow at in the interval 0, T T There is no idle tie in the interval [0, T] a Let iediately before T Let 2 deadlines at T, a, a,..., b, b2, b a, a, 3,... 1 a b1, b, b3,... Let 2 deadlines beyond T t T denote the request ties are the request ties of tasks with are the request ties of tasks with [ T ] 25

26 26 The Deadline Driven Scheduling Algorith Proof of Theore 7. Two cases ust be considered Case 1. None of the coputation ties of requested at was carried out before T Case 2. Soe of the coputation ties of requested at was carried out before T b1, b2, b3,... b1, b2, b3,... 26

27 27 The Deadline Driven Scheduling Algorith Proof of Theore 7. Case 1. The total deand of coputation tie in the interval [0, T] Since there is no idle period Thus This is a contradiction 27

28 28 The Deadline Driven Scheduling Algorith Proof of Theore 7. Case 2. There ust exist a point T such that none of requests at b1, b2, b3,... was carried out in the interval [T, T] In other words, only those requests with deadline at or before T will be executed Note that since soe of the requests at b1, b2, b3,... can be executed until T, all those requests initiated before T with deadlines at or before T have been fulfilled before T Therefore, the total deand of coputation tie in the interval [T, T] is less than or equal to Since an overflow occurs,, which is a contradiction 28

29 29 The Deadline Driven Scheduling Algorith 29

30 30 Note! Task b j cannot arrive ore than once in the interval (T, T), since this eans task b j has a deadline earlier than T and ust be copleted before T in (T, T). Thus, there is no execution of task b j in (T, T) and this eans only tasks a i can execute in (T, T). Let the coputation tie deand of all tasks a i be X and X is less than Ters for task b j are 0 X > T T since there is a deadline iss, thus 30

31 31 The Deadline Driven Scheduling Algorith Deadline driven scheduling algorith is optiu If a set of tasks can be scheduled by any algorith, it can be scheduled by the deadline driven algorith This clai coes fro Theore 7 If a set of tasks can be scheduled by any algorith, their CPU utilization is no greater than one Therefore, the task set can also be scheduled by the deadline driven scheduling algorith 31

32 32 Other Proof of Optiality We show that any feasible schedule can be systeatically transfored to EDF schedule Assue that parts of two jobs J i a J k are scheduled in non-edf order: 32