90
Real-Time Real-Time Embedded Systems Embedded Systems Assist. dr. Barbara Assist. dr. Barbara Koroušić Seljak Koroušić Seljak [email protected] [email protected] (01) 4773-363 (01) 4773-363

Real-Time Embedded Systems

  • Upload
    salim

  • View
    72

  • Download
    3

Embed Size (px)

DESCRIPTION

Real-Time Embedded Systems. Assist. dr. Barbara Koroušić Seljak [email protected] (01) 4773-363. Course synopsis. Fall semester : Basics of real-time and embedded systems Embedded systems’ modeling Software and program design concepts Operating systems for real-time applications. - PowerPoint PPT Presentation

Citation preview

Page 1: Real-Time  Embedded Systems

Real-Time Real-Time Embedded SystemsEmbedded Systems

Assist. dr. Barbara Koroušić Assist. dr. Barbara Koroušić SeljakSeljak

[email protected]@ijs.si

(01) 4773-363(01) 4773-363

Page 2: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 2

Course synopsisCourse synopsis

►Fall semesterFall semester:: Basics of real-time and embedded Basics of real-time and embedded

systemssystems Embedded systems’ modelingEmbedded systems’ modeling Software and program design conceptsSoftware and program design concepts Operating systems for real-time Operating systems for real-time

applicationsapplications

Page 3: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 3

Course synopsisCourse synopsis

►Spring semesterSpring semester:: Designing and developing embedded Designing and developing embedded

systemssystems Implementation and performance issues Implementation and performance issues

Page 4: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 4

Benefits? Learn about ...Benefits? Learn about ...

► ... ... challenges and approaches in challenges and approaches in real-time real-time embeddedembedded system design system design

► …… performance estimation of performance estimation of real-time real-time embeddedembedded systems systems

► ... current research area... current research areass

Page 5: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 5

Basics of real-time and Basics of real-time and embedded systemsembedded systems

1.1. Real-time systemsReal-time systems

Page 6: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 6

Real-time (RT) systemsReal-time (RT) systems

►Categories of computer systemsCategories of computer systems:: BatchBatch: has no operational deadline from : has no operational deadline from

event to system response; event to system response; Interactive on-lineInteractive on-line: quick response is : quick response is

longed-for, but not required;longed-for, but not required; Real-timeReal-time: system response is required : system response is required

within a predefined timescale, otherwise within a predefined timescale, otherwise the system won’t work properly.the system won’t work properly.

Page 7: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 7

Characteristics of a batch Characteristics of a batch systemsystem

► The user pre-The user pre-processes all processes all programs and programs and information at a information at a local local sitesite, and at some , and at some convenient time these convenient time these jobs are passed to a jobs are passed to a remote computerremote computer. . When all jobs are When all jobs are finished, the results finished, the results are transmitted back are transmitted back to the originating site.to the originating site.

Page 8: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 8

Characteristics of an on-line Characteristics of an on-line systemsystem

► Normally, access to Normally, access to such a system is such a system is made using made using computer-based computer-based remote remote terminalsterminals, , and all transactions and all transactions are handled by the are handled by the central computercentral computer in in a time-sliced a time-sliced fashion.fashion.

► These systems are These systems are widely used in widely used in banking, holiday banking, holiday booking and mail-booking and mail-order systems.order systems.

► Their response time Their response time depends on the depends on the amount of activity.amount of activity.

Page 9: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 9

Characteristics of a RT Characteristics of a RT systemsystem

► A A control computercontrol computer detects events detects events triggered by triggered by sensorssensors, and , and responds over responds over actuatorsactuators within within predefined time predefined time bounds.bounds.

Page 10: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 10

History of real-time History of real-time computingcomputing

►The term real-time derives from its use The term real-time derives from its use in early in early simulationsimulation..

►OOriginallyriginally, this term, this term referred to a referred to a simulation that proceeded at a rate simulation that proceeded at a rate that matched that of the real process that matched that of the real process it was simulating. it was simulating.

Page 11: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 11

RT ApplicationsRT Applications

Execution Execution timetime

DeadlinesDeadlines SW sizeSW size SW SW complexitycomplexity

Hard real-Hard real-time & fasttime & fast

● ● ● ●● ● ● ● ● ● ● ●● ● ● ● ●● ●●

Hard real-Hard real-time & slowtime & slow

●● ● ● ● ●● ● ● ● ●● ● ● ●● ● ● ●● ● ● ● ● ● ● ●●

Soft real-Soft real-time & fasttime & fast

● ● ● ●● ● ● ● ● ●● ● ●● ● ● ●● ● ● ●● ● ● ●● ● ●

Soft real-Soft real-time & slowtime & slow

● ●● ● ● ●● ● ●● ● ● ● ● ● ● ●●

●● ● ● ● ● ● ● ●●

● Low weighting; ● ● ● ● High weighting

Page 12: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 12

Hard RT ApplicationsHard RT Applications

►Critical deadlinesCritical deadlines►Usually, low SW complexityUsually, low SW complexity►ExampleExample: airbag deployment system in : airbag deployment system in

motor vehiclesmotor vehicles

fast system – late deploymentdefeats the whole purpose ofairbag protection

time

value

hard deadline

Page 13: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 13

Soft RT ApplicationsSoft RT Applications

►Deadlines are not criticalDeadlines are not critical►Usually, more complex and large SW; Usually, more complex and large SW;

man-machine interfaceman-machine interface►ExamplesExamples: factory : factory

automation system, automation system,

barcode recognition barcode recognition

systemsystemfast/slow system – if fast/slow operator response is required

time

value

soft deadline

