System and Realtime Programming (G53SRP)

28
1 System and Realtime Programming (G53SRP) Chris Greenhalgh Chris Greenhalgh School of Computer School of Computer Science Science

description

System and Realtime Programming (G53SRP). Chris Greenhalgh School of Computer Science. Aim:. To look at the issues of programming relevant to real-time, concurrent and embedded systems where timeliness, reliability, concurrency and hardware interfacing are required. - PowerPoint PPT Presentation

Transcript of System and Realtime Programming (G53SRP)

Page 1: System and Realtime Programming  (G53SRP)

1

System and Realtime Programming

(G53SRP)Chris GreenhalghChris Greenhalgh

School of Computer ScienceSchool of Computer Science

Page 2: System and Realtime Programming  (G53SRP)

2

Aim:• To look at the issues of programming To look at the issues of programming

relevant to real-time, concurrent and relevant to real-time, concurrent and embedded systemsembedded systems– where timeliness, reliability, concurrency and where timeliness, reliability, concurrency and

hardware interfacing are required.hardware interfacing are required.– with particular emphasis on Java, including the with particular emphasis on Java, including the

Real-time Specification for JavaReal-time Specification for Java

Page 3: System and Realtime Programming  (G53SRP)

3

Pre- and co-requisites• Introduction to programming (G51PRG)Introduction to programming (G51PRG)

– Moderate imperative programming Moderate imperative programming competence, including methods & classes, to be competence, including methods & classes, to be applied in Java for examples, exercises and applied in Java for examples, exercises and examinationexamination

• Concepts of concurrency (G52CON)Concepts of concurrency (G52CON)– Relevant material on Java threads and Relevant material on Java threads and

synchronization reviewed in the first few synchronization reviewed in the first few lectures.lectures.

Page 4: System and Realtime Programming  (G53SRP)

4

Format• The teaching and assessment of this module The teaching and assessment of this module

comprises:comprises:– ~ ~ 20 full-class lectures.20 full-class lectures.– 1 RTSJ coursework and report (25%).1 RTSJ coursework and report (25%).– 1 written examination: 2 hours, unseen, 75%.1 written examination: 2 hours, unseen, 75%.– Plus (of course) you review the material, look Plus (of course) you review the material, look

at past papers, revise… at past papers, revise…

Page 5: System and Realtime Programming  (G53SRP)

5

Support• Talk to or emailing the convener, Talk to or emailing the convener,

Chris Greenhalgh:Chris Greenhalgh:– in his office, room in his office, room B2B2

(CS building, (CS building, 11stst floorfloor, access over walkway , access over walkway from centre block, not through MRL!from centre block, not through MRL!).).

– by email, [email protected] email, [email protected] (repeatedly) (repeatedly)– see also http://www.cs.nott.ac.uk/~cmg/see also http://www.cs.nott.ac.uk/~cmg/

Page 6: System and Realtime Programming  (G53SRP)

6

Resources• 2 lectures per week – 2 lectures per week –

– All lectures are compulsory.All lectures are compulsory.– Any cancellations will be announced in lectures and Any cancellations will be announced in lectures and

on the web pageon the web page

• notes available on-line as the course progresses.notes available on-line as the course progresses.

• a WWW page giving information about the a WWW page giving information about the course, exercises, assessment, special course, exercises, assessment, special arrangements, etc (see CS Module Table):arrangements, etc (see CS Module Table):http://www.cs.nott.ac.uk/~cmg/G53SRP/http://www.cs.nott.ac.uk/~cmg/G53SRP/

Page 7: System and Realtime Programming  (G53SRP)

7

Textbooks• The course text-book, “The course text-book, “Real-Time Real-Time

Programming in Java”, Andy Wellings, Programming in Java”, Andy Wellings, Wiley, 2004 ISBN 0-470-84437-X Wiley, 2004 ISBN 0-470-84437-X

• The old course text-book, "Real-time The old course text-book, "Real-time systems and their programming languages", systems and their programming languages", Alan Burns and Andy Wellings, Addison-Alan Burns and Andy Wellings, Addison-Wesley, 2001 (third edition). Wesley, 2001 (third edition). – Second edition OK for non-RTJava-specific Second edition OK for non-RTJava-specific

stuff.stuff.

Page 8: System and Realtime Programming  (G53SRP)

