real-time systems mark stanovich. introduction system with timing constraints (e.g., deadlines) what...
TRANSCRIPT
Real-Time Systems
Mark Stanovich
Introduction
System with timing constraints (e.g., deadlines)
What makes a real-time system different?
– Meeting timing constraints is critical• Same as incorrect function output
– 1 + 1 = 3?
• May also need to meet other constraints at the same time(e.g. power)
Examples
Airplanes Cars Movie players Robots Radar Tracking Cell phones
Difficulties
What are some difficulties producing real-time systems?
Difficulties
What are some difficulties producing real-time systems?
– Abstractions hide timing characteristics• Virtual memory
• Virtual machines
• Caching
• Layering of software functionalities
– Optimal solutions tend to be NP-complete or harder (or may not exist)
Real-Time Scheduling
Guarantee that timing constraints will always be met
Real-Time Scheduling Theory
Analysis techniques to design a system to meet timing constraints
Schedulability Analysis
– Workload models
– Processor models
– Scheduling algorithms
timePeriod = T Computation time
WCET = C
Deadline = D
Task
jobs (j1, j2, j3, …)
Release Time 8
Task = {T, C, D}
Periodic Task
Processor Model (Theory)
• Number of processors
9
Processor Model (Theory)
• Number of processors• Preemptable or non-preemptable
j1
j2
j1
j2
arrivals
time
10
Processor Model (Theory)
• Number of processors• Preemptable or non-preemptable• Processor executes at a fixed or variable
speed
time
11
Scheduling Algorithm (Theory)
Arbitrate access to shared resources
VideoPhone
GPSNavigation
MoviePlayer
?12
Real-Time Scheduling Theory
Fixed-task priority
– Priority assigned to jobs of a single task does not change
– Rate-monotonic Fixed-job priority
– Priority assigned to different jobs of a single task may change
– Earliest deadline first (EDF) Dynamic-job priority
– Priority of a single job may change
– P-fair
Real-Time Scheduling Theory
What is the time complexity for non-preemptive scheduling?
Non-preemptive Scheduling
time
time
time
time15
Anomalies
Do all jobs of a task have equal execution times?
Considering all job sizes less than the WCET is impractical?
Resctrict models to be free of anomalies
– System is predictable
– Non-preemptive EDF scheduling is not predictable
Real-Time Scheduling Theory
Guarantee jobs will meet their deadlines Examples
– Response time analysis• Compute max response time of each task
• Verify this is ≤ deadline
– Utilization bounds• Prove job can miss deadline only if
• total utilization > utilization bound
• Verify total utilization ≤ utilization bound – EDF utilization bound = 1– RM utilization bound = ln(2)
Applications
OS
Hardware
Storage Device
StorageDevice Driver
CPUScheduler
I/OScheduler
NetworkDD
Implications for OS
18
AppApp
Implications for OS
Theoretical guarantees rely on implementation matching the theory
OS must provide mechanisms that allow accurate implementation of the theory
Example:
– How can we use common OS abstractions to implement a periodic task?
Periodic Task
sched_setscheduler()
clock_nanosleep()
Difficulties
What are some other difficulties in an implemented OS that would cause problems for a real-time system?
Difficulties
What are some other difficulties in an implemented OS that would cause problems for a real-time system?
– Critical sections
– Hierarchical scheduling spaces• Interrupt handlers
– Scheduling tasks• Wake-up latency
– Shared OS components• Network device driver
• File system metadata
Priority Inversion
Lower priority job is executing while a higher priority job is pending but not executing
– Critical sections should be short
– Blocking terms must be added to schedulability analysis
Priority Inheritance
If task A is block by task B, task B inherits task A's priority
– Implementation complexity can be high• Transitive inheritance
• Multiprocessor scheduling
POSIX support for pthread_mutex_t using PTHREAD_PRIO_INHERIT
Priority Inversion
Varying CPU time priority
– Interrupts
– Soft IRQs Adhoc changes in priority Difficult to model CPU
time at a given priority
Extracting Worst-Case Behavior
Schedulability analysis requires worst-case service time
– Vary between devices
– Unpredictable
– Rarely observed• e.g., Hard drive