programovánísystémůreálnéhočasu real ... · programovánísystémůreálnéhočasu...

67
Programování systémů reálného času Real-Time Systems Programming *35PSR Michal Sojka, Pavel Píša Czech Technical University in Prague, FEE and CIIRC October 3, 2018 1 / 67

Upload: others

Post on 31-Aug-2019

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Programování systémů reálného časuReal-Time Systems Programming

*35PSR

Michal Sojka, Pavel Píša

Czech Technical University in Prague,FEE and CIIRC

October 3, 2018

1 / 67

Page 2: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

What is this course about?

Real-Time systems principlesWhat is a real-time system? HW, SW, ...The aim is deterministic (predictable) behaviorReal-Time scheduling (theory, analysis)Real-Time communication

Real-Time operating systems (RTOS)Demonstrated on VxWorks, similar for others RTOSes as well.

Safety critical systems

Literature

Jane W.S. Liu, Real-Time Systems, Prentice Hall, 2000.Alan Burns and Andy Wellings, Real-Time Systems and ProgrammingLanguages, Addison Wesley, 2001

2 / 67

Page 3: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

What is this course not about?

Real-Time web :-)

3 / 67

Page 4: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Lectures

1 Introduction to Real-Time Systems2 VxWorks Operating System3 POSIX 1003.1b – Standard Real-time Systems API4 Overview of other Real-Time OSes (Linux, RTEMS, ...)5 Introduction to safety engineering6 Safety analysis methods (HAZOP, ...)7 Real-Time Scheduling and Analysis (static scheduling, fixed-priority

scheduling, deadline scheduling)8 Static scheduling9 Fixed priority scheduling10 Dynamic priority scheduling11 Real-Time resource management12 Combining real-time and non-real-time tasks13 Advanced use of C language, GCC compiler

4 / 67

Page 5: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Course gradingMax. points

Tasks 1 – 7 35within 1 week 5 pointseach other week −1 points (up to -3)

Semestral work 25Code 18 pointsVersion control 4 pointsDocumentation 3 points

Exam 40Exam test min 13 max 30 pt.Oral exam max 10 pt.

Authoritative information is on the course web site!

Grade PointsA 90 – 100B 80 – 89C 70 – 79D 60 – 69E 50 – 59F <50 or <13 from exam test 5 / 67

Page 6: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Communication

Website: https://rtime.felk.cvut.cz/psrE-mail: [email protected] list: [email protected] (preferred)

6 / 67

Page 7: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Outline

1 Real-time Systems Introduction

2 Examples of real-time systems

3 Classification of real-time systems

4 Real-Time Operating Systems

7 / 67

Page 8: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

What is a Real-Time System?

Real-time system is a system whose specification includes both logicaland temporal correctness requirements.Logical correctness We get correct results, e.g. 1 + 1 = 2.Temporal correctness We get the results at the right time.Real-Time system can react in deterministic way to unpredictableevents.The system is deterministic if the analysis of the worst-case behaviorproves that all deadlines (temporal requirements) are met.

Techniques to verify the timing requirements are the focus of thiscourse.The question of specifying temporal requirements is important, but it ismostly out of the scope of this course. Typically, it is applicationspecific.

8 / 67

Page 9: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Typical Characteristics of Real-Time Systems

Event driven, reactiveMisbehave/failure is often expensive, dangerous, life or environmentthreateningParallel/multithreaded programmingContinuous operation without human interaction or supervisionStrict demands on reliability and fault-tolerancePredictable behavior

9 / 67

Page 10: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Real-Time System Examples

10 / 67

Page 11: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Real-Time System Examples

11 / 67

Page 12: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Real-Time System Examples

12 / 67

Page 13: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

There is no science in real-time systemsdesign.

Wewill see during the course…

13 / 67

Page 14: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

There is no science in real-time systemsdesign.

Wewill see during the course…

14 / 67

Page 15: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

Advances in computer hardware willsolve all real-time requirements for us.

