14/10/2015 e-mail: [email protected] computer scuola ... · 14/10/2015 1 giorgio buttazzo e-mail:...

36
Giorgio Buttazzo E-mail: [email protected] Scuola Superiore Sant’Anna

Upload: lethuan

Post on 18-Feb-2019

229 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

1

Giorgio ButtazzoE-mail: [email protected]

Scuola Superiore Sant’Anna

Definition

Real-Time Systems are computing systems that must perform computation within given timing constraints.

They are typically embeddedin a larger system to control its functions:

Real-Time Embedded Systems

EmbeddedComputer

Controlled System

Sensors

Motors

Evolution of Embedded Systems

Embedded computing systems have grownexponentially in several application domains:

1970 1990 2000 20100

Number ofembeddedcomputers

1980 year

avionics

robotics

automotive

consumer electronics

multimedia

Computers everywhere

Today, 98% of all processors in the planet areembedded in other objects:

Typical applications

avionics

automotive

robotics

industrial automation

telecommunications

multimedia systems

consumer electronics

From Hardware to Software

We are experiencing a dematerialization process inwhich many functions are converted into software.

Examples– Money

– Documents– Books

– Music

– Pictures– Movies

– Tickets

– Education

Page 2: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

1

Giorgio ButtazzoE-mail: [email protected]

Scuola Superiore Sant’Anna

Definition

Real-Time Systems are computing systems that must perform computation within given timing constraints.

They are typically embeddedin a larger system to control its functions:

Real-Time Embedded Systems

EmbeddedComputer

Controlled System

Sensors

Motors

Evolution of Embedded Systems

Embedded computing systems have grownexponentially in several application domains:

1970 1990 2000 20100

Number ofembeddedcomputers

1980 year

avionics

robotics

automotive

consumer electronics

multimedia

Computers everywhere

Today, 98% of all processors in the planet areembedded in other objects:

Typical applications

avionics

automotive

robotics

industrial automation

telecommunications

multimedia systems

consumer electronics

From Hardware to Software

We are experiencing a dematerialization process inwhich many functions are converted into software.

Examples– Money

– Documents– Books

– Music

– Pictures– Movies

– Tickets

– Education

Page 3: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

1

Giorgio ButtazzoE-mail: [email protected]

Scuola Superiore Sant’Anna

Definition

Real-Time Systems are computing systems that must perform computation within given timing constraints.

They are typically embeddedin a larger system to control its functions:

Real-Time Embedded Systems

EmbeddedComputer

Controlled System

Sensors

Motors

Evolution of Embedded Systems

Embedded computing systems have grownexponentially in several application domains:

1970 1990 2000 20100

Number ofembeddedcomputers

1980 year

avionics

robotics

automotive

consumer electronics

multimedia

Computers everywhere

Today, 98% of all processors in the planet areembedded in other objects:

Typical applications

avionics

automotive

robotics

industrial automation

telecommunications

multimedia systems

consumer electronics

From Hardware to Software

We are experiencing a dematerialization process inwhich many functions are converted into software.

Examples– Money

– Documents– Books

– Music

– Pictures– Movies

– Tickets

– Education

Page 4: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

1

Giorgio ButtazzoE-mail: [email protected]

Scuola Superiore Sant’Anna

Definition

Real-Time Systems are computing systems that must perform computation within given timing constraints.

They are typically embeddedin a larger system to control its functions:

Real-Time Embedded Systems

EmbeddedComputer

Controlled System

Sensors

Motors

Evolution of Embedded Systems

Embedded computing systems have grownexponentially in several application domains:

1970 1990 2000 20100

Number ofembeddedcomputers

1980 year

avionics

robotics

automotive

consumer electronics

multimedia

Computers everywhere

Today, 98% of all processors in the planet areembedded in other objects:

Typical applications

avionics

automotive

robotics

industrial automation

telecommunications

multimedia systems

consumer electronics

From Hardware to Software

We are experiencing a dematerialization process inwhich many functions are converted into software.

Examples– Money

– Documents– Books

– Music

– Pictures– Movies

– Tickets

– Education

Page 5: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

1

Giorgio ButtazzoE-mail: [email protected]

Scuola Superiore Sant’Anna

Definition

Real-Time Systems are computing systems that must perform computation within given timing constraints.

They are typically embeddedin a larger system to control its functions:

Real-Time Embedded Systems

EmbeddedComputer

Controlled System

Sensors

Motors

Evolution of Embedded Systems

Embedded computing systems have grownexponentially in several application domains:

1970 1990 2000 20100

Number ofembeddedcomputers

1980 year

avionics

robotics

automotive

consumer electronics

multimedia

Computers everywhere

Today, 98% of all processors in the planet areembedded in other objects:

Typical applications

avionics

automotive

robotics

industrial automation

telecommunications

multimedia systems

consumer electronics

From Hardware to Software

We are experiencing a dematerialization process inwhich many functions are converted into software.

Examples– Money

– Documents– Books

– Music

– Pictures– Movies

– Tickets

– Education

Page 6: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

1

Giorgio ButtazzoE-mail: [email protected]

Scuola Superiore Sant’Anna

Definition

Real-Time Systems are computing systems that must perform computation within given timing constraints.

They are typically embeddedin a larger system to control its functions:

Real-Time Embedded Systems

EmbeddedComputer

Controlled System

Sensors

Motors

Evolution of Embedded Systems

Embedded computing systems have grownexponentially in several application domains:

1970 1990 2000 20100

Number ofembeddedcomputers

1980 year

avionics

robotics

automotive

consumer electronics

multimedia

Computers everywhere

