Presentation is loading. Please wait.

Presentation is loading. Please wait.

Clock Driven Scheduling By Dr. Amin Danial Asham.

Similar presentations


Presentation on theme: "Clock Driven Scheduling By Dr. Amin Danial Asham."— Presentation transcript:

1 Clock Driven Scheduling By Dr. Amin Danial Asham

2 References Real-time Systems Theory and Practice. By Rajib mall

3 Example1: A cyclic scheduler is to be used to run the following set of periodic tasks on a uniprocessor: T 1 = (e 1 =1,P 1 =4), T2 = (e 2 =1,P 2 =5), T 3 = (e 3 =1,P 3 =20), T 4 = (e 4 =2,P 4 =20). Select an appropriate frame size. Solution:  For the given task set, an appropriate frame size is the one that satisfies all the three required constraints. 1.The Major Cyle M = LCM(4,5,20) =20. 2.Constraint 1. Frames must be sufficiently long so that every job can start and complete within a single frame:, then maxi {ei} ≤ F. Therefore, we get F ≥ 2 3.Constraint 2. The major cycle must have an integer number of frames. Therefore, the possible values of F are 2, 4, 5, 10, 20.

4 2451020 424124 511555 2451020 2451020 PiPi F Table of GCD of all possible frame sizes and task periods 2451020 4True False 5TrueFalseTrueFalse 20True 20True didi F Table of the 3 rd constraint 2F - GCD(F,P i ) ≤ d i Suitable Frame Size 4.Constraint 3. To satisfy this constraint, we need to check whether a selected frame size F satisfies the inequality: 2F - GCD(F,P i ) ≤ d i for each P i.

5 Example1 (cont.): 0 2 4 6 8 10 12 14 16 18 20 T1T2T3T4T1T2T3T4 T1T1 T1T1 T1T1 T1T1 T2T2 T2T2 T2T2 T1T1 T1T1 T1T1 T1T1 T1T1 T1T2T3T4T1T2T3T4 T3T3 T4T4 T2T2 T2T2 T2T2 T2T2 0 2 4 6 8 10 12 14 16 18 20 T1T2T3T4T1T2T3T4 T1T1 T1T1 T1T1 T1T1 T2T2 T2T2 T2T2 T1T1 T1T1 T1T1 T1T1 T1T1 T1T2T3T4T1T2T3T4 T3T3 T4T4 T2T2 T2T2 T2T2 T2T2 T4T4 T3T3

6 Example 2 Consider the following set of periodic real-Time tasks to be scheduled by a cyclic scheduler: T 1 (e 1 =1, P 1 =4), T 2 = (e 2 =2,P 2 =5), T 3 = (e 3 =5,P 3 =20). Determine a suitable frame size for the task set. Solution: 1.Major cycle M = LCM (4, 5, 20) = 20 2.Constraint 1: F ≥ 5. 3.Constraint 2: the possible values of F are 5, 10 and 20. 4.Constraint 3: 51020 4124 5555 51020 PiPi F 51020 4False 5TrueFalse 20True didi F Table of GCD of all possible frame sizes and task periods Table of the 3 rd constraint 2F - GCD(F,P i ) ≤ d i No Suitable Frame size

7 Example 2 (cont.) It is easy to observe that the task T 3 has the largest execution Time and consequently due to the constraint 1 makes the feasible frame sizes quite large. We try splitting T 3 into two or three tasks. After splitting T 3 into three tasks, we have: T 3.1 = (20, 1, 20), T 3.2 = (20, 2, 20), T 3.3 = (20, 2, 20). 1.Constraint 1: F ≥ 2. 2.Constraint 2: the possible values of F are 2,4,5, 10 and 20. 3.Constraint 3: 2451020 424124 511555 2451020 2451020 2451020 2451020 4True False 5TrueFalseTrueFalse 20True 20True 20True Table of GCD of all possible frame sizes and task periods Table of the 3 rd constraint 2F - GCD(F,P i ) ≤ d i PiPi F Suitable Frame size didi F

8 Note It is very difficult to come up with a clear set of guidelines to identify the exact task that is to be split, and the parts into which it needs to be split. This therefore needs to be done by trial and error. Further, as the number of tasks to be scheduled increases, this method of trial and error becomes impractical since each task needs to be checked separately. However, when the task set consists of only a few tasks we can easily apply this technique to find a feasible frame size for a set of tasks otherwise un-schedulable by a cyclic scheduler.

9 Example 3: T 1 = (e 1 =1,p 1 =4); T 2 = (e 2 =1.8,p 2 =5); T 3 = (e 3 =1,p 3 =20); T 4 = (e 4 =2,p 4 =20). Solution: 1.M=LCM(4,5,20,20)=20 2.U=1/4+1.8/5+1/20+2/20= 0.76 3.F≥2 4.Possible frame sizes 2,4,5,10,20 5.2f – GCD(p i,f) ≤ d i 1 ≤ i ≤ 4 i.F=2 T 1 : 4 – 2 ≤ 4 (OK) T 2 : 4 – 1 ≤ 5 (OK) T 3 and T4: 4 – 2 ≤ 20 (OK) ii.F=4 T1 : 8 – 4 ≤ 4 (OK) T2 : 8 – 1 ≤ 5 (NO) iii.F=5 : T 1 : 10 – 1 ≤ 4 (NO) iv.F=10: T 1 : 20 – 2 ≤ 4 (NO) v.F=20: T 1 : 40 – 4 ≤ 4 (NO) Suitable size