Page 14: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 14

Basics of real-time and Basics of real-time and embedded systemsembedded systems

1.1. Real-time systemsReal-time systems

2.2. Embedded systemsEmbedded systems

Page 15: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 15

Categories of RT systemsCategories of RT systems

►Categories of Categories of computing systemscomputing systems:: General-purpose computing systems;General-purpose computing systems; Embedded systems (ESs).Embedded systems (ESs).

►RT systems may be general-purpose or RT systems may be general-purpose or embedded systems.embedded systems.

►We are going to discuss We are going to discuss RT embedded RT embedded systemssystems. .

Page 16: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 16

Characteristics of general-Characteristics of general-purpose systemspurpose systems

►Broad class of applicationsBroad class of applications;;►Programmable by Programmable by the the end userend user;;►Faster is betterFaster is better..►CriteriaCriteria::

CostCost,, performance (performance (average speedaverage speed););

►ExamplesExamples: : personal computers, personal computers, laptops, mainframes, servers.laptops, mainframes, servers.

Page 17: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 17

What is an ES?What is an ES?

►An embedded system is an An embedded system is an electronic electronic componentcomponent within a physical system. within a physical system.

sensors / actuators

man-machineinterface

embedded system (a combination oftailored HW & SW)

external process

reactive & time-constrained reactive & time-constrained environmentenvironment

Page 18: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 18

Characteristics of ESsCharacteristics of ESs

►Single-functionedSingle-functioned:: A single system-tailored task or a very small A single system-tailored task or a very small

number of related tasks are executed repeatedly;number of related tasks are executed repeatedly; Minimal end-user intervention;Minimal end-user intervention;

►Tightly constrainedTightly constrained:: Low cost, low power, small size, easy-to-use, etc;Low cost, low power, small size, easy-to-use, etc;

►Reactive & real-timeReactive & real-time:: Continually reacts to events in the system’s Continually reacts to events in the system’s

physical environmentphysical environment;; Must perform certain tasks in real-time on a Must perform certain tasks in real-time on a

physical platformphysical platform..

Page 19: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 19

Examples of ESs in common Examples of ESs in common environments (1)environments (1)

Page 20: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 20

Examples of ESs in common Examples of ESs in common environments (2)environments (2)

Page 21: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 21

Short list of embedded Short list of embedded applicationsapplications

► Consumer electronicsConsumer electronics (MP3 players, smart clothes, (MP3 players, smart clothes, wearable devices)wearable devices)

► Home appliancesHome appliances (microwave owens, home security (microwave owens, home security system)system)

► Office automationOffice automation (modems, printers, scanners) (modems, printers, scanners)► Business equipmentBusiness equipment (intruder alarm systems, POS (intruder alarm systems, POS

terminals)terminals)► AutomobilesAutomobiles (fuel injection, anti-lock brakes) (fuel injection, anti-lock brakes)► Aircrafts, Aircrafts, satellitesatellites, trains, submariness, trains, submarines (navigation (navigation

systems)systems)► MedicineMedicine (life-support systems, medical devices) (life-support systems, medical devices)► TelecommunicationTelecommunication (network switches/routers, cell (network switches/routers, cell

phones)phones)► AAutomationutomation systems systems (monitors, robots) (monitors, robots)

Page 22: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 22

Microprocessor and Microprocessor and semiconductor chips’ trendssemiconductor chips’ trends

Page 23: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 23

Brief history of ESs (1)Brief history of ESs (1)► Late Late 1940’s1940’s: MIT Whirlwind : MIT Whirlwind

computer was designed for computer was designed for real-time operationsreal-time operations:: Originally designed to control Originally designed to control

an aircraft simulatoran aircraft simulator;;► In the In the 1960’s1960’s::

The first recognizably The first recognizably ESES was was the Apollo Guidance the Apollo Guidance ComputerComputer ( (MIT MIT Instrumentation LaboratoryInstrumentation Laboratory););

► By the end of the By the end of the 8080’s’s: : ESsESs were the norm rather were the norm rather

than the exception for almost than the exception for almost all electronics devicesall electronics devices (microcontrollers, I(microcontrollers, I22C).C).

Whirlwind computerWhirlwind computer

Apollo Guidance Apollo Guidance computercomputer

Intel 4004Intel 4004

Page 24: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 24

Brief history of ESs (2)Brief history of ESs (2)

Today’s complex ESs are based on Today’s complex ESs are based on networks networks of distributed microprocessorsof distributed microprocessors that run that run many off-the-shelf operating systemsmany off-the-shelf operating systems and and communicate through wired and wireless communicate through wired and wireless buses, LANs and WANs;buses, LANs and WANs;► AA high-end automobile may have high-end automobile may have 100 microprocessors:100 microprocessors: 4-bit microcontroller4-bit microcontrollerss check seat check seat

beltbeltss;; microcontrollers run dashboard microcontrollers run dashboard

devices;devices; 16/32-bit microprocessor 16/32-bit microprocessor

controls engine.controls engine.

Page 25: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 25

Brief history of ESs (3)Brief history of ESs (3)

► What do we expect from high-performance What do we expect from high-performance ESs today?ESs today? Giga-ops of computing power;Giga-ops of computing power; For example, cell phones that use SW-radio For example, cell phones that use SW-radio

techniques will need to deliver at least techniques will need to deliver at least 10 billion 10 billion operations per secondoperations per second;;

Multimedia applications.Multimedia applications.

► It is It is difficultdifficult to achieve this performance to achieve this performance level in the face of level in the face of real-timereal-time and and low powerlow power or other constraints.or other constraints.

Page 26: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 26