Today, 98% of all processors in the planet areembedded in other objects:

Typical applications

avionics

automotive

robotics

industrial automation

telecommunications

multimedia systems

consumer electronics

From Hardware to Software

We are experiencing a dematerialization process inwhich many functions are converted into software.

Examples– Money

– Documents– Books

– Music

– Pictures– Movies

– Tickets

– Education

Page 7: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

2

Sensor

MotorSensorMotor

ControlUnit

Steer by Wire Why?

1. Software is more flexible than hardware

2. It can be quickly changed/adapted/updated

3. It can be upgraded remotely

4. It can evolve into intelligent control algorithms

5. It has no mass, so it can travel at the speed of light

There are many advantages

Increasing complexity

Related problems

Difficult design

Less predictability

Less reliability

The price to be paid is a higher software complexity .

Novel solutions for:

Component-based software design

Analysis for guaranteeing predictability and safety

Testing

Complexity and bugs

Software bugs increase with complexity:

1 K 100 K 1 M 10 M0

10

100

1000

10.000

10K

Lines of code

bugs

Reliability does not only depend on the correctness ofsingle instructions, but also on when they areexecuted:

controller

output

inputt

t +

A correct action executed too late can be useless oreven dangerous.

Software reliability Real-Time Systems

Computing systems that must guaranteebounded and predictable response timesare called real-time systems .

Predictability of response times must be guaranteed

for each critical activity;

for all possible combination of events.

Page 8: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

2

Sensor

MotorSensorMotor

ControlUnit

Steer by Wire Why?

1. Software is more flexible than hardware

2. It can be quickly changed/adapted/updated

3. It can be upgraded remotely

4. It can evolve into intelligent control algorithms

5. It has no mass, so it can travel at the speed of light

There are many advantages

Increasing complexity

Related problems

Difficult design

Less predictability

Less reliability

The price to be paid is a higher software complexity .

Novel solutions for:

Component-based software design

Analysis for guaranteeing predictability and safety

Testing

Complexity and bugs

Software bugs increase with complexity:

1 K 100 K 1 M 10 M0

10

100

1000

10.000

10K

Lines of code

bugs

Reliability does not only depend on the correctness ofsingle instructions, but also on when they areexecuted:

controller

output

inputt

t +

A correct action executed too late can be useless oreven dangerous.

Software reliability Real-Time Systems

Computing systems that must guaranteebounded and predictable response timesare called real-time systems .

Predictability of response times must be guaranteed

for each critical activity;

for all possible combination of events.

Page 9: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

2

Sensor

MotorSensorMotor

ControlUnit

Steer by Wire Why?

1. Software is more flexible than hardware

2. It can be quickly changed/adapted/updated

3. It can be upgraded remotely

4. It can evolve into intelligent control algorithms

5. It has no mass, so it can travel at the speed of light

There are many advantages

Increasing complexity

Related problems

Difficult design

Less predictability

Less reliability

The price to be paid is a higher software complexity .

Novel solutions for:

Component-based software design

Analysis for guaranteeing predictability and safety

Testing

Complexity and bugs

Software bugs increase with complexity:

1 K 100 K 1 M 10 M0

10

100

1000

10.000

10K

Lines of code

bugs

Reliability does not only depend on the correctness ofsingle instructions, but also on when they areexecuted:

controller

output

inputt

t +

A correct action executed too late can be useless oreven dangerous.

Software reliability Real-Time Systems

Computing systems that must guaranteebounded and predictable response timesare called real-time systems .

Predictability of response times must be guaranteed

for each critical activity;

for all possible combination of events.

Page 10: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

2

Sensor

MotorSensorMotor

ControlUnit

Steer by Wire Why?

1. Software is more flexible than hardware

2. It can be quickly changed/adapted/updated

3. It can be upgraded remotely

4. It can evolve into intelligent control algorithms

5. It has no mass, so it can travel at the speed of light

There are many advantages

Increasing complexity

Related problems

Difficult design

Less predictability

Less reliability

The price to be paid is a higher software complexity .

Novel solutions for:

Component-based software design

Analysis for guaranteeing predictability and safety

Testing

Complexity and bugs

Software bugs increase with complexity:

1 K 100 K 1 M 10 M0

10

100

1000

10.000

10K

Lines of code

bugs

Reliability does not only depend on the correctness ofsingle instructions, but also on when they areexecuted:

controller

output

inputt

t +

A correct action executed too late can be useless oreven dangerous.

Software reliability Real-Time Systems

Computing systems that must guaranteebounded and predictable response timesare called real-time systems .

Predictability of response times must be guaranteed

for each critical activity;

for all possible combination of events.

Page 11: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

3

efficiency predictability

Predictability vs. Efficiency

Allocated resources

QoS management High performance Safety critical

digital tvsoft firm hard

Criticality

What’s special in Embedded Systems?

FEATURES

Scarce resources (space, weight, time, memory, energy)

High concurrency and resource sharing (high task interference)

Interaction with the environment

(causing timing constraints)

High variability on workload and resource demand

REQUIREMENTS

High efficiency in resource management

Temporal isolation to limit the interference

High predictability in the response time

Adaptivity to handle overload situations

Aim of the Course

Studying software methodologies for supportingtime critical computing systems.

We will not consider how to control a system,but only how to provide a predictable softwaresupport to control applications.

Main focus: predictable software

Design

Analysis

Programming

Sensoryprocessing

Control

Commun.

software

Graphics

EmbeddedComputer

Controlled System

systemdynamics

Control and implementation

Often, control and implementation are done bydifferent people that do not talk to each other:

