CprE 458/558: Real-Time Systems Dynamic Planning Based Scheduling CprE 458/558: Real-Time Systems (G. Manimaran) 1 The big picture CprE 458/558: Real-Time Systems (G. Manimaran) 2 Planning based scheduling approach • A planning based approach will evaluate different possible schedules for a given task set and chooses a final feasible schedule which satisfies all the constraints • Ideally, one should evaluate all the possible schedules before choosing the final schedule. • However, the number of possible schedules for a reasonable number of tasks is huge. Therefore, all the possible schedules in the search space cannot be evaluated CprE 458/558: Real-Time Systems (G. Manimaran) 3 Scheduler model CprE 458/558: Real-Time Systems (G. Manimaran) 4 Scheduler model (contd.) • Schedulability checking (on-line) – by the scheduler • Schedule construction (on-line) – by the scheduler • Dispatching & Resource reclaiming – by the processors; each processor runs reclaiming algorithm when it finishes a task execution. Sched-check at a most opportune time (punctual point) – Too early: tend to reject tasks because reclaiming may not be exploited fully – Too late: if rejected, the application has no time to take any recovery action CprE 458/558: Real-Time Systems (G. Manimaran) 5 Task set model • Planning based scheduler assumes worst case computation time for each task • Planning based scheduler performs nonpreemptive scheduling CprE 458/558: Real-Time Systems (G. Manimaran) 6 Planning based scheduling: search space • The search space for the planning based scheduling consists of different possible schedules for the given task set • A typical planning based scheduler will prune the search space by exploring different schedules and choose a final feasible schedule based on a heuristic function CprE 458/558: Real-Time Systems (G. Manimaran) 7 Search space: example Aperiodic Task set: Ti = (ri, ci, di) Different possible schedules T1 = (0,2,8) and T2 = (1,5,6) Schedule #1 T1 T2 2 0 6 7 8 Schedule #2 T2 1 T1 6 7 8 CprE 458/558: Real-Time Systems (G. Manimaran) 8 Spring/Myopic Scheduling Algorithm • Notations/Jargon – EATSK = earliest available time when resource Rk becomes available for shared access – EATeK = earliest available time when resource Rk becomes available for exclusive access – Avail_time(j) = earliest time at which the processor Pj becomes available for executing a task – EST(Ti) = Max(ri, min(avail_time(j)), max(EATUK) ) CprE 458/558: Real-Time Systems (G. Manimaran) 9 Understanding EST: Example R1 Time = 10 P1 Tx Time = 5 Arrival of tasks Ti Time = 3 EST(Ti) = max(3, 5, 10) = 10 CprE 458/558: Real-Time Systems (G. Manimaran) 10 Definitions • Feasible task: – A task Ti is feasible in a schedule if its timing constraint and resource requirements are met in the schedule, that is, if – EST(Ti) + Ci ≤ Di. • Feasible schedule: – A schedule for a set of tasks is said to be a feasible schedule if all the tasks are feasible in the schedule. CprE 458/558: Real-Time Systems (G. Manimaran) 11 Definitions (contd..) • Strongly feasible schedule: – A partial schedule for a subset of tasks. A partial schedule is said to be strongly feasible if all the schedules obtained by extending the current schedule by any one of the remaining tasks within a window, called the feasibility check window K are also feasible. CprE 458/558: Real-Time Systems (G. Manimaran) 12 Spring/Myopic Scheduling Algorithm Heuristic search algorithm based on a notion of strong feasibility. Branch & Bound search. 1. Sort the “n” tasks in deadline order. 2. Check for strong feasibility for K tasks which are in the feasibility check window. (i.e., Check if EST(Ti) + Ci <= di) 3. If the current vertex is strongly feasible – Compute heuristic value Hi = di + W * EST(Ti) – Choose the best (smallest) H value, let it be Hx. – Extend the schedule with task Tx. CprE 458/558: Real-Time Systems (G. Manimaran) 13 Spring/Myopic Scheduling (contd.) 4. Else Backtrack to the previous vertex, Extend the schedule with next best task. 5. Repeat steps 2-4 until either: – Feasible schedule is obtained. – Maximum backtracks reached. – No more backtracking is possible. Algorithm Complexity: O(Kn + Backtracks). Exhaustive search algorithm: O(m^n) where m: # processors; n: # tasks. CprE 458/558: Real-Time Systems (G. Manimaran) 14 Myopic scheduling: Example Task Id Ready time WCET Deadline R1 usage R2 usage T1 0 28 80 S N T2 0 24 73 N E T3 14 39 93 E E T4 5 25 89 S N T5 35 21 108 N S Ordered by their deadlines T2 T1 T4 T3 T5 Feasibility check window, K=3 Assume, w = 1 H2 = 73 + 0 H1 = 80 + 0 H4 89 ++ 0 5 H1 == 80 H4 = 89 + 5 H4 = 89 + 24 H3 = 93 + 24 H3 = 93 + 28 H5 == 93 108+ +49 35 H3 H5 = 108 + 35 T3 on P1 Search Tree (0,0) (24,0) (24,28) (49,28) (88,28) CprE 458/558: Real-Time Systems (G. Manimaran) Strongly feasible T2 on P1 T1Strongly on T5 P2 on P2 Strongly feasible Strongly T4feasible on P1 Strongly feasible feasible T3 on P1 (49,56) (95,56) NOT Strongly feasible 15 Myopic scheduling: Example Search Tree (0,0) (24,0) T1 on P2 (24,28) P2 P1 T1 T2 on P1 T4 on P1 T5 on P2 (49,28) (49,56) (88,28) (95,56) T3 on P1 T5 28 35 T2 56 T4 24 T3 49 56 95 Feasible schedule obtained using Myopic algorithm CprE 458/558: Real-Time Systems (G. Manimaran) 16