No! Bad design and/or algorithms cancause infinite delays.

15 / 67

Page 16: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

Advances in computer hardware willsolve all real-time requirements for us.

No! Bad design and/or algorithms cancause infinite delays.

16 / 67

Page 17: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

Real-time computing is equivalent of fastcomputing.

May be for PR and advertising agencies.We understand real-time as predictable.

17 / 67

Page 18: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

Real-time computing is equivalent of fastcomputing.

May be for PR and advertising agencies.We understand real-time as predictable.

18 / 67

Page 19: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

Real-time programming is coding inassembly.

It is better to have easy to understand(and verified) code than (may be) clever

coded but unmaintainable andunreadable low level code.

19 / 67

Page 20: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

Real-time programming is coding inassembly.

It is better to have easy to understand(and verified) code than (may be) clever

coded but unmaintainable andunreadable low level code.

20 / 67

Page 21: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

``Real-time'' systems research isperformance engineering.

Deterministic timing is oftenmoreimportant than system throughput.

21 / 67

Page 22: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

``Real-time'' systems research isperformance engineering.

Deterministic timing is oftenmoreimportant than system throughput.

22 / 67

Page 23: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

The problems of real-time systemsdesign have all been solved in other

areas of computer science/engineering.

IT people are mostly concerned aboutaverage performance.

23 / 67

Page 24: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

The problems of real-time systemsdesign have all been solved in other

areas of computer science/engineering.

IT people are mostly concerned aboutaverage performance.

24 / 67

Page 25: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

It is not meaningful to talk aboutguaranteeing real-time performance,because there is no bug free software

and 100% reliable HW.

Even though everything can brake, we donot want the operating system or theapplication to be weakest point in the

chain.

25 / 67

Page 26: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

It is not meaningful to talk aboutguaranteeing real-time performance,because there is no bug free software

and 100% reliable HW.

Even though everything can brake, we donot want the operating system or theapplication to be weakest point in the

chain. 26 / 67

Page 27: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

Real-Time systems operates in a staticenvironment.

Sometimes yes, but we consider evensystems with mode changes or systems

that respond to minor HW faults.

27 / 67

Page 28: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Common Misconceptions about RT Systems(Stankovic ’88)

Real-Time systems operates in a staticenvironment.

Sometimes yes, but we consider evensystems with mode changes or systems

that respond to minor HW faults.

28 / 67

Page 29: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Are All Systems Real-Time Systems?

Question: Is a payroll processing systema real-time system?

There is a deadline – print the paychecks once a month.

According to the definition of real-timesystems it is a real-time system.However, we do not consider it as such.We are interested in systems for whichit is not a priori obvious how to meetthe timing constraints.

29 / 67

Page 30: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Are All Systems Real-Time Systems?

Question: Is a payroll processing systema real-time system?

There is a deadline – print the paychecks once a month.

According to the definition of real-timesystems it is a real-time system.However, we do not consider it as such.We are interested in systems for whichit is not a priori obvious how to meetthe timing constraints.

30 / 67

Page 31: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Are All Systems Real-Time Systems?

Question: Is a payroll processing systema real-time system?

There is a deadline – print the paychecks once a month.

According to the definition of real-timesystems it is a real-time system.However, we do not consider it as such.

We are interested in systems for whichit is not a priori obvious how to meetthe timing constraints.

31 / 67

Page 32: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Are All Systems Real-Time Systems?

Question: Is a payroll processing systema real-time system?

There is a deadline – print the paychecks once a month.

According to the definition of real-timesystems it is a real-time system.However, we do not consider it as such.We are interested in systems for whichit is not a priori obvious how to meetthe timing constraints.

32 / 67

Page 33: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Resource Availability

Resources (CPU, memory, network, ....) may be categorized as:Abundant Almost any design methodology can be used to realize

timing requirements of the application.Insufficient It is not known how to fulfill the application requirements

with any known technology.Sufficient but scarce It is possible to realize the timing requirements, but