Control guys typically assume a computer with infiniteresources and computational power. In some case,computation is modeled by a fixed delay .

In reality, a computer:

has limited resources;

finite computational power (non null execution times);

executes several concurrent activities;

introduces variabile delays (often unpredictable).

Modeling such factors and taking them into accountin the design phase allows a significantimprovement in performance and reliability.

Control and implementation

Page 12: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

3

efficiency predictability

Predictability vs. Efficiency

Allocated resources

QoS management High performance Safety critical

digital tvsoft firm hard

Criticality

What’s special in Embedded Systems?

FEATURES

Scarce resources (space, weight, time, memory, energy)

High concurrency and resource sharing (high task interference)

Interaction with the environment

(causing timing constraints)

High variability on workload and resource demand

REQUIREMENTS

High efficiency in resource management

Temporal isolation to limit the interference

High predictability in the response time

Adaptivity to handle overload situations

Aim of the Course

Studying software methodologies for supportingtime critical computing systems.

We will not consider how to control a system,but only how to provide a predictable softwaresupport to control applications.

Main focus: predictable software

Design

Analysis

Programming

Sensoryprocessing

Control

Commun.

software

Graphics

EmbeddedComputer

Controlled System

systemdynamics

Control and implementation

Often, control and implementation are done bydifferent people that do not talk to each other:

Control guys typically assume a computer with infiniteresources and computational power. In some case,computation is modeled by a fixed delay .

In reality, a computer:

has limited resources;

finite computational power (non null execution times);

executes several concurrent activities;

introduces variabile delays (often unpredictable).

Modeling such factors and taking them into accountin the design phase allows a significantimprovement in performance and reliability.

Control and implementation

Page 13: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

3

efficiency predictability

Predictability vs. Efficiency

Allocated resources

QoS management High performance Safety critical

digital tvsoft firm hard

Criticality

What’s special in Embedded Systems?

FEATURES

Scarce resources (space, weight, time, memory, energy)

High concurrency and resource sharing (high task interference)

Interaction with the environment

(causing timing constraints)

High variability on workload and resource demand

REQUIREMENTS

High efficiency in resource management

Temporal isolation to limit the interference

High predictability in the response time

Adaptivity to handle overload situations

Aim of the Course

Studying software methodologies for supportingtime critical computing systems.

We will not consider how to control a system,but only how to provide a predictable softwaresupport to control applications.

Main focus: predictable software

Design

Analysis

Programming

Sensoryprocessing

Control

Commun.

software

Graphics

EmbeddedComputer

Controlled System

systemdynamics

Control and implementation

Often, control and implementation are done bydifferent people that do not talk to each other:

Control guys typically assume a computer with infiniteresources and computational power. In some case,computation is modeled by a fixed delay .

In reality, a computer:

has limited resources;

finite computational power (non null execution times);

executes several concurrent activities;

introduces variabile delays (often unpredictable).

Modeling such factors and taking them into accountin the design phase allows a significantimprovement in performance and reliability.

Control and implementation

Page 14: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

3

efficiency predictability

Predictability vs. Efficiency

Allocated resources

QoS management High performance Safety critical

digital tvsoft firm hard

Criticality

What’s special in Embedded Systems?

FEATURES

Scarce resources (space, weight, time, memory, energy)

High concurrency and resource sharing (high task interference)

Interaction with the environment

(causing timing constraints)

High variability on workload and resource demand

REQUIREMENTS

High efficiency in resource management

Temporal isolation to limit the interference

High predictability in the response time

Adaptivity to handle overload situations

Aim of the Course

Studying software methodologies for supportingtime critical computing systems.

We will not consider how to control a system,but only how to provide a predictable softwaresupport to control applications.

Main focus: predictable software

Design

Analysis

Programming

Sensoryprocessing

Control

Commun.

software

Graphics

EmbeddedComputer

Controlled System

systemdynamics

Control and implementation

Often, control and implementation are done bydifferent people that do not talk to each other:

Control guys typically assume a computer with infiniteresources and computational power. In some case,computation is modeled by a fixed delay .

In reality, a computer:

has limited resources;

finite computational power (non null execution times);

executes several concurrent activities;

introduces variabile delays (often unpredictable).

Modeling such factors and taking them into accountin the design phase allows a significantimprovement in performance and reliability.

Control and implementation

Page 15: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

3

efficiency predictability

Predictability vs. Efficiency

Allocated resources

QoS management High performance Safety critical

digital tvsoft firm hard

Criticality

What’s special in Embedded Systems?

FEATURES

Scarce resources (space, weight,

time, memory, energy)

High concurrency and resource

sharing (high task interference)

Interaction with the environment

(causing timing constraints)

High variability on workload and

resource demand

REQUIREMENTS

High efficiency in resource

management

Temporal isolation to limit

the interference

High predictability in the

response time

Adaptivity to handle

overload situations

Aim of the Course

Studying software methodologies for supportingtime critical computing systems.

We will not consider how to control a system,but only how to provide a predictable softwaresupport to control applications.

Main focus: predictable software

Design

Analysis

Programming

Sensoryprocessing

Control

Commun.

software

Graphics

EmbeddedComputer

Controlled System

systemdynamics

Control and implementation

Often, control and implementation are done bydifferent people that do not talk to each other:

Control guys typically assume a computer with infiniteresources and computational power. In some case,computation is modeled by a fixed delay .

In reality, a computer:

has limited resources;

finite computational power (non null execution times);

executes several concurrent activities;

introduces variable delays (often unpredictable).

Modeling such factors and taking them into accountin the design phase allows a significantimprovement in performance and reliability.

Control and implementation

Page 16: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

4

Specific objectives