Few statistical factsFew statistical facts

►General-purpose computersGeneral-purpose computers:: MillionsMillions of units produced per year. of units produced per year.

►Embedded systemsEmbedded systems:: BillionsBillions of units produced yearly of units produced yearly

(VDC Report, 2006).(VDC Report, 2006). More than 98% of processors applied More than 98% of processors applied

today are in ESs.today are in ESs. Mean age of embedded developers: Mean age of embedded developers:

39,6. 39,6.

Page 27: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 27

StudentsStudents

StudentStudent Research areaResearch area1.1. Student 1Student 1

2.2. Student 2Student 2

3.3. Student 3Student 3

4.4. Student 4Student 4

5.5. Student 5Student 5

6.6. Student 6Student 6

7.7. Student 7Student 7

Page 28: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 28

ESs’ modelingESs’ modeling

► ChallengesChallenges::1.1. TechnologicalTechnological: build an embedded : build an embedded

system of predictable functionality and system of predictable functionality and quality (performance & robustness) quality (performance & robustness) considering the system’s constraints;considering the system’s constraints;

Page 29: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 29

How to satisfy the How to satisfy the technologicaltechnological challenge?challenge?

Computing

methodsalgorithmsreuse

Execution constraints

CPU speedmemorypowerHW failure rates

System’s reaction constraints

performance (deadlines, jitter, throughput)robustness (security, safety, availability)

Page 30: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 30

Hardware design?Hardware design?

Computing

methodsalgorithmsreuse

Execution constraints

CPU speedmemorypowerHW failure rates

System’s reactionconstraints

performance (deadlines, jitter, throughput)robustness (security, safety, availability)

new computer new computer architectures (open & flexible multi-core SoC)architectures (open & flexible multi-core SoC)

Page 31: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 31

Software design?Software design?

Computing

methodsalgorithmsreuse

Execution constraints

CPU speedmemorypowerHW failure rates

System’s reactionconstraints

performance (deadlines, jitter, throughput)robustness (security, safety, availability)

new software new software architectures architectures (1-2 million lines of code)(1-2 million lines of code)

Page 32: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 32

Control design?Control design?

Computing

methodsalgorithmsreuse

Execution constraints

CPU speedmemorypowerHW failure rates

System’s reaction constraints

performance (deadlines, jitter, throughput)robustness (security, safety, availability)

novel system-level analysis, novel system-level analysis, modeling methods and toolsmodeling methods and tools

Page 33: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 33

HW/SW Codesign!HW/SW Codesign!

Computing

methodsalgorithmsreuse

Execution constraints

CPU speedmemorypowerHW failure rates

System’s reactionconstraints

performance (deadlines, jitter, throughput)robustness (security, safety, availability)

Design, validation & maintenance processesDesign, validation & maintenance processesneed to support the high-performance need to support the high-performance HW & communication technologies!HW & communication technologies!

Page 34: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 34

HW/SW Co-design ApproachHW/SW Co-design Approach

► In the past, HW and SW In the past, HW and SW design technologies design technologies were very different.were very different.

► Today, Today, synthesis synthesis approachesapproaches enable a enable a unified view of HW and unified view of HW and SW: SW: Design of HW and SW Design of HW and SW

can start from can start from behavioral (system-behavioral (system-level) description in level) description in sequential program sequential program model;model;

Electronic System Electronic System Level DesignLevel Design..

Co-specificationProblem analysis

Requirement specifications

HW/SW partitioning

Co-synthesis

SW HWInterface

System IntegrationCo-simulationCo-verification

C code

VHDL code

SystemC code

Page 35: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 35

The Co-design Ladder The Co-design Ladder (Vahid&Givargis, 2002)(Vahid&Givargis, 2002)

CompilersCompilers(1960s,1970s)(1960s,1970s)

Assemblers, linkersAssemblers, linkers(1950s, 1960s)(1950s, 1960s)

Behavioral synthesisBehavioral synthesis (1990s(1990s, 2000s, 2000s))

RT synthesisRT synthesis(1980s, 1990s)(1980s, 1990s)

Logic synthesisLogic synthesis(1970s, 1980s)(1970s, 1980s)

Assembly instructionsAssembly instructions

Machine instructionsMachine instructions Logic gatesLogic gates

LogicLogic equations/FSMs equations/FSMs

Register transfersRegister transfers

Sequential programSequential program codes codes (e.g., C, VHDL (e.g., C, VHDL, SystemC, SystemC))

Traditional program on a programmable Traditional program on a programmable processorprocessor

VLSI, ASIC, or PLD VLSI, ASIC, or PLD implementationimplementation

SWSW

HWHW

Page 36: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 36

Embedded Systems Design Embedded Systems Design ChallengeChallenge

►Design goal:Design goal: Construct a system with desired Construct a system with desired

functionality.functionality.

►Key design challenge:Key design challenge: Simultaneously optimize numerous Simultaneously optimize numerous design design

metricsmetrics::►Time-to-prototypeTime-to-prototype►Time-to-marketTime-to-market►MaintainabilityMaintainability►Correctness, reliability, safety, etc.Correctness, reliability, safety, etc.

8 months

Page 37: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 37

ESs’ modelingESs’ modeling

► ChallengesChallenges::1.1. TechnologicalTechnological: build an embedded : build an embedded

system of predictable functionality and system of predictable functionality and quality (performance & robustness) quality (performance & robustness) considering the system’s constraints;considering the system’s constraints;

2.2. ScientificScientific: integrate Electrical : integrate Electrical Engineering and Computer Science Engineering and Computer Science methodologies. methodologies.

Page 38: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 38