careful resource allocation is required.

33 / 67

Page 34: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-time Systems Introduction

Example: Interactive/Multimedia Application

Interesting RT applications are here.

1980 1990 2000

Remote login

Network file access

HiFi audio

interactive video

Requirements(performance)

Sufficient but scarceresourcesInsufficient

resources

Abundantresources

Hardware resource in year X34 / 67

Page 35: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Examples of real-time systems

Outline

1 Real-time Systems Introduction

2 Examples of real-time systems

3 Classification of real-time systems

4 Real-Time Operating Systems

35 / 67

Page 36: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Examples of real-time systems

Example: Real-Time System Application

Almost each control system is a real-time system.

Example 1: A simple control system with one sensor and one actuator.

Controller

A/D

A/D Controlaction

computationD/A

Actuator(H-bridge)

Controlled plant(e.g. motor)

Sensor(e.g. IRC)

yk

rkuk

u(t)y(t)

36 / 67

Page 37: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Examples of real-time systems

A simple control system (continued)

Pseudocode of a control applicationSetup periodic timer to activate interrupt in each period T.Run the next sequence for each timer interrupt activation:

run A/D conversion and read value ycompute controller output uwrite u and start D/A conversion

The parameter T is known as sampling frequency and the section of theproper T value depends on the dynamic properties of the controlled plant.Typical values range from one second to milliseconds or even less. Badchoice makes plant stabilization impossible or setpoint/trajectory trackingless precise than demanded.

37 / 67

Page 38: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Examples of real-time systems

Example: Multi-rate systemMore complex control systems, multiple sensors and actuators. Different system partitions exhibit differentdynamics and therefore multiple sampling periods for control loops are used.

Example 2: Helicopter control system

Do 180× per second the following:Check and read sensor data. Reconfigure (mode change) control strategy in case of sensor failure.Run noise filtering and decimation on input dataAvionics control every 6þcycle (30 Hz):

Check the keyboard for the change of the control modeNormalize sensor data and coordinate transformationsDetermine reference setpoints for controllersCompute outer pitch control loop control lawCompute outer roll control loop control lawCompute outer yaw and collective control loop control law.

Every 2ndcycle (90 Hz) run inner controller with setpoints computed in 30 Hz avionics computation):Update controller output for inner pitch control loop.Update controller output for inner yaw and collective control loop.

Update controller output for inner roll control loop.Write computed control actions into outputsRun internal testsWait for the next fast cycle release time

Note: Use of harmonic sampling rates simplifies the system. .

38 / 67

Page 39: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Examples of real-time systems

Example: Hierarchical Control SystemCommands

Air trafficcontrol

Flight man-agement

Aircraft control

Responses

State es-timation

State es-timation

State es-timation

Flight data

Navigation

OperatorInterface

Virtualsystem

Virtualsystem

39 / 67

Page 40: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Examples of real-time systems

Example: Digital Signal Processing System

Processing of a signal in different representation and conversion ofthe signals between these representations.Examples:

Digital filteringCompression/decompression of video or audio streamsRadar signal processing

Response times range from a few milliseconds to several seconds.

40 / 67

Page 41: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Examples of real-time systems

Example: Radar System

Radar Memory DSPprocessors

Dataprocessing

sampleddigital data

trajectoryrecords

signalprocessingparameters

trajectoryrecords

41 / 67

Page 42: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Examples of real-time systems

Other examples of real-time system applications I

Real-time databasesTransactions have to be committed within predefined deadlineMost significant problems: Classical algorithms for transactionsscheduling and optimization aim to achieve high throughput, which isin contrast to the predictability of real-time systems.Requirements for absolute or relative temporal consistency.

MultimediaThe typical goal is to process audio and/or video at a constantsampling frequency/framerate

Analog TV framerate is 25 Hz. 50 Hz for HDTV.Additional limits: Audio and video mutual synchronization, low jitter(discrepancy in timing), low latencies for interactive transmission(video phone)