Study software methodologies and algorithmsto increase predictability in computing systems.

We consider embeddded computing systemsconsisting of several concurrent activities subjectto timing constratints.

We will see how to model and analyze a real-timeapplication to predict worst-case response timesand verify its feasibility under a set of constraints.

Course outline - 1

1. Basic concepts and terminology

2. Sample applications

3. Problem identification

4. Modeling real-time activities

5. Deriving timing constraints

6. Worst-case reasoning

7. Managing periodic tasks

8. Scheduling algorithms

9. Schedulability analysis

10. Problems introduced by resource sharing

11. Resource access protocols

12. Estimating worst-case blocking times

13. Handling asynchronous (aperiodic) tasks

14. Handling execution overruns

15. Managing overload conditions

16. Real-time communication mechanisms

Course outline - 2

Programming real-time applications Processes and threads in Linux

Thread creation and activation

Linux schedulers

Time management

How implement periodic threads

How to structure RT applications

How to use a graphics library

How to simulate RT control systems

Course outline - 3

23

Teaching material

http://retis.sssup.it/~giorgio/rts-MECS.htmlCourse homepage

Books:

Third EditionPitagora, 2006Third EditionPitagora, 2006

Third EditionSpringer, 2011Third EditionSpringer, 2011

24

Final Exam

It consists of two parts:

1. Project work

2. Written test

Project: Developing a RT application under Linux, usingthe Pthread library and the Allegro graphics library.

Test: A number of questions and exercises on thecourse program.

Page 17: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

4

Specific objectives

Study software methodologies and algorithmsto increase predictability in computing systems.

We consider embeddded computing systemsconsisting of several concurrent activities subjectto timing constratints.

We will see how to model and analyze a real-timeapplication to predict worst-case response timesand verify its feasibility under a set of constraints.

Course outline - 1

1. Basic concepts and terminology

2. Sample applications

3. Problem identification

4. Modeling real-time activities

5. Deriving timing constraints

6. Worst-case reasoning

7. Managing periodic tasks

8. Scheduling algorithms

9. Schedulability analysis

10. Problems introduced by resource sharing

11. Resource access protocols

12. Estimating worst-case blocking times

13. Handling asynchronous (aperiodic) tasks

14. Handling execution overruns

15. Managing overload conditions

16. Real-time communication mechanisms

Course outline - 2

Programming real-time applications Processes and threads in Linux

Thread creation and activation

Linux schedulers

Time management

How implement periodic threads

How to structure RT applications

How to use a graphics library

How to simulate RT control systems

Course outline - 3

23

Teaching material

http://retis.sssup.it/~giorgio/rts-MECS.htmlCourse homepage

Books:

Third EditionPitagora, 2006Third EditionPitagora, 2006

Third EditionSpringer, 2011Third EditionSpringer, 2011

24

Final Exam

It consists of two parts:

1. Project work

2. Written test

Project: Developing a RT application under Linux, usingthe Pthread library and the Allegro graphics library.

Test: A number of questions and exercises on thecourse program.

Page 18: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

4

Specific objectives

Study software methodologies and algorithmsto increase predictability in computing systems.

We consider embeddded computing systemsconsisting of several concurrent activities subjectto timing constratints.

We will see how to model and analyze a real-timeapplication to predict worst-case response timesand verify its feasibility under a set of constraints.

Course outline - 1

1. Basic concepts and terminology

2. Sample applications

3. Problem identification

4. Modeling real-time activities

5. Deriving timing constraints

6. Worst-case reasoning

7. Managing periodic tasks

8. Scheduling algorithms

9. Schedulability analysis

10. Problems introduced by resource sharing

11. Resource access protocols

12. Estimating worst-case blocking times

13. Handling asynchronous (aperiodic) tasks

14. (Handling execution overruns

15. Managing overload conditions

16. Real-time communication mechanisms)

Course outline - 2

Programming real-time applications Processes and threads in Linux

Thread creation and activation

Linux schedulers

Time management

How implement periodic threads

How to structure RT applications

How to use a graphics library

How to simulate RT control systems

Course outline - 3

23

Teaching material

http://retis.sssup.it/~giorgio/rts-MECS.htmlCourse homepage

Books:

Third Edition

Pitagora, 2006

Third Edition

Pitagora, 2006

Third Edition

Springer, 2011

Third Edition

Springer, 201124

Final Exam

It consists of two parts:

1. Project work

2. Written test

Project: Developing a RT application under Linux, usingthe Pthread library and the Allegro graphics library.

Test: A number of questions and exercises on thecourse program.

Page 19: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

4

Specific objectives

Study software methodologies and algorithmsto increase predictability in computing systems.

We consider embeddded computing systemsconsisting of several concurrent activities subjectto timing constratints.

We will see how to model and analyze a real-timeapplication to predict worst-case response timesand verify its feasibility under a set of constraints.

Course outline - 1

1. Basic concepts and terminology

2. Sample applications

3. Problem identification

4. Modeling real-time activities

5. Deriving timing constraints

6. Worst-case reasoning

7. Managing periodic tasks

8. Scheduling algorithms

9. Schedulability analysis

10. Problems introduced by resource sharing

11. Resource access protocols

12. Estimating worst-case blocking times

13. Handling asynchronous (aperiodic) tasks

14. Handling execution overruns

15. Managing overload conditions

16. Real-time communication mechanisms

Course outline - 2

Programming real-time applications Processes and threads in Linux

Thread creation and activation

Linux schedulers

Time management

How implement periodic threads

How to structure RT applications

How to use a graphics library

How to simulate RT control systems

Course outline - 3

23

Teaching material

