sporadic server scheduling in linux theory vs. practice mark stanovich theodore baker andy wang
TRANSCRIPT
![Page 1: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/1.jpg)
Sporadic Server Scheduling in Linux
Theory vs. Practice
Mark Stanovich
Theodore Baker
Andy Wang
![Page 2: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/2.jpg)
Real-Time Scheduling Theory
Analysis techniques to design a system to meet timing constraints
Schedulability analysis
– Workload models
– Processor models
– Scheduling algorithms
![Page 3: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/3.jpg)
Real-Time Scheduling Theory
Analysis techniques to design a system to meet timing constraints
Schedulability analysis
– Workload models
– Processor models
– Scheduling algorithms
![Page 4: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/4.jpg)
timePeriod = T Computation time
WCET = C
Deadline = D
Task
jobs (j1, j2, j3, …)
Release time 4
Task = {T, C, D}
Periodic Task
![Page 5: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/5.jpg)
Periodic Task
sched_setscheduler(SCHED_FIFO)
clock_nanosleep()
![Page 6: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/6.jpg)
Periodic Task
Assumptions WCET is reliable Arrivals are periodic
Not realistic for most tasks
![Page 7: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/7.jpg)
Polling Server
time
time
Job arrivals
Initialbudget
Replenishment period
![Page 8: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/8.jpg)
Polling Server
Type of aperiodic server CPU time no worse than an equivalent
periodic task Can be modeled as a periodic task
WCET = Initial Budget Period = Replenishment Period
Budget consumed as CPU time is used CPU time forfeited if not used
Replenish budget every period
![Page 9: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/9.jpg)
Polling Server
Good Bounds CPU time Analyzable workload Simplicity
Can be better Faster response time if budget is not forfeited
![Page 10: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/10.jpg)
Sporadic Server
time
time
Job arrivals
Initialbudget
Replenishment period
replenishments
![Page 11: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/11.jpg)
Sporadic Server
Originally proposed by Sprunt et. al. Parameters
– Initial budget
– Replenishment period Bounds CPU interference for other tasks Fits into the periodic task workload model Better avg. response time than polling server
![Page 12: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/12.jpg)
Sporadic Server
Scheduling algorithm for fixed-task-priority systems
Can be used in UNIX priority model SCHED_SPORADIC is a version of SS
defined in POSIX definition
![Page 13: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/13.jpg)
Implementation
Linux 2.6.38 Softirq threading patch ported from earlier RT
patch Sporadic server implementation
Uniprocessor
![Page 14: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/14.jpg)
Sporadic Server Performance
Metrics Interference for lower priority tasks Average response time
![Page 15: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/15.jpg)
An experiment
Sends UDP packet withcurrent timestamp
Receives UDP packets
Calculate response time based on arrival at UDP layer
Measure CPU time for 10 second burst
A B
![Page 16: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/16.jpg)
Measuring CPU Time
Regher's “hourglass” technique Constantly read time stamp counter
– Detect preemptions by larger gaps
– Sum execution chunks Hourglass thread lower than SS thread
– Measures interference from SS thread
![Page 17: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/17.jpg)
Measuring CPU Time
Network receive thread Sporadic and polling server
Budget = 1 msec Period = 10 msec
SCHED_FIFO Hourglass thread
SCHED_FIFO Lower priority than network receive thread
![Page 18: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/18.jpg)
CPU Utilization
![Page 19: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/19.jpg)
Response Time
![Page 20: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/20.jpg)
Interference
SS budget limited to CPU demand Additional overheads lower priority tasks
– Context switch time
– Cache eviction and reloading Not in theoretical workload model Guarantees of theory require interference to
be included in the analysis
![Page 21: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/21.jpg)
Polling Server
21
time
= aperiodic job CPU time
= aperiodic job arrival
timebudget CS+SS 2
![Page 22: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/22.jpg)
Sporadic Server
22
time
= aperiodic job CPU time
= aperiodic job arrival
= replenishment period
max_repl2 timebudget CS+SS
![Page 23: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/23.jpg)
Over Provisioning
All context switch time may not be used
– e.g., one replenishment per period Account for CS time on-line
– Charge SS for each preemption
![Page 24: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/24.jpg)
CPU Utilization
![Page 25: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/25.jpg)
Response Time
![Page 26: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/26.jpg)
Response Time
![Page 27: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/27.jpg)
Analysis Light load
– Sporadic Server
• Low response time
– Polling Server
• High response time Heavy load
– Sporadic Server
• High response time
• Dropped packets
– Polling Server
• Low response time
• No dropped packets
27
![Page 28: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/28.jpg)
Can we get the best of both?
28
Sporadic ServerLight loads
Polling ServerHeavy loads
![Page 29: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/29.jpg)
Hybrid Server
How to switch
– Ensure bounded interference
– SS with 1 replenishment is same as polling server
– Coalesce replenishments• Push replenishments further into the future
Switching point
– Server has work but no budget
![Page 30: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/30.jpg)
Sporadic Server
time
![Page 31: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/31.jpg)
Sporadic Server
31
time
![Page 32: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/32.jpg)
Response Time
![Page 33: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/33.jpg)
CPU Utilization
![Page 34: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/34.jpg)
Switching
Immediate coalescing may be too extreme CPU time could be used for better response time
Gradual approach Coalesce a few replenishments
![Page 35: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/35.jpg)
Sporadic Server
35
time
![Page 36: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/36.jpg)
Sporadic Server
36
time
![Page 37: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/37.jpg)
Sporadic Server
37
time
![Page 38: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/38.jpg)
Response Time
![Page 39: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/39.jpg)
CPU Utilization
![Page 40: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/40.jpg)
Conclusion
Theoretical analysis provides solid guarantees Implementation must match abstract models
Additional interference terms need to be considered
SS can fit into the theoretical analysis
![Page 41: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/41.jpg)
Deferrable Server
![Page 42: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/42.jpg)
Deferrable Server
Bandwidth Preserving Allow server to retain budget
Periodically replenish budget WCET != Budget
![Page 43: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/43.jpg)
Response Time
![Page 44: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/44.jpg)
44
Replenishment Policy
replenishment period
replenishment
initial budget
time
arrival time(work available for server)
![Page 45: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/45.jpg)
45
Bandwidth Preservation
replenishment
initial budget
time
arrival time(work available for server)
replenishment period
![Page 46: Sporadic Server Scheduling in Linux Theory vs. Practice Mark Stanovich Theodore Baker Andy Wang](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d1f5503460f949f2448/html5/thumbnails/46.jpg)
Sporadic Server
46
time