FIFO WITH OFFSETS HIGH SCHEDULABILITY WITH LOW OVERHEADS RTAS 18 April 13, 2018 Mitra Nasri Rob Davis Björn Brandenburg
FIFO SCHEDULING First-In-First-Out (FIFO) scheduling extremely simple very low overheads }ideal for: IoT-class devices deeply embedded systems hardware implementations very low schedulability } meeting deadlines? Nasri, Davis, and Brandenburg 2
FIFO SCHEDULING First-In-First-Out (FIFO) scheduling extremely simple very low overheads }ideal for: IoT-class devices deeply embedded systems hardware implementations very low schedulability } meeting deadlines? HIGH! THIS PAPER FIFO can actually achieve excellent schedulability! [periodic non-preemptive tasks on a uniprocessor] Nasri, Davis, and Brandenburg 2
INTUITION
THE PROBLEM WITH PLAIN FIFO SCHEDULING FIFO schedule of 3 periodic tasks: (a) τ 3 8 τ 2 3 6 Missed 12 24 36 48 τ 1 10 20 30 40 50 60 Task WCET Period! 3 8 60! 2 6 12! 1 3 10 Nasri, Davis, and Brandenburg 4
Plain FIFO is oblivious to deadlines and priorities THE PROBLEM WITH PLAIN FIFO SCHEDULING! 3 comes first deadline miss FIFO schedule of 3 periodic tasks: (a) τ 3 8 τ 2 3 6 Missed 12 24 36 48 τ 1 10 20 30 40 50 60 Task WCET Period! 3 8 60! 2 6 12! 1 3 10 Nasri, Davis, and Brandenburg 4
THE PROBLEM WITH PLAIN FIFO SCHEDULING FIFO schedule of 3 periodic tasks: (a) τ 3 8 τ 2 3 6 Missed 12 24 36 48 τ 1 10 20 30 40 50 60 Task WCET Period! 3 8 60 In fact, any work-conserving policy (EDF, RM, )! 2 6 12 must schedule! 3 here deadline miss.! 1 3 10 Nasri, Davis, and Brandenburg 4
NON-WORK-CONSERVING SCHEDULING [critical-window EDF: Nasri & Fohler, 2016] CW-EDF schedule of the same 3 periodic tasks: (b) CW-EDF schedule τ 3 Idle time 8 τ 2 3 6 12 24 36 48 τ 1 10 20 30 40 50 60 Task WCET Period! 3 8 60! 2 6 12! 1 3 10 Nasri, Davis, and Brandenburg 5
NON-WORK-CONSERVING SCHEDULING [critical-window EDF: Nasri & Fohler, 2016] CW-EDF schedule of the same 3 periodic tasks: (b) CW-EDF schedule τ 3 Idle time 8 CW-EDF considers future job arrivals in the critical window and postpones! 3 until later. τ 2 3 6 12 24 36 48 τ 1 10 20 30 40 50 60 Task WCET Period! 3 8 60! 2 6 12! 1 3 10 Nasri, Davis, and Brandenburg 5
NON-WORK-CONSERVING SCHEDULING [critical-window EDF: Nasri & Fohler, 2016] CW-EDF schedule of the same 3 periodic tasks: (b) CW-EDF schedule τ 3 Idle time 8 τ 2 3 6 12 24 36 48 τ 1 10 20 30 40 50 60 LIMITATION Task WCET Period CW-EDF incurs much! 3 higher 8 runtime 60 overheads than simple! 2 work-conserving 6 12 policies.! 1 3 10 ATMega2560 @ 16 MHz: 9.2 higher than RM! Nasri, Davis, and Brandenburg 5
INTUITION: FIFO + JUST THE RIGHT OFFSETS FIFO schedule + offset for! 3 : (c) 3 τ 3 8 τ 2 τ 1 3 6 19 12 24 36 48 10 20 30 40 50 60 Task WCET Period! 3 8 60! 2 6 12! 1 3 10 Nasri, Davis, and Brandenburg 6
INTUITION: FIFO + JUST THE RIGHT OFFSETS FIFO schedule + offset for! 3 : (c) 3 τ 3 8 τ 2 τ 1 3 6 19 12 24 36 48 10 20 30 40 50 60 Task WCET Period Move! 3 out of the way by introducing (or adjusting) a release offset.! 3 8 60 FIFO schedule becomes identical to CW-EDF schedule!! 2 6 12! 1 3 10 Nasri, Davis, and Brandenburg 6
INTUITION: FIFO + JUST THE RIGHT OFFSETS FIFO schedule + offset for! 3 : (c) 3??? [Altmeyer, Sundharam, & Navet, 2016] τ 3 8 τ 2 τ 1 3 6 19 Missed 12 24 36 48 10 20 30 40 50 60 (b) CW-EDF schedule CW-EDF schedule is identical: τ 3 Idle time 8 τ 2 3 6 12 24 36 48 τ 1 10 20 30 40 50 60 (c) FIFO schedule with offsets (o 3 = 19) Nasri, Davis, and Brandenburg 6
THIS PAPER OFFSET TUNING ALGORITHM
PROBLEM STATEMENT Given a set of n periodic non-preemptive tasks, find, for each job of each task, a release offset such that (A) the resulting FIFO schedule is feasible, and (B) the number of offsets per task is minimized. Challenges space of possible offsets is large and unstructured even ignoring (B), solving just (A) is very Altmeyer et al. randomize offsets + test not systematic scalability limitations difficult [S. Altmeyer, S. Sundharam, and N. Navet, The case for FIFO real-time scheduling, University of Luxembourg, Tech. Rep., 2016] Nasri, Davis, and Brandenburg 8
KEY INSIGHT Given a set of n periodic non-preemptive tasks, find, for each job of each task, a release offset such that (A) the resulting FIFO schedule is feasible, and (B) the number of offsets per task is minimized. Solving (A) is very difficult so we don t! OFFSET TUNING Infer offsets from a given feasible reference schedule, while greedily working towards (B). Nasri, Davis, and Brandenburg 9
OFFSET TUNING OVERVIEW given task set generate feasible schedule CW-EDF [Nasri & Fohler, 2016] or ILP/SAT solving or bespoke planning heuristics or reference schedule offset tuning algorithm offset compression offset vectors compact offline online offset table simple FIFO scheduler + job release offsets Nasri, Davis, and Brandenburg 10
SCHEDULE EQUIVALENCY A schedule S 1 is equivalent to S 2 if (i) they schedule the same jobs, (ii) in the same order, and (iii) jobs start no later in S 1 than in S 2. Non-preemptive execution jobs also complete no later in S 1 than in S 2 Offset Tuning ensures FIFO schedule is equivalent to reference schedule Nasri, Davis, and Brandenburg 11
POI: POTENTIAL OFFSETS INTERVAL POI of a job: range of release offsets that guarantee schedule equivalency. FIFO schedule + offset for! 3 : (c) 3 τ 3 8 τ 2 τ 1 3 6 19 12 24 36 48 10 20 30 40 50 60 Nasri, Davis, and Brandenburg 12
POI: POTENTIAL OFFSETS INTERVAL POI of a job: range of release offsets that guarantee schedule equivalency. POI: any release time of! 3 in (12, 19] FIFO schedule + offset for! 3 : will yield an equivalent schedule. (c) 3 τ 3 8 τ 2 τ 1 3 6 19 12 24 36 48 10 20 30 40 50 60 Nasri, Davis, and Brandenburg 12
OFFSET PARTITION Consecutive jobs of a task form an offset partition if they have mutually intersecting POIs. can be assigned a single offset POI job 1 POI job 2 POI job 3 POI job 4 POI job 5 POI job 6 offset value offset partition 1 offset partition 2 offset partition 3 offset partitioning not necessarily unique Nasri, Davis, and Brandenburg 13
OFFSET TUNING ALGORITHM (SIMPLIFIED) for each task! i in deadline-monotonic order: greedily create offset partitions for!i assuming jobs of larger-deadline tasks are released as in reference schedule Nasri, Davis, and Brandenburg 14
Need to start somewhere OFFSET TUNING ALGORITHM (SIMPLIFIED) shorter relative deadline = fewer options for each task! i in deadline-monotonic order: greedily create offset partitions for!i assuming jobs of larger-deadline tasks are released as in reference schedule Release times of not-yet-processed jobs still unknown speculate. Mis-speculation increases the number of offset partitions, but does not cause the algorithm to fail. Nasri, Davis, and Brandenburg 14
PROPERTIES OF OFFSET TUNING REFERENCE SCHEDULE EQUIVALENCY In the resulting FIFO schedule, no job completes later than in the original reference schedule. PER-TASK MINIMAL OFFSET PARTITIONS The greedy offset partitioning strategy yields a minimal number of offset partitions (for a given task). NON-MINIMAL OFFSET PARTITIONS FOR ENTIRE TASK SET Deadline-monotonic processing order does not guarantee overall minimal number of offset partitions (but works well empirically). Nasri, Davis, and Brandenburg 15
SINGLE-OFFSET HEURISTICS What if we want just a single offset per task? no extra memory required compatibility with existing systems FST: First-Start-Time Heuristic pick start time of first job in reference schedule FOP: First-Offset-Partition Heuristic pick offset from first offset partition of the task Nasri, Davis, and Brandenburg 16
EVALUATION
EVALUATION QUESTIONS Q1: Does FIFO + Offset Tuning still have low runtime overheads? Q2: Does FIFO + Offset Tuning (FIFO-OT) significantly improve schedulability relative to EDF/RM? Q3: How many offsets are assigned? Q4: How much memory is needed? Nasri, Davis, and Brandenburg 18
PROTOTYPE PLATFORM Arduino Mega 2560 ATMega2560 microcontroller 16 MHz CPU 256 KiB Flash 8 KiB SRAM (no cache) gcc: -Os http://people.mpi-sws.org/~bbb/papers/details/rtas18 Nasri, Davis, and Brandenburg 19
EVALUATED SCHEDULERS NP-RM plain non-preemptive rate-monotonic scheduling NP-EDF plain non-preemptive EDF CW-EDF Critical Window EDF [Nasri & Fohler, 2016] TD Table-driven (a.k.a. static or time-triggered) scheduling OE Offline Equivalence [Nasri & Brandenburg, 2017] FIFO-OT FIFO + Offset Tuning [this paper] Nasri, Davis, and Brandenburg 20
overhead (microseconds) CW-EDF NP-EDF NP-RM OE FIFO-OT TD CW-EDF NP-EDF NP-RM OE FIFO-OT TD CW-EDF NP-EDF NP-RM OE FIFO-OT TD CW-EDF NP-EDF NP-RM OE FIFO-OT TD Q1: RUNTIME OVERHEADS 450 400 3 tasks 6 tasks 9 tasks 12 tasks Max Min Avg 404 350 300 308 250 200 150 100 50 76 48 36 44 44 32 156 72 32 56 52 32 104 36 64 60 32 136 44 76 68 32 0 Nasri, Davis, and Brandenburg 21
CW-EDF NP-EDF NP-RM OE FIFO-OT TD CW-EDF NP-EDF NP-RM OE FIFO-OT TD CW-EDF NP-EDF NP-RM OE FIFO-OT TD CW-EDF NP-EDF NP-RM OE FIFO-OT TD overhead (microseconds) LOW RUNTIME OVERHEADS Q1: RUNTIME OVERHEADS FIFO-OT is much cheaper than CW-EDF and roughly similar to NP-RM and OE. 450 400 350 300 250 3 tasks 6 tasks 9 tasks 12 tasks Max Min Avg 404 308 200 150 100 50 76 48 36 44 44 32 156 72 32 56 52 32 104 36 64 60 32 136 44 76 68 32 0 Nasri, Davis, and Brandenburg 22
WORKLOADS based on Kramer, Ziegenbein, and Hamann, Real world automotive benchmark for free, WATERS 2015 Periods non-uniformly in {1, 2, 5, 10, 20, 50, 100, 200, 1000} milliseconds Runnable BCETs and WCETs randomly generated based on statistics provided by Kramer et al. Runnable Packing Runnables aggregated into tasks until random utilization threshold reached utilization threshold ensures feasibility under non-preemptive scheduling Nasri, Davis, and Brandenburg 24
Q2: SCHEDULABILITY GAINS schedulability ratio 1 0,9 0,8 0,7 0,6 0,5 0,4 0,3 0,2 0,1 0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 utilization NP-RM plain FIFO FIFO + FST FIFO + FOP FIFO + offset tuning Nasri, Davis, and Brandenburg 25
As expected, plain FIFO exhibits very low schedulability. Q2: SCHEDULABILITY GAINS schedulability ratio 1 0,9 0,8 0,7 0,6 0,5 0,4 0,3 0,2 0,1 0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 utilization NP-RM plain FIFO FIFO + FST FIFO + FOP FIFO + offset tuning Nasri, Davis, and Brandenburg 26
Q2: SCHEDULABILITY GAINS Assigning even a single offset per task can substantially increase schedulability! schedulability ratio 1 0,9 0,8 0,7 0,6 0,5 0,4 0,3 0,2 0,1 0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 utilization NP-RM plain FIFO FIFO + FST FIFO + FOP FIFO + offset tuning Nasri, Davis, and Brandenburg 27
Q2: SCHEDULABILITY GAINS schedulability ratio 1 0,9 0,8 0,7 0,6 0,5 0,4 0,3 0,2 0,1 0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 utilization NP-RM plain FIFO FIFO + FST FIFO + FOP FIFO + offset tuning FIFO-OT achieves much higher schedulability, thanks to CW-EDF reference schedule. Nasri, Davis, and Brandenburg 28
(a) Q3: NUMBERS OF OFFSETS PER TASK 1 0.8 0.6 0.4 0.2 0 0.86 0 <=4 <=8 <=12 percentage of task sets <=16 <=20 <=24 <=28 <=32 <=36 <=40 <=44 <=48 <=52 <=56 <=60 number of offsets per task Most tasks require only few offset partitions. Nasri, Davis, and Brandenburg 30
(c) 300 NUMBERS OF UNIQUE OFFSETS PER TASK SET number of offsets/distinct offsets per task set 250 200 150 100 50 0 offsets per task set (for offset tuning) 241 number of distinct offsets per task set 96 0 7 14 21 28 34 44 8 10 9 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 utilization Across the hyper-period, offsets values repeat cyclicly. Opportunity to store offsets efficiently (compression). Nasri, Davis, and Brandenburg 31
(c) NUMBERS OF UNIQUE OFFSETS PER TASK SET Up to 25 reduction in the number of offset values that must be stored. 300 number of offsets/distinct offsets per task set 250 200 150 100 50 0 offsets per task set (for offset tuning) 241 number of distinct offsets per task set 96 0 7 14 21 28 34 44 8 10 9 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 utilization Across the hyper-period, offsets values repeat cyclicly. Opportunity to store offsets efficiently (compression). Nasri, Davis, and Brandenburg 31
percentage of task sets MEMORY USAGE 1 0.9 0.8 0.7 0.6 0.5 0.4 offset tuning offline equivalence table driven 0.3 0.2 0.1 0 <= 5 <= 20 <= 100 <= 200 <= 300 <= 400 <= 500 <= 600 <= 700 <= 800 <= 900 <= 1000 required memory (B) <= 1100 <= 1500 <= 3000 <= 7500 <= 12500 <= 20000 [non-linear scale] Nasri, Davis, and Brandenburg 33
MEMORY USAGE 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 <= 5 <= 20 <= 100 <= 200 <= 300 <= 400 <= 500 <= 600 <= 700 <= 800 <= 900 <= 1000 <= 1100 percentage of task sets Both OE and FIFO-OT require much less memory than table-driven scheduling. dozens to hundreds of bytes vs. 10KiB-20KiB offset tuning offline equivalence table driven required memory (B) <= 1500 <= 3000 <= 7500 <= 12500 <= 20000 [non-linear scale] Nasri, Davis, and Brandenburg 34
percentage of task sets MEMORY USAGE 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 offset tuning offline equivalence table driven For a fraction of task sets, OE requires slightly less memory (< 100 bytes difference) 0.1 0 <= 5 <= 20 <= 100 <= 200 <= 300 <= 400 <= 500 <= 600 <= 700 <= 800 <= 900 <= 1000 required memory (B) <= 1100 <= 1500 <= 3000 <= 7500 <= 12500 <= 20000 [non-linear scale] Nasri, Davis, and Brandenburg 35
percentage of task sets MEMORY USAGE but FIFO-OT can support over 90% of task sets with 250 bytes of offset data. 1 0.9 0.8 0.7 0.6 0.5 0.4 offset tuning offline equivalence table driven 0.3 0.2 0.1 0 <= 5 <= 20 <= 100 <= 200 <= 300 <= 400 <= 500 <= 600 <= 700 <= 800 <= 900 <= 1000 required memory (B) <= 1100 <= 1500 <= 3000 <= 7500 <= 12500 <= 20000 [non-linear scale] Nasri, Davis, and Brandenburg 36
IMPLEMENTATION FOOTPRINT code size 1,004 1000 global data (for 12 tasks) 928 memory used (byte) 800 600 400 312 414 490 824 229 215 200 108 156 48 10 0 NP-FP TD NP-EDF FIFO-OT CW-EDF OE Nasri, Davis, and Brandenburg 37
IMPLEMENTATION FOOTPRINT About 150 bytes smaller footprint than OE (RAM + code). code size 1,004 1000 global data (for 12 tasks) 928 memory used (byte) 800 600 400 312 414 490 824 229 215 200 108 156 48 10 0 NP-FP TD NP-EDF FIFO-OT CW-EDF OE Nasri, Davis, and Brandenburg 38
IMPLEMENTATION FOOTPRINT code size 1,004 1000 global data (for 12 tasks) 928 memory used (byte) 800 About 650 bytes more than most simple implementation (RAM + code). 600 490 414 400 312 824 229 215 200 108 156 48 10 0 NP-FP TD NP-EDF FIFO-OT CW-EDF OE Nasri, Davis, and Brandenburg 39
CONCLUSION
FIFO SCHEDULING OFFSET TUNING OVERVIEW First-In-First-Out (FIFO) scheduling extremely simple very low overheads }ideal for: IoT-class devices deeply embedded systems hardware implementations given task set generate feasible schedule reference schedule CW-EDF [Nasri & Fohler, 2016] or ILP/SAT solving or bespoke planning heuristics or very low schedulability } meeting deadlines? HIGH! THIS PAPER FIFO can actually achieve excellent schedulability! [periodic non-preemptive tasks on a uniprocessor] offset tuning algorithm offline online offset vectors offset compression compact offset table simple FIFO scheduler + job release offsets Nasri, Davis, and Brandenburg 2 Nasri, Davis, and Brandenburg 10 PROPERTIES OF OFFSET TUNING REFERENCE SCHEDULE EQUIVALENCY In the resulting FIFO schedule, no job completes later than in the original reference schedule. PER-TASK MINIMAL OFFSET PARTITIONS The greedy offset partitioning strategy yields a minimal number of offset partitions (for a given task). NON-MINIMAL OFFSET PARTITIONS FOR ENTIRE TASK SET Deadline-monotonic processing order does not guarantee overall minimal number of offset partitions (but works well empirically). schedulability ratio 1 0,9 0,8 0,7 0,6 0,5 0,4 0,3 0,2 0,1 0 Q2: SCHEDULABILITY GAINS 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 utilization NP-RM plain FIFO FIFO + FST FIFO + FOP FIFO + offset tuning FIFO-OT achieves much higher schedulability, thanks to CW-EDF reference schedule. Nasri, Davis, and Brandenburg 15 Nasri, Davis, and Brandenburg 28
APPENDIX
CAN OFFSET TUNING BE APPLIED TO EDF OR FIXED-PRIORITY SCHEDULING? yes in principle, but no equivalence guarantee FIFO schedule + offset for! 3 : (c) 3 (c) FIFO schedule with offsets (o 3 = 19) 8 τ 3 τ 2 τ 1 6 3 19 12 24 36 48 10 20 30 40 50 60 (d) RM NP-FP schedule schedule + offset with for! rate-monotonic 3 : priorities and offsets (o 3 = 19) τ 3 8 τ 2 τ 1 3 6 19 Missed 12 24 36 48 10 20 30 40 50 60 Nasri, Davis, and Brandenburg 44