http://retis.sssup.it/~giorgio/rts-MECS.htmlCourse homepage

Books:

Third EditionPitagora, 2006Third EditionPitagora, 2006

Third EditionSpringer, 2011Third EditionSpringer, 2011

24

Final Exam

It consists of two parts:

1. Project work

2. Written test

Project: Developing a RT application under Linux, usingthe Pthread library and the Allegro graphics library.

Test: A number of questions and exercises on thecourse program.

Page 20: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

5

Embedded systems

They are computing systems hidden in an object to controlits functions, enhance its performance, manage the availableresources and simplify the interaction with the user.

Environmentactuators

sensors

micro-processor

communication

user other units

Object

Control system components

the system to be controlled– it may include sensors and actuators

the controller– it sends signals to the system according to a

predetermined control objective

the environment in which the system operates

In every control application, we can distinguish 3basic components:

A typical control system

Environ-ment

SystemController

feedback

Detailed block diagram

Other activities

filtering, classification, data fusion, recognition, planning

Environ.

System

Controller

Sensoryprocessing

internal state

external statepre-processing

feedback

actuators

sensor sensor

Software vision

INPUT

OUTPUT

task buffer

Page 21: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

5

Embedded systems

They are computing systems hidden in an object to controlits functions, enhance its performance, manage the availableresources and simplify the interaction with the user.

Environmentactuators

sensors

micro-processor

communication

user other units

Object

Control system components

the system to be controlled– it may include sensors and actuators

the controller– it sends signals to the system according to a

predetermined control objective

the environment in which the system operates

In every control application, we can distinguish 3basic components:

A typical control system

Environ-ment

SystemController

feedback

Detailed block diagram

Other activities

filtering, classification, data fusion, recognition, planning

Environ.

System

Controller

Sensoryprocessing

internal state

external statepre-processing

feedback

actuators

sensor sensor

Software vision

INPUT

OUTPUT

task buffer

Page 22: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

5

Embedded systems

They are computing systems hidden in an object to controlits functions, enhance its performance, manage the availableresources and simplify the interaction with the user.

Environmentactuators

sensors

micro-processor

communication

user other units

Object

Control system components

the system to be controlled– it may include sensors and actuators

the controller– it sends signals to the system according to a

predetermined control objective

the environment in which the system operates

In every control application, we can distinguish 3basic components:

A typical control system

Environ-ment

SystemController

feedback

Detailed block diagram

Other activities

filtering, classification, data fusion, recognition, planning

Environ.

System

Controller

Sensoryprocessing

internal state

external statepre-processing

feedback

actuators

sensor sensor

Software vision

INPUT

OUTPUT

task buffer

Page 23: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

5

Embedded systems

They are computing systems hidden in an object to controlits functions, enhance its performance, manage the availableresources and simplify the interaction with the user.

Environmentactuators

sensors

micro-processor

communication

user other units

Object

Control system components

the system to be controlled– it may include sensors and actuators

the controller– it sends signals to the system according to a

predetermined control objective

the environment in which the system operates

In every control application, we can distinguish 3basic components:

A typical control system

Environ-ment

SystemController

feedback

Detailed block diagram

Other activities

filtering, classification, data fusion, recognition, planning

Environ.

System

Controller

Sensoryprocessing

internal state

external statepre-processing

feedback

actuators

sensor sensor

Software vision

INPUT

OUTPUT

task buffer

Page 24: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

5

Embedded systems

They are computing systems hidden in an object to controlits functions, enhance its performance, manage the availableresources and simplify the interaction with the user.

Environmentactuators

sensors

micro-processor

communication

user other units

Object

Control system components

the system to be controlled– it may include sensors and actuators

the controller– it sends signals to the system according to a

predetermined control objective

the environment in which the system operates

In every control application, we can distinguish 3basic components:

A typical control system

Environ-ment

SystemController

feedback

Detailed block diagram

Other activities

filtering, classification, data fusion, recognition, planning

Environ.

System

Controller

Sensoryprocessing

internal state

external statepre-processing

feedback

actuators

sensor sensor

Software vision

INPUT

OUTPUT

task buffer

Page 25: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

5

Embedded systems

They are computing systems hidden in an object to controlits functions, enhance its performance, manage the availableresources and simplify the interaction with the user.

Environmentactuators

sensors

micro-processor

communication

user other units

Object

Control system components

the system to be controlled– it may include sensors and actuators

the controller– it sends signals to the system according to a

predetermined control objective

the environment in which the system operates

In every control application, we can distinguish 3basic components:

A typical control system

Environ-ment

SystemController

feedback

Detailed block diagram

Other activities

filtering, classification, data fusion, recognition, planning

Environ.

System

Controller

Sensoryprocessing

internal state

external statepre-processing

feedback

actuators

sensor sensor

Software vision

INPUT

OUTPUT

task buffer

Page 26: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

6

Types of control systems

Monitoring Systems– do not modify the environment

Open-loop control systems– loosely modify the environment

Closed-loop control systems– tight interaction between perception and action

Depending of the system-environment interactions,we can distinguish 3 types of control systems:

Do not have actuators Do not modify the environment

Monitoring Systems

Examples: Environmental monitoring, surveillance systems,air traffic control

Environ-ment

Dataprocessing

sensors

sensors

sensors...

Real-time system

Display

Modify the environment, actions are mostly pre-programmed,so loosely coupled with the current state of the environment:

Loosely-coupled control systems

SystemController actuators

sensorsData

processingPlanning

Environment

Examples: painting robots, assembly robots, sorting robots

Environment

SystemController actuators

sensorsData

processingPlanning