Simulations interacting with human or physical environmentVirtual reality

42 / 67

Page 43: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Classification of real-time systems

Outline

1 Real-time Systems Introduction

2 Examples of real-time systems

3 Classification of real-time systems

4 Real-Time Operating Systems

43 / 67

Page 44: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Classification of real-time systems

Real-Time Applications CategoriesPurely periodic

Every task is released periodicallyConstant or almost constant demand for system resourcesExamples: digital controller, flight control, real-time monitoring

Mostly periodicMost of the tasks are released periodicallySystem has to respond to external asynchronous eventsExamples: modern avionics or control systems

Asynchronous and predictableMost of the tasks are aperiodicRequirements for system resources can change dramatically for the consecutive taskactivations, but there are limits known in advance or their statistical distribution isknown.Examples: multimedia communication, radar signal processing and trackingfacilities

Asynchronous and non-predictableMost of the events are asynchronousTask with high level of complexityExamples: real-time control with artificial intelligence, real-time simulation, virtualreality

44 / 67

Page 45: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Classification of real-time systems

Terminology

Task τi

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15rij dij

Rij

Di

Job Jij Job Jij+1

Time

= release time (rij); the job is released at time 3.= absolute deadline (dij); the job has to be completed before

deadline; equal to 10 for this case.Relative deadline (Di) is 7.Response time (Rij) is 6.

45 / 67

Page 46: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Classification of real-time systems

Hard Real-Time Systems

Hard Deadline is a deadline that has to be met under allcircumstances.

If a hard deadline is missed, the behavior of the system is wrong and itoften has catastrophic consequences.We need mathematical apparatus for verifying that deadlines are met.But: “There is nothing like a hard deadline in the real world.”

Hard Real-Time System: is a real-time system, where all deadlines arehard.

This course is focused on hard real-time systems. They are easier toanalyze. Why?

Examples: Nuclear power plant, aircraft control.

46 / 67

Page 47: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Classification of real-time systems

Soft Real-Time Systems

Soft Deadline (required completion time) can be missed occasionally.Question: How to define the term “occasionally”?

Soft Real-Time System: a real-time system where all deadlines aresoft.Example: Multimedia applications, telephone exchanges (but whatabout emergency calls?).

47 / 67

Page 48: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Classification of real-time systems

Try to Define Term “Occasionally”

One approach: Use a statistical probability model.For example: 99% deadlines has to be met.

Another approach: Define the function describing the outcome of ajob provides as a function of its completion time.

0

1

relative deadline

Notice: To analyze system behavior according such model is morecomplicated.

48 / 67

Page 49: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Outline

1 Real-time Systems Introduction

2 Examples of real-time systems

3 Classification of real-time systems

4 Real-Time Operating Systems

49 / 67

Page 50: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Parallelism in the Real World and Control Application

Control

Control

Inter Tasks coordination

Task 1

Task 250 / 67

Page 51: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Why to Use Real-Time Operating Systems/Executives?

Parallel data processing reflects the natural parallelism of the realworld.

Synchronization between and data exchange in tasks represent theinteraction between the elements in the real world.Allow easy separation of task functions (what tasks do) and temporalcharacteristics (when it should be done).Provide an interface (API) for application to use the hardware.Allow easier and effective utilization of system resources (hardware)for applications.Higher level of abstraction simplifies application porting to differenthardware/software platforms.Provide appropriate algorithms for resource managementMutual temporal and (address) space isolation of processes.

51 / 67

Page 52: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Why to Use Real-Time Operating Systems/Executives?

Parallel data processing reflects the natural parallelism of the realworld.Synchronization between and data exchange in tasks represent theinteraction between the elements in the real world.

Allow easy separation of task functions (what tasks do) and temporalcharacteristics (when it should be done).Provide an interface (API) for application to use the hardware.Allow easier and effective utilization of system resources (hardware)for applications.Higher level of abstraction simplifies application porting to differenthardware/software platforms.Provide appropriate algorithms for resource managementMutual temporal and (address) space isolation of processes.