How to satisfy the How to satisfy the scientific scientific challenge? challenge?

Electrical engineeringElectrical engineering► Differential equationsDifferential equations► Linear algebraLinear algebra► Probability theoryProbability theory

► SythesisSythesis

► Theories of estimationTheories of estimation► Theories of robustnessTheories of robustness

Computer scienceComputer science► LogicLogic► Discrete structuresDiscrete structures► Automata theoryAutomata theory

► Theories of Theories of correctnesscorrectness

► VerificationVerificationLet’s take down the cultural wall between Let’s take down the cultural wall between the two fields!the two fields!

Page 39: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 39

Modeling (1)Modeling (1)

Main steps of the ES’s designMain steps of the ES’s design::1.1. Definition of system’s constraints / Definition of system’s constraints /

requirements;requirements;

2.2. Derivation of an abstract system, i.e. Derivation of an abstract system, i.e. a model;a model;

3.3. Automatic generation of a system. Automatic generation of a system.

Page 40: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 40

Modeling (2)Modeling (2)

► However, we cannot separate computation However, we cannot separate computation (SW) from physicality (SW) from physicality ((platform & platform & environmentenvironment))!!

SW designSW design

a program

a code

a compilergenerates

modelmodel

HW designHW design

a HW description

a circuit

a computer-aided design tool synthesizes

modelmodel

Page 41: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 41

Analytical modeling (1)Analytical modeling (1)

►AnalyticAnalyticalal model model is ais a simulationsimulation,, based based on on an an abstract abstract system’s system’s representationrepresentation, which:, which: attempts to find attempts to find analytical analytical (equation-(equation-

based) based) solutions to problemssolutions to problems thatthat enable enable the prediction of the the prediction of the system’s system’s behavior behavior from a set of parameters and initial from a set of parameters and initial conditionsconditions..

Page 42: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 42

Analytical modeling (2)Analytical modeling (2)

►Types of aTypes of analyticnalyticalal model modelss :: algorithm-basedalgorithm-based (language-based: Ada, (language-based: Ada,

RT-Java / synthesis-based: VHDL, Verilog),RT-Java / synthesis-based: VHDL, Verilog), equation-basedequation-based (MATLAB/Simulink) (MATLAB/Simulink)

►object-oriented,object-oriented,►dynamic simulation,dynamic simulation,►implementation platform independent (implementation platform independent (model-model-

basedbased););►ANSYS.ANSYS.

Page 43: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 43

Analytical modeling (3)Analytical modeling (3)

► Building blocksBuilding blocks: : typestypes: transistors, logic gates, functional components (adders), : transistors, logic gates, functional components (adders),

architectural components (processors);architectural components (processors); structure changesstructure changes: deterministic, or probabilistic;: deterministic, or probabilistic; compositioncomposition: interconnected, inherently parallel, determined by data : interconnected, inherently parallel, determined by data

flows;flows; formal semanticsformal semantics: transfer functions, typically specified by equations;: transfer functions, typically specified by equations;

ExamplesExamples: netlists, dataflow diagrams, and other notations for describing system’s structure.

Page 44: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 44

Analytical modeling (4)Analytical modeling (4)

► Embedded Embedded MATLAB:MATLAB: automatic automatic

code code generation generation of of C and C and C+C++ objects+ objects, , optimized optimized for ESs.for ESs.

Page 45: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 45

Computational modeling (1)Computational modeling (1)

► ComputationalComputational model model is is a a computer programcomputer program, or , or a a network of computers, network of computers, whichwhich attempts to simulate attempts to simulate an abstract model of a particular systeman abstract model of a particular system:: ssimulationimulation is combined is combined with with the the reality of actual eventsreality of actual events;; solutions to the problem are solutions to the problem are machine-basedmachine-based..

Page 46: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 46

Computational modeling (2)Computational modeling (2)

►Types of computationalTypes of computational model modelss :: machine-basedmachine-based (RT/UML, AADL) (RT/UML, AADL)

►object-oriented,object-oriented,►dynamic simulation,dynamic simulation,►more generic (execution semantics more generic (execution semantics

independent) – independent) – model-basedmodel-based..

Page 47: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 47

Computational modeling (3)Computational modeling (3)

► Building blocks:Building blocks: typestypes: objects, threads;: objects, threads; structure changesstructure changes: dynamically;: dynamically; compositioncomposition: sequential, determined by control flows;: sequential, determined by control flows; formal semanticsformal semantics: abstract machine (virtual machine / : abstract machine (virtual machine /

automaton);automaton);

ExamplesExamples: programs, state machines, and other notations for describing system dynamics.

Page 48: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 48

Computational modeling (4)Computational modeling (4)

►Be realistic about the UML:Be realistic about the UML: Lack of Lack of analytical toolsanalytical tools for computational for computational

models to deal with physical constraints;models to deal with physical constraints; Generally,Generally, c codeode is still individually is still individually

designed, not automatically generated.designed, not automatically generated.

Page 49: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 49

Analytical vs. computational Analytical vs. computational modelingmodeling

Analytical modelingAnalytical modeling Computational Computational modelingmodeling

ConcurrencyConcurrency + / naturally deals with + / naturally deals with concurrencyconcurrency

--

Physical Physical constraintsconstraints

++ --

NondeterminismNondeterminism - / struggles with partial - / struggles with partial & incremental & incremental specifications specifications

+ / supports + / supports nondeterministic abstraction nondeterministic abstraction

hierarchies hierarchies

Computational Computational complexitycomplexity

-- + / rich theory+ / rich theory

Analytical & Analytical & synthesis synthesis techniquestechniques

