ECE 5780 RealTime Systems Cyclic Scheduling Slides adapted
























- Slides: 24
ECE 5780 Real-Time Systems Cyclic Scheduling Slides adapted from various sources
Last Time • Modeling – Workload model • Task and its attributes – Resource model – Algorithms • WCET analysis 2
Today’s Objectives • To learn about static offline scheduling • To understand the concept of slack stealing 3
Scheduling • A scheduling scheme provides two features – An algorithm for ordering the use of system resources, especially CPUs – A means of predicting the worst-case behavior of the system when the scheduling algorithm is applied • The prediction can then be used to confirm the temporal requirements of the application • Given n independent tasks, how many ways are there to schedule them non-preemptively? 4
3 Main Approaches to Scheduling • Weighted round-robin • Clock-driven (aka time-driven and time-triggered) – Cyclic scheduling • Priority-driven – Next time 5
Weighted Round-Robin Approach • WRR • Each task given a weight which reflects importance • Tends to increase finish times and hence response times • But has its place – E. g. , in a high-speed switched network 6
Clock-Driven Approach: Cyclic Scheduling • Schedule all tasks offline and use a lookup table at runtime • Pros – Easy to analyze – Minimum runtime overhead – Can use a more sophisticated scheduling algorithm • Cons: inflexible, lookup table can be large – Restrictive task model • • n periodic tasks, n is fixed All task parameters are known offline Ji, k ready to execute at release time ri, k Aperiodic tasks accepted but put in a different queue 7
How Long to Schedule? • Recall that tasks are periodic so task release pattern will eventually repeat itself • Hyperperiod • Number of jobs in a hyperperiod 8
How Does It Work at Runtime? Input: stored schedule (tk, τ(tk)), k = 0, 1, N-1 Task CYCLIC_SCHEDULER: set the next decision point i and table entry k to 0 set the timer to expire at tk while(1): accept timer interrupt if an aperiodic job is executing, preempt it current task τC = τ (tk) i=i+1 compute the next table entry k = i mod(N) set the timer to expire at tk+1 if system is idle let the job at the head of the aperiodic queue execute else execute τC go to sleep end CYCLIC_SCHEDULER 9
Cyclic Executives • Special type of clock-driven approach • Idea is to provide some structure/regularity in setting the timer – Divide time into equal slices (called minor cycles or frames) 10
How Does It Work? (1) 11
How Does It Work? (2) every_major_cycle_do: read all in_signals run_minor_cycle_1_processes wait_for_interrupt write all out_signals … read all in_signals run_minor_cycle_n_processes wait_for_interrupt write all out_signals No preemptions inside 12
Consequences of Using Frames • No preemption inside a frame • Job release times must be at the start a each frame – Why? – Restrict frame size choice 13
Selecting Frame Size/Minor Cycle • Ideally, frame size f should be • f should divide H – If f is too large, hard to determine a deadline miss • One way – f = GCD(T 1, T 2, …, Tn) • But determining f this way is not perfect – Sum of execution times may not fit in a minor cycle – Can be error-prone to split code 14
Example Task C T τ1 τ2 10 25 8 25 τ3 τ4 τ5 5 50 4 50 2 100 Task C T τ1 τ2 10 75 20 100 15
Schedulability Test • Sum of execution times in each minor cycle ≤ frame size • If succeeded – The schedule, whose length corresponds to the major cycle, is repeated for all executions • If failed – Break tasks that do not fit into two or more tasks and run the different parts in different minor cycles 16
Including Aperiodic Jobs • Slack stealing – Execute aperiodic jobs ahead of periodic jobs whenever possible • At the beginning of each minor cycle – If the aperiodic queue is nonempty, the cyclic executive can schedule aperiodic jobs during slack time without causing any jobs to miss their deadlines – When queue is empty or slack is zero, periodic jobs are executed 17
Example A 2 Assume preemptions are not allowed 18
Average Response Time of Aperiodic Jobs U is the total utilization of periodic tasks 19
Including Sporadic Jobs • Hard deadlines! • Acceptance test – Look at periodic/sporadic jobs and see if new job fits – If not, recovery action 20
Example Acceptance decisions occur at the beginning of a frame Why? 21
Handling Overruns • Three options – Abort – Preempt the offending job and convert it into an aperiodic job – Continue executing • Could lead to a domino effect 22
Problems with Cyclic Exec. • All task periods must be a multiple of the minor cycle time • Sporadic activities are difficult to incorporate • The cyclic executive is difficult to construct and difficult to maintain — it is a NP-hard problem
Today’s Objectives • To learn about static offline scheduling • To understand the concept of slack stealing 25