52 / 67

Page 53: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Why to Use Real-Time Operating Systems/Executives?

Parallel data processing reflects the natural parallelism of the realworld.Synchronization between and data exchange in tasks represent theinteraction between the elements in the real world.Allow easy separation of task functions (what tasks do) and temporalcharacteristics (when it should be done).

Provide an interface (API) for application to use the hardware.Allow easier and effective utilization of system resources (hardware)for applications.Higher level of abstraction simplifies application porting to differenthardware/software platforms.Provide appropriate algorithms for resource managementMutual temporal and (address) space isolation of processes.

53 / 67

Page 54: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Why to Use Real-Time Operating Systems/Executives?

Parallel data processing reflects the natural parallelism of the realworld.Synchronization between and data exchange in tasks represent theinteraction between the elements in the real world.Allow easy separation of task functions (what tasks do) and temporalcharacteristics (when it should be done).Provide an interface (API) for application to use the hardware.

Allow easier and effective utilization of system resources (hardware)for applications.Higher level of abstraction simplifies application porting to differenthardware/software platforms.Provide appropriate algorithms for resource managementMutual temporal and (address) space isolation of processes.

54 / 67

Page 55: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Why to Use Real-Time Operating Systems/Executives?

Parallel data processing reflects the natural parallelism of the realworld.Synchronization between and data exchange in tasks represent theinteraction between the elements in the real world.Allow easy separation of task functions (what tasks do) and temporalcharacteristics (when it should be done).Provide an interface (API) for application to use the hardware.Allow easier and effective utilization of system resources (hardware)for applications.

Higher level of abstraction simplifies application porting to differenthardware/software platforms.Provide appropriate algorithms for resource managementMutual temporal and (address) space isolation of processes.

55 / 67

Page 56: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Why to Use Real-Time Operating Systems/Executives?

Parallel data processing reflects the natural parallelism of the realworld.Synchronization between and data exchange in tasks represent theinteraction between the elements in the real world.Allow easy separation of task functions (what tasks do) and temporalcharacteristics (when it should be done).Provide an interface (API) for application to use the hardware.Allow easier and effective utilization of system resources (hardware)for applications.Higher level of abstraction simplifies application porting to differenthardware/software platforms.

Provide appropriate algorithms for resource managementMutual temporal and (address) space isolation of processes.

56 / 67

Page 57: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Why to Use Real-Time Operating Systems/Executives?

Parallel data processing reflects the natural parallelism of the realworld.Synchronization between and data exchange in tasks represent theinteraction between the elements in the real world.Allow easy separation of task functions (what tasks do) and temporalcharacteristics (when it should be done).Provide an interface (API) for application to use the hardware.Allow easier and effective utilization of system resources (hardware)for applications.Higher level of abstraction simplifies application porting to differenthardware/software platforms.Provide appropriate algorithms for resource management

Mutual temporal and (address) space isolation of processes.

57 / 67

Page 58: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Why to Use Real-Time Operating Systems/Executives?

Parallel data processing reflects the natural parallelism of the realworld.Synchronization between and data exchange in tasks represent theinteraction between the elements in the real world.Allow easy separation of task functions (what tasks do) and temporalcharacteristics (when it should be done).Provide an interface (API) for application to use the hardware.Allow easier and effective utilization of system resources (hardware)for applications.Higher level of abstraction simplifies application porting to differenthardware/software platforms.Provide appropriate algorithms for resource managementMutual temporal and (address) space isolation of processes.

58 / 67

Page 59: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Requirements of a Real-Time OS

Multi tasking or multi thread environment

Preemptive

RT task should not be blocked by other tasks if it is not necessary(shared resources).

A mechanism to prevent priority inversion or even better to avoiddeadlocksPriority driven (or EDF – earliest deadline first)Sufficient number of prioritiesGuaranteed response-time for handling of interrupts (interruptlatency)Time resolution for measurement and task activation is fine enough