8

Textbooks (ii)• See Library reading list for G53SRPSee Library reading list for G53SRP

– Linked from Module page & CS Module Index Linked from Module page & CS Module Index

• See also…See also…– Java books and online resources, e.g. "Java in a Java books and online resources, e.g. "Java in a

Nutshell", David Flanagan, O'Reilly & Nutshell", David Flanagan, O'Reilly & Associates, Inc. Associates, Inc.

– other textbooks in the library - try a UNLOC other textbooks in the library - try a UNLOC subject search.subject search.

Page 9: System and Realtime Programming  (G53SRP)

9

Topics• Concurrent (multi-threaded) programming in JavaConcurrent (multi-threaded) programming in Java• Concurrency control in JavaConcurrency control in Java• Real-time threads in RTSJReal-time threads in RTSJ• Scheduling, schedulability and resource sharingScheduling, schedulability and resource sharing• Event-driven and asynchronous programming in Event-driven and asynchronous programming in

Java and RTSJJava and RTSJ• Memory management in RTSJMemory management in RTSJ• Hardware interfacing in RTSJ   Hardware interfacing in RTSJ   • (Maybe: Interrupting threads, and asynchronous (Maybe: Interrupting threads, and asynchronous

transfer of control in RTSJ??)transfer of control in RTSJ??)

Page 10: System and Realtime Programming  (G53SRP)

10

Why?• So you appreciate simple applications when you So you appreciate simple applications when you

find them :-)find them :-)• "Real" systems are like this."Real" systems are like this.• Concurrent programming can be appropriate and Concurrent programming can be appropriate and

useful in some applications.useful in some applications.• Being "correct" is not always enough; something Being "correct" is not always enough; something

may also have to be "in time".may also have to be "in time".• Computers have increasingly critical roles to play Computers have increasingly critical roles to play

in real-world activities with important safety and in real-world activities with important safety and reliability requirements.reliability requirements.

Page 11: System and Realtime Programming  (G53SRP)

11

What is a real-time system?• A real-time system is any information processing system A real-time system is any information processing system

which has to respond to externally generated input stimuli which has to respond to externally generated input stimuli within a finite and specified periodwithin a finite and specified period

– the correctness depends not only on the logical result the correctness depends not only on the logical result but also the time it was deliveredbut also the time it was delivered

– failure to respond is as bad as the wrong response!failure to respond is as bad as the wrong response!

• The computer is a component in a larger engineering The computer is a component in a larger engineering system => EMBEDDED COMPUTER SYSTEMsystem => EMBEDDED COMPUTER SYSTEM

• 99% of all processors are for the embedded systems 99% of all processors are for the embedded systems marketmarket

Page 12: System and Realtime Programming  (G53SRP)

12

Terminology• HardHard real-time — systems where it is absolutely imperative real-time — systems where it is absolutely imperative

that responses occur within the required deadline. E.g. Flight that responses occur within the required deadline. E.g. Flight control systems.control systems.

• SoftSoft real-time — systems where deadlines are important but real-time — systems where deadlines are important but which will still function correctly if deadlines are which will still function correctly if deadlines are occasionally missed. E.g. Data acquisition system.occasionally missed. E.g. Data acquisition system.

• ““Real”Real” real-time — systems which are hard real-time and real-time — systems which are hard real-time and which the response times are very short. E.g. Missile which the response times are very short. E.g. Missile guidance system.guidance system.

• FirmFirm real-time — systems which are soft real-time but in real-time — systems which are soft real-time but in which there is no benefit from late delivery of service.which there is no benefit from late delivery of service.

A single system may have all hard, soft and real real-time subsystemsIn reality many systems will have a cost function associated with missing each deadline

Page 13: System and Realtime Programming  (G53SRP)

13

Examples

Page 14: System and Realtime Programming  (G53SRP)

14

A simple fluid control systemPipe

Flow meter

Valve

Interface

ComputerTime

Input flowreading

Processing

Output valveangle

Burns & Wellings, http://www.cs.york.ac.uk/rts/RTSbookThirdEdition/chap1.pptBurns & Wellings, http://www.cs.york.ac.uk/rts/RTSbookThirdEdition/chap1.ppt

Page 15: System and Realtime Programming  (G53SRP)

15