10 0 2 4 6 8 10 12 14 16 18 20 T1T2T3T4T1T2T3T4 T1T1 T1T1 T1T1 T1T1 T2T2 T2T2 T2T2 T1T1 T2T2 T1T1 T2T2 T1T1 T1T1 T1T1 T2T2 T2T2 T1T2T3T4T1T2T3T4 T3T3 T4T4 Example 3 (cont.) 0 2 4 6 8 10 12 14 16 18 20 T1T2T3T4T1T2T3T4 T1T1 T1T1 T1T1 T1T1 T2T2 T2T2 T2T2 T1T1 T2T2 T1T1 T2T2 T1T1 T1T1 T1T1 T2T2 T2T2 T1T2T3T4T1T2T3T4 T3T3 T4T4

11 Example 4: T 1 = (p 1 =15,e 1 =1,d 1 =14); T 2 = (p 2 =20,e 2 =2,d 2 =26); T 3 = (e 3 =3, p 3 =22). Solution: 1.M=LCM(15,20,22)=660 2.U=1/15+2/20+3/22= 0.303 3.F≥3 Possible frame sizes 3,4,5,10,11,15,20,22 (Note: f divides the Major Cycle M; this is true if f divides at least one p i ) 1.2f – GCD(P i,f) ≤ d i 1 ≤ i ≤ 3 i.F=3 T 1 : 6 – 3 ≤ 14 (OK) T 2 : 6 – 1 ≤ 26 (OK) T 3 : 6 – 1 ≤ 22 (OK) ii.F=4 T 1 : 8 – 1 ≤ 14 (OK) T 2 : 8 – 4 ≤ 26 (OK) T 3 : 8 – 2 ≤ 22 (OK) iv.F = 10: T1: 20 – 5 ≤ 14 (NO) v.F= 11: T1: 22 – 1 ≤ 14 (NO) vi.F= 15: T1: 30 –15 ≤ 14 (NO) vii.F= 20: T1: 40 – 5 ≤ 14 (NO) viii.F= 22: T1: 44 – 1 ≤ 14 (NO) Suitable sizes 3,4,and 5 iii.F=5 T 1 : 10 – 5 ≤ 14 (OK) T 2 : 10 – 5 ≤ 26 (OK) T 3 : 10 – 1 ≤ 22 (OK)

12 Design steps and decisions to consider in the process of constructing a cyclic schedule 1.Determine the Major Cycle M 2.Determine the total utilization U (if >1 schedule is unfeasible) 3.Choose a frame size that meets the constraints 4.Partition jobs into slices, if necessary 5.Place slices in the frames.

13 A Generalized Task Scheduler Many practical applications typically consist of a mixture of several periodic, aperiodic, and sporadic tasks. Aperiodic and sporadic tasks can be accommodated by cyclic schedulers. In generalized scheduler: In a generalized scheduler, initially a schedule (assignment of tasks to frames) for only periodic tasks is prepared. The sporadic and aperiodic tasks are scheduled in the slack times that may be available in the frames. Slack time in a frame is the time left in the frame after a periodic task allocated to the frame completes its execution. Non-zero slack time in a frame can exist only when the execution time of the task allocated to it is smaller than the frame size.

14 Notes: A sporadic task is taken up for scheduling only if enough slack time is available for the arriving sporadic task to complete before its deadline. Therefore, a sporadic task on its arrival is subjected to an acceptance test. The acceptance test checks whether the task is likely to be completed within its deadline when executed in the available slack times. If it is not possible to meet the task’s deadline, then the scheduler rejects it and the corresponding recovery routines for the task are run. For aperiodic tasks no acceptance test is done, but no guarantee is given for a task’s completion time and best effort is made to complete the task as early as possible. An efficient implementation of this scheme is that the slack times are stored in a table and during acceptance test this table is used to check the schedulability of the arriving tasks. Another popular alternative is that the aperiodic and sporadic tasks are accepted without any acceptance test, and best effort is made to meet their respective deadlines.

15 Comparison of Cyclic with Table-Driven Scheduling Both table-driven and cyclic schedulers are important clock-driven schedulers. Cyclic scheduling: needs to set a periodic timer only once at the application initialization time. This timer continues to give an interrupt exactly at every frame boundary. No overhead of setting the timer each time a task starts.

16 Comparison of Cyclic with Table-Driven Scheduling (cont.) –Table-driven scheduling: a timer has to be set every time a task starts to run. The execution time of a typical real-time task is usually of the order of a few milliseconds. Therefore, a call to a timer is made every few mill Seconds. This represents a significant overhead and results in degraded system performance. However, if the overhead of setting a timer can be ignored, a table-driven scheduler is more proficient than a cyclic scheduler because the size of the frame that needs to be chosen should be at least as long as the size of the largest execution time of a task in the task set. This is a source of inefficiency, since this results in processor time being wasted in case of those tasks whose execution times are smaller than the chosen frame size.

17 Thanks


Download ppt "Clock Driven Scheduling By Dr. Amin Danial Asham."

Similar presentations


Ads by Google