Sensing and control are tightly coupled and occur atdifferent hierarchical level:

Tightly-coupled control systems

Examples: flight control systems, military systems,advanced robots, living beings

Hierarchical control

Environment

S1

S2

S3

A1

A2

A3

F1

F2

F3

Sensing Control

high-levelcommand

high-levelrecognition

low-levelactuation

low-levelacquisition

Implications

The tight interaction with the environmentrequires the system to react to events withinprecise timing constraints.

Timing constraints are imposed by theperformance requirements and the dynamics ofthe system to be controlled.

The operating system must be able toexecute tasks within timing constraints.

Page 27: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

6

Types of control systems

Monitoring Systems– do not modify the environment

Open-loop control systems– loosely modify the environment

Closed-loop control systems– tight interaction between perception and action

Depending of the system-environment interactions,we can distinguish 3 types of control systems:

Do not have actuators Do not modify the environment

Monitoring Systems

Examples: Environmental monitoring, surveillance systems,air traffic control

Environ-ment

Dataprocessing

sensors

sensors

sensors...

Real-time system

Display

Modify the environment, actions are mostly pre-programmed,so loosely coupled with the current state of the environment:

Loosely-coupled control systems

SystemController actuators

sensorsData

processingPlanning

Environment

Examples: painting robots, assembly robots, sorting robots

Environment

SystemController actuators

sensorsData

processingPlanning

Sensing and control are tightly coupled and occur atdifferent hierarchical level:

Tightly-coupled control systems

Examples: flight control systems, military systems,advanced robots, living beings

Hierarchical control

Environment

S1

S2

S3

A1

A2

A3

F1

F2

F3

Sensing Control

high-levelcommand

high-levelrecognition

low-levelactuation

low-levelacquisition

Implications

The tight interaction with the environmentrequires the system to react to events withinprecise timing constraints.

Timing constraints are imposed by theperformance requirements and the dynamics ofthe system to be controlled.

The operating system must be able toexecute tasks within timing constraints.

Page 28: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

6

Types of control systems

Monitoring Systems– do not modify the environment

Open-loop control systems– loosely modify the environment

Closed-loop control systems– tight interaction between perception and action

Depending of the system-environment interactions,we can distinguish 3 types of control systems:

Do not have actuators Do not modify the environment

Monitoring Systems

Examples: Environmental monitoring, surveillance systems,air traffic control

Environ-ment

Dataprocessing

sensors

sensors

sensors...

Real-time system

Display

Modify the environment, actions are mostly pre-programmed,so loosely coupled with the current state of the environment:

Loosely-coupled control systems

SystemController actuators

sensorsData

processingPlanning

Environment

Examples: painting robots, assembly robots, sorting robots

Environment

SystemController actuators

sensorsData

processingPlanning

Sensing and control are tightly coupled and occur atdifferent hierarchical level:

Tightly-coupled control systems

Examples: flight control systems, military systems,advanced robots, living beings

Hierarchical control

Environment

S1

S2

S3

A1

A2

A3

F1

F2

F3

Sensing Control

high-levelcommand

high-levelrecognition

low-levelactuation

low-levelacquisition

Implications

The tight interaction with the environmentrequires the system to react to events withinprecise timing constraints.

Timing constraints are imposed by theperformance requirements and the dynamics ofthe system to be controlled.

The operating system must be able toexecute tasks within timing constraints.

Page 29: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

6

Types of control systems

Monitoring Systems– do not modify the environment

Open-loop control systems– loosely modify the environment

Closed-loop control systems– tight interaction between perception and action

Depending of the system-environment interactions,we can distinguish 3 types of control systems:

Do not have actuators Do not modify the environment

Monitoring Systems

Examples: Environmental monitoring, surveillance systems,air traffic control

Environ-ment

Dataprocessing

sensors

sensors

sensors...

Real-time system

Display

Modify the environment, actions are mostly pre-programmed,so loosely coupled with the current state of the environment:

Loosely-coupled control systems

SystemController actuators

sensorsData

processingPlanning

Environment

Examples: painting robots, assembly robots, sorting robots

Environment

SystemController actuators

sensorsData

processingPlanning

Sensing and control are tightly coupled and occur atdifferent hierarchical level:

Tightly-coupled control systems

Examples: flight control systems, military systems,advanced robots, living beings

Hierarchical control

Environment

S1

S2

S3

A1

A2

A3

F1

F2

F3

Sensing Control

high-levelcommand

high-levelrecognition

low-levelactuation

low-levelacquisition

Implications

The tight interaction with the environmentrequires the system to react to events withinprecise timing constraints.

Timing constraints are imposed by theperformance requirements and the dynamics ofthe system to be controlled.

The operating system must be able toexecute tasks within timing constraints.

Page 30: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

7

A robot control example

Consider a mobile robot equipped with:

two actuated wheels;

two proximity (US) sensors;

a mobile (pan/tilt) camera;

a wireless transceiver.

Goal Follow a path based on visual feedback; Avoid obstacles;

Send complete robot status every 20 ms.

Design requirements

Modularity : a subsystem must be developed withoutknowing the details of other subsystems (team work).

Configurability : software must be adapted to differentsituations (through the use of suitable parameters) withoutchanging the source code.

Portability : minimize code changes when porting the systemto different hardware platforms.

Predictability : allow the estimation of maximum delays.

Efficiency : optimize the use of available resources(computation time, memory, energy).

Modularity

Modularity can be achieved by:

partitioning the system into a set of subsystems, eachmanaged by one or more computational tasks;

defining precise interfaces between tasks, each specifying:

data exchanged with the other tasks (input and output)