A Production Control SystemProductionControlSystem

Parts

Machine Tools Manipulators Conveyor Belt

FinishedProducts

Burns & Wellings, http://www.cs.york.ac.uk/rts/RTSbookThirdEdition/chap1.pptBurns & Wellings, http://www.cs.york.ac.uk/rts/RTSbookThirdEdition/chap1.ppt

Page 16: System and Realtime Programming  (G53SRP)

16

A Typical Embedded System

Algorithms forDigital Control

Data Logging

Data Retrievaland Display

OperatorInterface

InterfaceEngineeringSystem

RemoteMonitoring System

Real-TimeClock

Database

Operator’sConsole

Display Devices

Real-Time Computer

Burns & Wellings, http://www.cs.york.ac.uk/rts/RTSbookThirdEdition/chap1.pptBurns & Wellings, http://www.cs.york.ac.uk/rts/RTSbookThirdEdition/chap1.ppt

Page 18: System and Realtime Programming  (G53SRP)

A fly-by-wire aircraft (e.g. f-22 raptor)

18

Page 19: System and Realtime Programming  (G53SRP)

A rocket or missile(e.g. Ariane 5)

19

Page 20: System and Realtime Programming  (G53SRP)

An autonomous robot (e.g. Mars Pathfinder)

20

Page 21: System and Realtime Programming  (G53SRP)

21

Characteristics of a RTS• Large and complex — vary from a few Large and complex — vary from a few

hundred lines of assembler or C to 20 hundred lines of assembler or C to 20 million lines of Ada estimated for the Space million lines of Ada estimated for the Space Station FreedomStation Freedom

• Concurrent control of separate system Concurrent control of separate system components — devices operate in parallel components — devices operate in parallel in the real-world; better to model this in the real-world; better to model this parallelism by concurrent entities in the parallelism by concurrent entities in the programprogram

Page 22: System and Realtime Programming  (G53SRP)

22

• Facilities to interact with special purpose Facilities to interact with special purpose hardware — need to be able to program hardware — need to be able to program devices in a reliable and abstract waydevices in a reliable and abstract way

• Extreme reliability and safe — embedded Extreme reliability and safe — embedded systems typically control the environment systems typically control the environment in which they operate; failure to control can in which they operate; failure to control can result in loss of life, damage to environment result in loss of life, damage to environment or economic lossor economic loss

Page 23: System and Realtime Programming  (G53SRP)

23

• Guaranteed response times — we need to Guaranteed response times — we need to be able to predict with confidence the worst be able to predict with confidence the worst case response times for systems; efficiency case response times for systems; efficiency is important but predictability is essentialis important but predictability is essential

Page 24: System and Realtime Programming  (G53SRP)

24

Application Examples: Compiler

• CorrectCorrect

• Not interactiveNot interactive

• No deadlinesNo deadlines

• Typically sequentialTypically sequential

• May have safety critical impact depending May have safety critical impact depending on useon use

Page 25: System and Realtime Programming  (G53SRP)

25

Application Examples: WYSIWIG Word Processor

• InteractiveInteractive

• Timely responseTimely response

• Not realtimeNot realtime

• Rarely safety criticalRarely safety critical

• Additional opportunity to recover from Additional opportunity to recover from errorerror

• May have concurrencyMay have concurrency

Page 26: System and Realtime Programming  (G53SRP)

26

Application Examples: Washing machine controller

• EmbeddedEmbedded

• RealtimeRealtime

• May have concurrencyMay have concurrency

Page 27: System and Realtime Programming  (G53SRP)

27

Application Examples: Aircraft controller

• EmbeddedEmbedded

• Hard realtime systemHard realtime system

• Safety criticalSafety critical

• Plenty of concurrencyPlenty of concurrency

Page 28: System and Realtime Programming  (G53SRP)

28

Summary• Many systems and devices include Many systems and devices include

programmed computer-based elementsprogrammed computer-based elements

• These typically These typically – Exhibit concurrencyExhibit concurrency– Have timeliness requirements (hard or soft)Have timeliness requirements (hard or soft)– Interface to specific hardwareInterface to specific hardware– Must be safe and reliable Must be safe and reliable

See also Burns & Welling chapter 1, Wellings chapter 1See also Burns & Welling chapter 1, Wellings chapter 1