++ --

Automatic Automatic generation of a generation of a systemsystem

++ + / directly executable + / directly executable modelsmodels

Page 50: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 50

Software and program design Software and program design conceptsconcepts

►SW PrototypingSW Prototyping

Page 51: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 51

What do we want in our SW?What do we want in our SW?

► Correctness: the static property that a

program is consistent with its specification;

► Reliability: the extend to which a

program can be expected to perform its intended function with required precision;

► Safety: the extend to which a

program is concerned with the consequences of failure.

dependable SW

correct

reliable

safe

is

We wish that our SW is We wish that our SW is dependable, is delivered on dependable, is delivered on time and is done within time and is done within budget!budget!

Page 52: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 52

How to achieve this? (1)How to achieve this? (1)

1.1. Develop a clear statement of system’s requirements.Develop a clear statement of system’s requirements.2.2. Ensure that the design solution is capable of achieving Ensure that the design solution is capable of achieving

this.this.3.3. Organize the development so that the project is Organize the development so that the project is

manageable.manageable.4.4. Organize the development so that timescales can be met.Organize the development so that timescales can be met.5.5. Make sure that the design can be managed without major Make sure that the design can be managed without major

rewrites.rewrites.6.6. Design for testability.Design for testability.7.7. Minimize risks by using tried and trusted methods.Minimize risks by using tried and trusted methods.8.8. Ensure that safety is given its correct priority.Ensure that safety is given its correct priority.9.9. Make sure that the project doesn’t completely rely on Make sure that the project doesn’t completely rely on

particular individual.particular individual.10.10.Produce a maintainable design.Produce a maintainable design.11.11.??

Page 53: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 53

How to achieve this? (2)How to achieve this? (2)

System’s requirements

What it’s supposed to do

function

Do’s and don’t’s

constraints

How it fits inwith its

environment

interfaces

How well itmust do it

performance

‘real-world’ interfaces ‘SW world’ interfaces

man-machine plant OSs databases

functionalfunctional non-functionalnon-functional non-functionalnon-functional non-functionalnon-functional

Page 54: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 54

How to achieve this? (3)How to achieve this? (3)sy stem’s

requirementscapturing

architectural

design

architectural

ev aluation

design

architectural

ref inement

integration

metrics

collection

sof tware

libraries

hardware

libraries

sof tware hardware

sy nthesis

virtual prototypingvirtual prototyping

Page 55: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 55

OSs for RT ApplicationsOSs for RT Applications

►Basics of RTOSs;Basics of RTOSs;

Page 56: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 56

Role of OSsRole of OSs

► Typical OS configurationTypical OS configuration::

► OS is an organized collection of OS is an organized collection of SW extensions of HW that serve SW extensions of HW that serve as:as: control routines for operating control routines for operating

a computer;a computer; an environment for execution an environment for execution

of programs.of programs.

► Typical embedded Typical embedded configurationconfiguration::

HW

OSUser programs

HW

User programsincluding RTOScomponents

Page 57: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 57

OS hierarchyOS hierarchy

► Typical OS Typical OS configurationconfiguration::

► Typical embedded Typical embedded configurationconfiguration::

► OS kernel gives us control over OS kernel gives us control over the resources:the resources: No background processes;No background processes; Bounded number of tasks;Bounded number of tasks;

► OS kernel gives us control over OS kernel gives us control over timing by allowing:timing by allowing: Manipulation of task priorities;Manipulation of task priorities; Choice of scheduling options.Choice of scheduling options.

HW

OS Kernel

File & Disk Control

OS User Interface Shell

Applicationprogram

Applicationprogram

Applicationprogram

HW

OS Kernel

Applicationprogram interfaces

OS Executive

Real-worldinterfaces

Page 58: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 58

Terminology: tasks & functions Terminology: tasks & functions (1)(1)

► A A tasktask is a is a processprocess that that repeats itself:repeats itself: Loop forever;Loop forever; Essential building block Essential building block

of real-time SW systems;of real-time SW systems; A job is an instance of a A job is an instance of a

task.task.

► A A functionfunction is a is a procedureprocedure that is that is called. It runs, then called. It runs, then exits and may return a exits and may return a value.value.

while(1){ get_data(); process_data();}

looploop

functionsfunctions

a task with a real-time a task with a real-time purposepurpose

Page 59: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 59

Terminology: tasks & functions Terminology: tasks & functions (2)(2)

► Periodic tasksPeriodic tasks:: Time-drivenTime-driven:: ccharacteristics are known a prioriharacteristics are known a priori;; Task Task ttii is characterized by (T is characterized by (Tii, C, Cii));; For example, For example, ttask monitoring temperature of a patient.ask monitoring temperature of a patient.

► Aperiodic tasksAperiodic tasks:: Event-drivenEvent-driven:: ccharacteristics are not known a prioriharacteristics are not known a priori;; Task Task ttii is characterized by (C is characterized by (Cii, D, Dii) and some probabilistic ) and some probabilistic

profileprofile for arrival patterns (e.g. Poisson model)for arrival patterns (e.g. Poisson model);; For example, tFor example, task activated upon detecting change in ask activated upon detecting change in

patient’spatient’s condition.condition.► Sporadic TasksSporadic Tasks::

Aperiodic tasks with known minimum inter-arrival time (TAperiodic tasks with known minimum inter-arrival time (Tii, , CCii))..

Page 60: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 60

Terminology: tasks & functions Terminology: tasks & functions (3)(3)

► Task’s parameters:Task’s parameters: Release timeRelease time: the time when a job is ready;: the time when a job is ready; Computation timeComputation time: usually Worst-Case Execution : usually Worst-Case Execution