functionality of the task (what it has to do)

validity assumptions (e.g., admissible ranges)

performance requirements (priority, period, deadline, jitter)

Asynchronous communication mechanisms.

Control view

mot_dx mot_sxpan tiltcamera US2US1

visualtracking

obstacleavoidance

vehiclecontrol

visual‐basednavigation

1 ms1 ms

5 ms

10 ms

20 ms

100 ms

feature

extraction

object

recognition

motorcontrol

motorcontrol

motorcontrol

motorcontrol

Software View

mot_dx mot_sxpan tiltcamera US2US1

visualtracking

obstacleavoidance

vehiclecontrol

visual‐basednavigation

featureextraction

objectrecognition

motorcontrol

periodic task buffer

EnvironmentRT System

y

x (t)

(t+)

Real-Time System

It is a system in which the correctness dependsnot only on the output values, but also on the timeat which results are produced.

tt

REAL means that system time must be synchronizedwith the time flowing in the environment.

Page 31: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

7

A robot control example

Consider a mobile robot equipped with:

two actuated wheels;

two proximity (US) sensors;

a mobile (pan/tilt) camera;

a wireless transceiver.

Goal Follow a path based on visual feedback; Avoid obstacles;

Send complete robot status every 20 ms.

Design requirements

Modularity : a subsystem must be developed withoutknowing the details of other subsystems (team work).

Configurability : software must be adapted to differentsituations (through the use of suitable parameters) withoutchanging the source code.

Portability : minimize code changes when porting the systemto different hardware platforms.

Predictability : allow the estimation of maximum delays.

Efficiency : optimize the use of available resources(computation time, memory, energy).

Modularity

Modularity can be achieved by:

partitioning the system into a set of subsystems, eachmanaged by one or more computational tasks;

defining precise interfaces between tasks, each specifying:

data exchanged with the other tasks (input and output)

functionality of the task (what it has to do)

validity assumptions (e.g., admissible ranges)

performance requirements (priority, period, deadline, jitter)

Asynchronous communication mechanisms.

Control view

mot_dx mot_sxpan tiltcamera US2US1

visualtracking

obstacleavoidance

vehiclecontrol

visual‐basednavigation

1 ms1 ms

5 ms

10 ms

20 ms

100 ms

feature

extraction

object

recognition

motorcontrol

motorcontrol

motorcontrol

motorcontrol

Software View

mot_dx mot_sxpan tiltcamera US2US1

visualtracking

obstacleavoidance

vehiclecontrol

visual‐basednavigation

featureextraction

objectrecognition

motorcontrol

periodic task buffer

EnvironmentRT System

y

x (t)

(t+)

Real-Time System

It is a system in which the correctness dependsnot only on the output values, but also on the timeat which results are produced.

tt

REAL means that system time must be synchronizedwith the time flowing in the environment.

Page 32: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

7

A robot control example

Consider a mobile robot equipped with:

two actuated wheels;

two proximity (US) sensors;

a mobile (pan/tilt) camera;

a wireless transceiver.

Goal Follow a path based on visual feedback; Avoid obstacles;

Send complete robot status every 20 ms.

Design requirements

Modularity : a subsystem must be developed withoutknowing the details of other subsystems (team work).

Configurability : software must be adapted to differentsituations (through the use of suitable parameters) withoutchanging the source code.

Portability : minimize code changes when porting the systemto different hardware platforms.

Predictability : allow the estimation of maximum delays.

Efficiency : optimize the use of available resources(computation time, memory, energy).

Modularity

Modularity can be achieved by:

partitioning the system into a set of subsystems, eachmanaged by one or more computational tasks;

defining precise interfaces between tasks, each specifying:

data exchanged with the other tasks (input and output)

functionality of the task (what it has to do)

validity assumptions (e.g., admissible ranges)

performance requirements (priority, period, deadline, jitter)

Asynchronous communication mechanisms.

Control view

mot_dx mot_sxpan tiltcamera US2US1

visualtracking

obstacleavoidance

vehiclecontrol

visual‐basednavigation

1 ms1 ms

5 ms

10 ms

20 ms

100 ms

feature

extraction

object

recognition

motorcontrol

motorcontrol

motorcontrol

motorcontrol

Software View

mot_dx mot_sxpan tiltcamera US2US1

visualtracking

obstacleavoidance

vehiclecontrol

visual‐basednavigation

featureextraction

objectrecognition

motorcontrol

periodic task buffer

EnvironmentRT System

y

x (t)

(t+)

Real-Time System

It is a system in which the correctness dependsnot only on the output values, but also on the timeat which results are produced.

tt

REAL means that system time must be synchronizedwith the time flowing in the environment.

Page 33: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

7

A robot control example

Consider a mobile robot equipped with:

two actuated wheels;

two proximity (US) sensors;

a mobile (pan/tilt) camera;

a wireless transceiver.

Goal Follow a path based on visual feedback; Avoid obstacles;

Send complete robot status every 20 ms.

Design requirements

Modularity : a subsystem must be developed withoutknowing the details of other subsystems (team work).

Configurability : software must be adapted to differentsituations (through the use of suitable parameters) withoutchanging the source code.

Portability : minimize code changes when porting the systemto different hardware platforms.

Predictability : allow the estimation of maximum delays.

Efficiency : optimize the use of available resources(computation time, memory, energy).

Modularity

Modularity can be achieved by:

partitioning the system into a set of subsystems, eachmanaged by one or more computational tasks;

defining precise interfaces between tasks, each specifying:

data exchanged with the other tasks (input and output)

functionality of the task (what it has to do)

validity assumptions (e.g., admissible ranges)

