real-time systems mark stanovich. introduction system with timing constraints (e.g., deadlines) what...

26
Real-Time Systems Mark Stanovich

Upload: catherine-wood

Post on 03-Jan-2016

229 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Real-Time Systems

Mark Stanovich

Page 2: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

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)

Page 3: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Examples

Airplanes Cars Movie players Robots Radar Tracking Cell phones

Page 4: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Difficulties

What are some difficulties producing real-time systems?

Page 5: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

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)

Page 6: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Real-Time Scheduling

Guarantee that timing constraints will always be met

Page 7: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Real-Time Scheduling Theory

Analysis techniques to design a system to meet timing constraints

Schedulability Analysis

– Workload models

– Processor models

– Scheduling algorithms

Page 8: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

timePeriod = T Computation time

WCET = C

Deadline = D

Task

jobs (j1, j2, j3, …)

Release Time 8

Task = {T, C, D}

Periodic Task

Page 9: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Processor Model (Theory)

• Number of processors

9

Page 10: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Processor Model (Theory)

• Number of processors• Preemptable or non-preemptable

j1

j2

j1

j2

arrivals

time

10

Page 11: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Processor Model (Theory)

• Number of processors• Preemptable or non-preemptable• Processor executes at a fixed or variable

speed

time

11

Page 12: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Scheduling Algorithm (Theory)

Arbitrate access to shared resources

VideoPhone

GPSNavigation

MoviePlayer

?12

Page 13: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

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

Page 14: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Real-Time Scheduling Theory

What is the time complexity for non-preemptive scheduling?

Page 15: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Non-preemptive Scheduling

time

time

time

time15

Page 16: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

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

Page 17: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

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)

Page 18: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Applications

OS

Hardware

Storage Device

StorageDevice Driver

CPUScheduler

I/OScheduler

NetworkDD

Implications for OS

18

AppApp

Page 19: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

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?

Page 20: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Periodic Task

sched_setscheduler()

clock_nanosleep()

Page 21: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Difficulties

What are some other difficulties in an implemented OS that would cause problems for a real-time system?

Page 22: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

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

Page 23: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

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

Page 24: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

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

Page 25: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Priority Inversion

Varying CPU time priority

– Interrupts

– Soft IRQs Adhoc changes in priority Difficult to model CPU

time at a given priority

Page 26: Real-Time Systems Mark Stanovich. Introduction System with timing constraints (e.g., deadlines) What makes a real-time system different? – Meeting timing

Extracting Worst-Case Behavior

Schedulability analysis requires worst-case service time

– Vary between devices

– Unpredictable

– Rarely observed• e.g., Hard drive