Time (CTime (Cii);); DeadlineDeadline: the time when a job should be ready : the time when a job should be ready

(D(Dii);); PeriodPeriod: Period or minimum interarrival time;: Period or minimum interarrival time; PriorityPriority: static or dynamic;: static or dynamic; Blocking timeBlocking time: worst-case;: worst-case; Response time (latency)Response time (latency): the time difference : the time difference

between the release time of a job and the between the release time of a job and the completition time of the job.completition time of the job.

Page 61: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 61

Terminology: Processes & Terminology: Processes & ThreadsThreads

► InIn traditional multitasking traditional multitasking OSs,OSs, processesprocesses are typically are typically independent, carry independent, carry considerable state considerable state information, have separate information, have separate address spaces, and interact address spaces, and interact only through system-provided only through system-provided inter-process communication inter-process communication mechanisms. mechanisms.

► Multiple Multiple threadsthreads, on the other , on the other hand, typically share the hand, typically share the state information of a single state information of a single process, and share memory process, and share memory and other resources directly. and other resources directly.

► Context switching between Context switching between threads in the same process threads in the same process is typically faster than is typically faster than context switching between context switching between processes.processes.

A threadthread ((of executionof execution)) is is a way for a way for a programa program to fork (or split)to fork (or split) itself into itself into two ortwo or more more (pseudo-)(pseudo-)simultaneously simultaneously running tasks.running tasks.

Page 62: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 62

Basic RTOS kernel functionsBasic RTOS kernel functions

►Task schedulerTask scheduler: to determine which : to determine which task will run next in a multitasking task will run next in a multitasking system;system;

►Task dispatcherTask dispatcher: to perform necessary : to perform necessary book-keeping to start a task;book-keeping to start a task;

►Control of shared resourcesControl of shared resources: to support : to support intertask communication.intertask communication.

Page 63: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 63

OSs for RT ApplicationsOSs for RT Applications

►Basics of RTOSs;Basics of RTOSs;►Scheduling modeling assumptions.Scheduling modeling assumptions.

Page 64: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 64

RTOS kernel design strategies RTOS kernel design strategies (1)(1)

► Simple optionsSimple options::1.1. Pooled loop systemsPooled loop systems::

A single and repetative instruction tests a flag that A single and repetative instruction tests a flag that indicates whether or not an event has occured;indicates whether or not an event has occured;

No scheduling and intertask communication needed;No scheduling and intertask communication needed; Processor is dedicated to handling the data channel.Processor is dedicated to handling the data channel.

2.2. Interrupt-driven systemsInterrupt-driven systems:: Processing continues until interrupted by external Processing continues until interrupted by external

events;events; After interrupt has been serviced, processing After interrupt has been serviced, processing

resumes where it left off.resumes where it left off.

Page 65: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 65

Interrupt handlingInterrupt handling

► An An interruptinterrupt is a SW or is a SW or HW HW signalsignal to the to the processor,processor, indicating that something indicating that something

urgent has happened:urgent has happened:► Current task wants to Current task wants to

sleep or get I/O;sleep or get I/O;► Scheduler wants to run a Scheduler wants to run a

different task now;different task now;► Sensors detect external Sensors detect external

events;events; Interrupts can be:Interrupts can be:

► prioritized,prioritized,► disabled,disabled,► masked.masked.

interrupts

ISRISR

ISR

Processor must check for Processor must check for interrupts very frequently.interrupts very frequently.

Page 66: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 66

RTOS kernel design strategies RTOS kernel design strategies (2)(2)

► Extended optionsExtended options::

1.1. MultitaskingMultitasking

2.2. Foreground / background systemsForeground / background systems

3.3. Full featured RTOSsFull featured RTOSs

Page 67: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 67

Multitasking (1)Multitasking (1)

► Separate tasks share one or Separate tasks share one or more more processorsprocessors..

► Each task executes within its own Each task executes within its own contextcontext::

► Owns Owns CPU;CPU;► Sees its own variablesSees its own variables;;► May be interruptedMay be interrupted;;

► Tasks may interact to execute as a Tasks may interact to execute as a whole programwhole program..

Page 68: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 68

Multitasking (2)Multitasking (2)

► Ways to implement multitasking:Ways to implement multitasking: Cyclic Executive Cyclic Executive (statically ordered tasks / threads)(statically ordered tasks / threads) Round Robin Round Robin (each task is assigned a fixed time slice)(each task is assigned a fixed time slice)

► These waysThese ways areare not perfectnot perfect:: High priority tasks hog resources and starve low High priority tasks hog resources and starve low

priority taskspriority tasks;; Low priority tasks share a resource with high priority Low priority tasks share a resource with high priority

tasks and block hightasks and block high priority taskpriority tasks.s.► How does a RTOS deal with some of these issues?How does a RTOS deal with some of these issues?

Rate Monotonic Rate Monotonic / Earliest Deadline / Earliest Deadline SystemsSystems Priority InheritancePriority Inheritance

Page 69: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 69

Rate Monotonic systems (Liu & Rate Monotonic systems (Liu & Layland, 1973)Layland, 1973)

► General characteristicsGeneral characteristics:: Priority-based pre-Priority-based pre-

emptive staticemptive static scheduling;scheduling;

Highest-priority ready Highest-priority ready tasktask runs runs first; first;

Task priority P is set Task priority P is set according to its according to its periodicity Tperiodicity Tpp: : P=1/ TP=1/ Tpp;;

Tasks are equally Tasks are equally important;important;

SCHED_FIFO (POSIX)SCHED_FIFO (POSIX)