performance requirements (priority, period, deadline, jitter)

Asynchronous communication mechanisms.

Control view

mot_dx mot_sxpan tiltcamera US2US1

visualtracking

obstacleavoidance

vehiclecontrol

visual‐basednavigation

1 ms1 ms

5 ms

10 ms

20 ms

100 ms

feature

extraction

object

recognition

motorcontrol

motorcontrol

motorcontrol

motorcontrol

Software View

mot_dx mot_sxpan tiltcamera US2US1

visualtracking

obstacleavoidance

vehiclecontrol

visual‐basednavigation

featureextraction

objectrecognition

motorcontrol

periodic task buffer

EnvironmentRT System

y

x (t)

(t+)

Real-Time System

It is a system in which the correctness dependsnot only on the output values, but also on the timeat which results are produced.

tt

REAL means that system time must be synchronizedwith the time flowing in the environment.

Page 34: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

7

A robot control example

Consider a mobile robot equipped with:

two actuated wheels;

two proximity (US) sensors;

a mobile (pan/tilt) camera;

a wireless transceiver.

Goal Follow a path based on visual feedback; Avoid obstacles;

Send complete robot status every 20 ms.

Design requirements

Modularity : a subsystem must be developed withoutknowing the details of other subsystems (team work).

Configurability : software must be adapted to differentsituations (through the use of suitable parameters) withoutchanging the source code.

Portability : minimize code changes when porting the systemto different hardware platforms.

Predictability : allow the estimation of maximum delays.

Efficiency : optimize the use of available resources(computation time, memory, energy).

Modularity

Modularity can be achieved by:

partitioning the system into a set of subsystems, eachmanaged by one or more computational tasks;

defining precise interfaces between tasks, each specifying:

data exchanged with the other tasks (input and output)

functionality of the task (what it has to do)

validity assumptions (e.g., admissible ranges)

performance requirements (priority, period, deadline, jitter)

Asynchronous communication mechanisms.

Control view

mot_dx mot_sxpan tiltcamera US2US1

visualtracking

obstacleavoidance

vehiclecontrol

visual‐basednavigation

1 ms1 ms

5 ms

10 ms

20 ms

100 ms

feature

extraction

object

recognition

motorcontrol

motorcontrol

motorcontrol

motorcontrol

Software View

mot_dx mot_sxpan tiltcamera US2US1

visualtracking

obstacleavoidance

vehiclecontrol

visual‐basednavigation

featureextraction

objectrecognition

motorcontrol

periodic task buffer

EnvironmentRT System

y

x (t)

(t+)

Real-Time System

It is a system in which the correctness dependsnot only on the output values, but also on the timeat which results are produced.

tt

REAL means that system time must be synchronizedwith the time flowing in the environment.

Page 35: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

8

RTOS responsibilities

A real-time operating system is responsible for:

Managing concurrency;

Activating periodic tasks at the beginning of eachperiod (time management);

Deciding the execution order of tasks (scheduling);

Solving possible timing conflicts during the accessof shared resources (mutual exclusion);

Manage the timely execution of asynchronousevents (interrupt handling).

Typical objection

AnswerGiven an arbitrary computer speed, we mustalways guarantee that timing constraints can bemet. Testing is NOT sufficient.

It is not worth to invest in RT theory, becausecomputer speed is increasing exponentially, andall timing constraints can eventually be handled.

Real-Time Fast

A real-time system is not a fast system.

Speed is always relative to a specificenvironment.

Running faster is good, but does notguarantee a correct behavior.

Speed vs. Predictability

The objective of a real-time system is to guaranteethe timing behavior of each individual task.

The objective of a fast system is to minimize theaverage response time of a task set. But …

Don’t trust the average when you have toguarantee individual performance

Sources of non determinism

Architecture cache, pipelining, interrupts, DMA

Operating system scheduling, synchronization, communication

Language lack of explicit support for time

Design methodologies lack of analysis and verification techniques

Traditional (wrong) approach

In spite of this large application domain, most ofRT applications are designed using empiricaltechniques:

– assembly programming

– timing through dedicated timers

– control through driver programming

– priority manipulation

Page 36: 14/10/2015 E-mail: buttazzo@sssup.it Computer Scuola ... · 14/10/2015 1 Giorgio Buttazzo E-mail: buttazzo@sssup.it Scuola Superiore Sant’Anna Definition Real-Time Systemsare computing

14/10/2015

9

Disadvantages

1. Tedious programming which heavilydepends on programmer’s ability

2. Difficult code understanding

Readability 1

efficiency

Disadvantages

3. Difficult software maintainability

Complex appl.s consists of millions lines of code

Code understanding takes more that re-writing

But re-writing is VERY expensive and bug prone

4. Difficult to verify timing constraints withoutexplicit support from the OS and the language

Implications

Such a way of programming RT applicationsis very dangerous.

It may work in most situations, but the risk ofa failure is high.

When the system fails is very difficult tounderstand why.

low reliability

Accidents due to SW

Task overrun during LEM lunar landing

First flight of the Space Shuttle (synch)

Ariane 5 (overflow)

Airbus 320 (cart task)

Airbus 320 (holding task)

Pathfinder (reset for timeout)

Lessons learned

Tests, although necessary, allow only apartial verification of system’s behavior.

Predictability must be improved at the level ofthe operating system.

The system must be designed to be fault-tolerantand handle overload conditions.

Critical systems must be designed underpessimistic assumptions.

Murphy’s Laws

If something can go wrong, it will go wrong

If a system stops working, it will do itat the worst possible time

Sooner or later, the worst possiblecombination of circumstances will occur