59 / 67

Page 60: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Requirements of a Real-Time OS

Multi tasking or multi thread environmentPreemptive

RT task should not be blocked by other tasks if it is not necessary(shared resources).

A mechanism to prevent priority inversion or even better to avoiddeadlocksPriority driven (or EDF – earliest deadline first)Sufficient number of prioritiesGuaranteed response-time for handling of interrupts (interruptlatency)Time resolution for measurement and task activation is fine enough

60 / 67

Page 61: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Requirements of a Real-Time OS

Multi tasking or multi thread environmentPreemptive

RT task should not be blocked by other tasks if it is not necessary(shared resources).

A mechanism to prevent priority inversion or even better to avoiddeadlocksPriority driven (or EDF – earliest deadline first)Sufficient number of prioritiesGuaranteed response-time for handling of interrupts (interruptlatency)Time resolution for measurement and task activation is fine enough

61 / 67

Page 62: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Requirements of a Real-Time OS

Multi tasking or multi thread environmentPreemptive

RT task should not be blocked by other tasks if it is not necessary(shared resources).

A mechanism to prevent priority inversion or even better to avoiddeadlocks

Priority driven (or EDF – earliest deadline first)Sufficient number of prioritiesGuaranteed response-time for handling of interrupts (interruptlatency)Time resolution for measurement and task activation is fine enough

62 / 67

Page 63: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Requirements of a Real-Time OS

Multi tasking or multi thread environmentPreemptive

RT task should not be blocked by other tasks if it is not necessary(shared resources).

A mechanism to prevent priority inversion or even better to avoiddeadlocksPriority driven (or EDF – earliest deadline first)

Sufficient number of prioritiesGuaranteed response-time for handling of interrupts (interruptlatency)Time resolution for measurement and task activation is fine enough

63 / 67

Page 64: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Requirements of a Real-Time OS

Multi tasking or multi thread environmentPreemptive

RT task should not be blocked by other tasks if it is not necessary(shared resources).

A mechanism to prevent priority inversion or even better to avoiddeadlocksPriority driven (or EDF – earliest deadline first)Sufficient number of priorities

Guaranteed response-time for handling of interrupts (interruptlatency)Time resolution for measurement and task activation is fine enough

64 / 67

Page 65: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Requirements of a Real-Time OS

Multi tasking or multi thread environmentPreemptive

RT task should not be blocked by other tasks if it is not necessary(shared resources).

A mechanism to prevent priority inversion or even better to avoiddeadlocksPriority driven (or EDF – earliest deadline first)Sufficient number of prioritiesGuaranteed response-time for handling of interrupts (interruptlatency)

Time resolution for measurement and task activation is fine enough

65 / 67

Page 66: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Requirements of a Real-Time OS

Multi tasking or multi thread environmentPreemptive

RT task should not be blocked by other tasks if it is not necessary(shared resources).

A mechanism to prevent priority inversion or even better to avoiddeadlocksPriority driven (or EDF – earliest deadline first)Sufficient number of prioritiesGuaranteed response-time for handling of interrupts (interruptlatency)Time resolution for measurement and task activation is fine enough

66 / 67

Page 67: Programovánísystémůreálnéhočasu Real ... · Programovánísystémůreálnéhočasu Real-TimeSystemsProgramming *35PSR Michal Sojka, Pavel Píša Czech Technical University

Real-Time Operating Systems

Distributed Real-Time Systems

There are many reasons to use distributed systemsIncreased reliability (redundancy)Distribution of computational power to places where it is needed (fastlocal servo-control loops)Simpler interconnection of subsystems from different producers(standardized communication protocols)

Additional problems to solve: end-to-end propertiesEnd-to-end properties (e.g. response-time) depends on more resourcesand components (multiple CPUs, network, ...)One of the biggest challenges of today’s engineers

67 / 67