► ConsCons:: It cannot deal with aperiodic It cannot deal with aperiodic

tasks;tasks; Task deadline and period are Task deadline and period are

considered to be considered to be synonymous;synonymous;

TaskTask worst-case worst-case execution execution time is constanttime is constant;;

Tasks are independent, i.e. Tasks are independent, i.e. non-interacting.non-interacting.

► ProsPros:: Zero contextZero context--switch timeswitch time;; Task set scheduled using Task set scheduled using

RMS is guaranteed to be RMS is guaranteed to be feasiblefeasible provided its provided its utilizationutilization does not exceed does not exceed 0.693 (0.693 (full utilizationfull utilization).).

Page 70: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 70

Rate Monotonic systems (2)Rate Monotonic systems (2)

►UtilizationUtilization:: The percentage of The percentage of

available available processor time processor time spent executing spent executing tasks (Utasks (Utt););

The lowest The lowest utilization figure utilization figure U for n tasks is U for n tasks is U=n(2U=n(21/n1/n-1)-1)..

tastaskk

execution execution time (ms)time (ms)

deadline / deadline / period (ms)period (ms)

11 11 88

22 22 55

33 22 1010

Ut=1/8+2/5+2/10=0.725

U= 3(21/3-1)=0.78

Since USince Utt < U ... the system is < U ... the system is schedulable!schedulable!

Page 71: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 71

Earliest Deadline First (EDF)Earliest Deadline First (EDF)

► General General characteristicscharacteristics:: Priority-based pre-Priority-based pre-

emptive dynamicemptive dynamic scheduling;scheduling;

Highest-priority Highest-priority ready ready tasktask runs runs first; first;

Task priority P is set Task priority P is set according to its due according to its due time Ttime Tgg: : P=1/ TP=1/ Tgg;;

Tasks are equally Tasks are equally important;important;

► ConsCons:: Tasks’ priorities need to Tasks’ priorities need to

bebe recalculated recalculated at every at every timer interrupttimer interrupt;;

Task set scheduled using Task set scheduled using EDF is guaranteed to be EDF is guaranteed to be feasiblefeasible even if its even if its utilizationutilization is 1. is 1.

► ProsPros:: Task may miss its Task may miss its

deadline.deadline.

Page 72: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 72

Foreground / background Foreground / background systemssystems

►Most common Most common hybrid solutionhybrid solution for for embedded applications.embedded applications.

► Involve Involve interrupt-driveninterrupt-driven (foreground) & (foreground) & non-interrupt-drivennon-interrupt-driven (background) (background) processes:processes: Anything non-time-critical should be in Anything non-time-critical should be in

background.background.

Page 73: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 73

OSs for RT ApplicationsOSs for RT Applications

►Basics of RTOSs;Basics of RTOSs;►Scheduling modeling assumptionsScheduling modeling assumptions;;► Interprocess communication.Interprocess communication.

Page 74: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 74

Priority inversionPriority inversion

► ProblemProblem:: Task TTask T11 of high of high

priority and task Tpriority and task T33 of low priority share of low priority share a resource;a resource;

Task TTask T11 is blocked is blocked when task Twhen task T33 runs runs ((priority inversionpriority inversion); );

Task TTask T1 1 will be will be blocked for longer if blocked for longer if task Ttask T22 of medium of medium priority comes along priority comes along to keep task Tto keep task T33 from from finishing;finishing;

► SolutionSolution:: A good RTOS would A good RTOS would

sense this condition sense this condition and temporarily and temporarily promote task Tpromote task T33 to to the high priority of the high priority of task Ttask T1 1 ((priority priority inheritanceinheritance).).

Page 75: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 75

How to overcome priority How to overcome priority inversion? inversion?

► ProblemProblem:: ► Solution Solution ((priority priority ceiling protocolceiling protocol):):

T3 T3 T3

T2

T1T1

time

priority

low

high

T1 is blocked because T3 has the resource

T2 can block T3, which

also keeps T1 waiting

T3 inherits T1’s priorityso it can finish and then T1 can have the resource

time

low

high

T3

T3

T3

T2

T1T1

priority

Page 76: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 76

OSs for RT ApplicationsOSs for RT Applications

►Basics of RTOSs.Basics of RTOSs.►Scheduling modeling assumptions.Scheduling modeling assumptions.► Interprocess communication.Interprocess communication.►Power management.Power management.

Page 77: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 77

Power optimizationPower optimization

►Power managementPower management: : determines how system resources are determines how system resources are

going to be going to be used to used to satisfy thesatisfy the power power consumptionconsumption’s requirement’s requirement..

►RTRTOS OS may may reduce power by shutting reduce power by shutting down unitsdown units:: Entering and leaving the power-down Entering and leaving the power-down

mode requires both, energy and timemode requires both, energy and time..

Page 78: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 78

Power Power management policies management policies (1)(1)

► Request-drivenRequest-driven: : PPower up once ower up once

request is receivedrequest is received;; ConCon: : Adds delay to Adds delay to

response.response.

► Predictive shutdownPredictive shutdown:: Due timeDue time toto next next

requestrequest is predicted; is predicted; ProPro: : May start up in May start up in

advance of request in advance of request in anticipation of a new anticipation of a new requestrequest;;

ConCon: : If predictIf prediction ision is wrong, wrong, an an additional additional delay delay may be incured may be incured while starting up.while starting up.

Page 79: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 79

Power Power management policies management policies (2)(2)

►Probabilistic shutdownProbabilistic shutdown: : Assume service requests are probabilisticAssume service requests are probabilistic;; Optimize expected values:Optimize expected values:

►power consumption;power consumption;►response time.response time.

Simple probabilisticSimple probabilistic: shut down after time : shut down after time TTonon, turn back on after waiting for T, turn back on after waiting for Toffoff..

Page 80: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 80

Advanced Configuration and Advanced Configuration and Power InterfacePower Interface

►ACPIACPI ( (open standard for power open standard for power management servicesmanagement services))..

Hardware platform

devicedrivers

ACPI BIOS

RTOS kernel

application

powermanagement

Page 81: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 81

OSs for RT ApplicationsOSs for RT Applications

►Basics of RTOSs.Basics of RTOSs.►Scheduling modeling assumptions.Scheduling modeling assumptions.► Interprocess communication.Interprocess communication.►Power management.Power management.►Examples of commercial RTOSs.Examples of commercial RTOSs.

Page 82: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 82

Examples of commercial RTOSs Examples of commercial RTOSs (1)(1)

► RTOSsRTOSs: VxWorks (VRTX), QNX, LynxOS, : VxWorks (VRTX), QNX, LynxOS, eCos, DeltaOS, PSX, embOS, ...eCos, DeltaOS, PSX, embOS, ... satisfy the standard Real-Time POSIX 1003.1 satisfy the standard Real-Time POSIX 1003.1

(pre-emptive fixed-priority scheduling, (pre-emptive fixed-priority scheduling, synchronization methods, task scheduling synchronization methods, task scheduling options).options).

► Because people love Because people love general-purpose OSsgeneral-purpose OSs:: RTLinux (FSMLabs),RTLinux (FSMLabs), Linux/RT (TimeSys),Linux/RT (TimeSys), Windows CE, ...Windows CE, ...

Page 83: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 83

Examples of commercial RTOSs Examples of commercial RTOSs (2)(2)

► LynxOSLynxOS:: Microkernel architecture Microkernel architecture

that provides scheduling, that provides scheduling, interrupt & interrupt & synchronization supportsynchronization support

Real-time POSIX supportReal-time POSIX support Easy transition from Easy transition from

LinuxLinux

► VxWorksVxWorks:: Monolithic kernel (reduces Monolithic kernel (reduces

run-time overhead, but run-time overhead, but has an increased kernel has an increased kernel size compared to size compared to microkernel designs)microkernel designs)

Real-time POSIX supportReal-time POSIX support Common in industry:Common in industry:

► Mars missionMars mission► Honda ASIMO robotHonda ASIMO robot► SwitcesSwitces► MRI scannersMRI scanners► Car engine control Car engine control

systems systems

Page 84: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 84

Examples of commercial RTOSs Examples of commercial RTOSs (3)(3)

► RTLinuxRTLinux:: Dual-kernel Dual-kernel

approach:approach:► Makes Linux a low-Makes Linux a low-

priority pre-emptable priority pre-emptable thread running on a thread running on a separate RTLinux separate RTLinux kernel;kernel;

► Tradeoff between Tradeoff between determinism of pure determinism of pure RTOSs and flexibility RTOSs and flexibility of GPOSs.of GPOSs.

Periodic tasks only.Periodic tasks only.

Page 85: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 85

Open IssueOpen Issuess - - Multi-criteria Multi-criteria Optimization Problems (1)Optimization Problems (1)

► HW/SW partitioning:HW/SW partitioning: By evolutionary By evolutionary

algorithms & algorithms & genetic algorithms, genetic algorithms, Lothar Thiele, ETH.Lothar Thiele, ETH.

Page 86: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 86

Open IssueOpen Issuess - - Multi-criteria Multi-criteria Optimization Problems (2)Optimization Problems (2)

► CConfigurable onfigurable processor processor technology technology TensilicaTensilica ((http://www.tensilica.comhttp://www.tensilica.com

):): fitting the fitting the

processor to the processor to the algorithm;algorithm;

Page 87: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 87

EU Technological platform EU Technological platform ARTEMISARTEMIS

Page 88: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 88

Organization (1)Organization (1)

►ConsultationConsultation: JSI / room S6D, (01) : JSI / room S6D, (01) 4773-363, [email protected] 4773-363, [email protected]

►Next lectureNext lecture: 4: 4thth March, 2008 March, 2008►Web page Web page (course material): (course material):

csd.ijs.si/korousic/korousic.htmlcsd.ijs.si/korousic/korousic.html

Page 89: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 89

Organization (2)Organization (2)

►ReferencesReferences:: J. Cooling, Software Engineering for Real-J. Cooling, Software Engineering for Real-

Time Systems, Addison-Wesley, 2003;Time Systems, Addison-Wesley, 2003; F. Vahid, T.Givargis, Embedded System F. Vahid, T.Givargis, Embedded System

Design – A Unified Hardware/Software Design – A Unified Hardware/Software Introduction, Wiley, 2002;Introduction, Wiley, 2002;

IEEE Computer, Vol. 40, No. 10, October IEEE Computer, Vol. 40, No. 10, October 2007;2007;

http://www.echelon.com/solutions/industrial/appshttp://www.echelon.com/solutions/industrial/appstories/tories/

http://www.mathworks.fr/products/simulink/demohttp://www.mathworks.fr/products/simulink/demos.html?file=/products/demos/wt/s.html?file=/products/demos/wt/spacecraft.htmspacecraft.htmll

Page 90: Real-Time  Embedded Systems

Jožef Stefan International Postgraduate School 90

Organization (3)Organization (3)

►Course materialCourse material:: slide copies, slide copies, books, books, paperspapers

►ExamExam: : seminar work OR seminar work OR oraloral exam exam May, June, SeptemberMay, June, September