Lecture Outline TDDC47: Real-Time Systems and Concurrent Programming Block 1: • Course information • Examples of systems where real-time systems are found • Definition of real-time system • Terminology and characteristics • The problems specific for real-time systems • Operating systems Block 1: Introduction Mehdi Amirijoo Real-Time Systems Laboratory Department of Computer Science Linköping University meham@ida.liu.se TDCC47 – Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU Personal • Examinator/föreläsare: – Mehdi Amirijoo (meham@ida.liu.se) • Lektionshandledare och labbassistent: – Mehdi Amirijoo – Jonas Elmqvist (jonel@ida.liu.se) • Kursinnehåll • Kursen behandlar två delar: 1. Processprogrammering (block 2): Processbegreppet, synkronisering och kommunikation mellan processer, hantering av baklås 2. Realtidssystem (block 3 och 4): Formulering av tidskrav, design map tidskrav, realtidskommunikation Kurssekreterare: – Anne Moe (annes@ida.liu.se) TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 • 2006 Innehållet består av två delar som normalt ges i två kurser TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 1 Kurslitteratur • Finns ej ngn bok som täcker hela kursen • Två böcker rekommenderas: 1. C. Norström, K. Sandström, J. Mäki-Turja, H. Hansson, H. Thane och J. Gustafsson, "Robusta realtidssystem“ – Tryckakademin, Kårallen – (processer block 2), schemaläggning block 3, realtidskommunikation block 4 Kursmål Efter genomgången kurs ska studenten självständigt kunna: – tydligt förklara principer bakom processer, processoperationer, och kommunikation mellan processer – karaktärisera delade resurser och kritiska sektioner, förklara synkroniseringsmekanismer och tekniker för att hantera låsning mellan processer – använda ansatser för att synkronisera processer samt tillämpa algoritmer för att undvika och hantera låsning mellan processer – beskriva designmetoder och ansatser för att tillgodose krav på realtidssystem inklusive nätverksbaserade system – uttrycka temporala krav på realtidssystem, välja lämplig ansats för att tillgodose kraven på ett realtidssystem samt jämföra prestanda av ansatser då flera existerar – kunna redogöra för samband mellan temporala egenskaper inom reglerteknik och realtidsteknik – tillämpa metoder för att höja prestanda i reglersystem som har implementerats med realtidsteknik 2. A. Burns and A. Wellings, ”Real-time Systems and their programming languages”, Addison Wesley, 2001. – Bokakademin, Kårallen – processer block 2, schemaläggning block 3, (realtidskommunikation block 4) – Diskuterar även andra delar som inte tas upp i kursen • Fyra Artiklar TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU Laborationer • • • • • • • MATLAB, TrueTime, Simulink – Kräver mindre erfarenhet med MATLAB – Ingen programmering (C++, ADA, Java etc), fokus på grundläggande koncept Laborationsuppgifter: 1. Synkronisering av processer 2. Schemaläggning 3. Reglering av datorprestanda Kräver att man har löst förberedelseuppgifter innan laboration Schemalagda tillfällen ej dedikerade åt viss uppgift Deadlines för varje laborationsuppgift – Kan ses som riktlinje för hur man bör planera Laborationsrapport Registrering i WebReg TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 2006 Mer info - Websidor • Kurshemsida: www.ida.liu.se/~TDDC47 • Kursinformation: – Organisation, mål, kursutvärdering – Kontorstid tisdagar 12:30-13:30 (ej 14:e nov) • Kompletterande kurslitteratur – MATLAB, Simulink • Examination (gamla tentor) • Föreläsningar och lektioner – Lektionsmaterial – Föreläsningsslides finns tillgängligt senast 24h innan föreläsning TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 2 Background • • • Traditionally systems have been controlled by analog (electrical) or mechanical systems However, there is an increasing need in the use of computers for controlling systems and to react to external stimuli Why? – To reduce costs, example: • Cables in a car are very expensive! • Replace cables with a computer network that uses one ”cable” – Add more functionality that cannot be provided by analog or mechanical systems: • Anti-spinn, ABS breaks, navigation system etc. – Easily upgrade system • ”Plug in your car to the Internet and upgrade the software” TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU Background Ok, let’s use computers! But before we do that let’s consider what type of systems we are dealing with…. 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU Safety system TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 2006 Drive-by-wire system TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 3 Networked system in a car A simple fluid control system Interface Pipe Input flow reading Flow meter Processing of Control Algorithm Valve Output valve angle Time Computer TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU A Process Control System A Production Control System Process Control Computer Valve Chemicals and Materials Temperature Transducer 2006 Production Control System Stirrer Finished Products Finished Products Parts Machine Tools Manipulators Conveyor Belt PLANT TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 4 What kind of computing systems? “Every-day” computing systems e.g. a PC Average is not enough Computing systems in previous slides e.g., system in a car Goal Minimize average response time of user requests React to environment in a predictive manner Result of failing goal Annoyed user Damage, loss of human life Conclusion Computer controls speed of user, Computer-time Computer has to follow speed of the environment, Real-time TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU A person drowned in a river which an average depth of 25 cm. 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 What is a real-time system? Real-time systems environment • A real-time system is any information processing system which has to respond to externally generated input stimuli within a finite and specified period called the deadline action event – the correctness depends not only on the logical result but also the time it was delivered I/O – failure to respond is as bad as the wrong response! • Clock 99% of all processors are for the embedded/realtime systems market TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU Real-time computing system 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 5 Terminology • Event-triggered (ET) system – The computations are driven by occurrence of events – Aperiodic processing – Example: airbag Example Example: Actuate if the temperature falls below a certain threshold. environment action event I/O Clock • Time-triggered (TT) system – Computation are driven by a clock – Periodic processing – Example: altitude control in an airplane Real-time computing system TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 Terminology Terminology Hard real-time — systems where it is absolutely imperative that responses occur within the required deadline. E.g. Flight control systems. • Soft real-time — systems where deadlines are important but which will still function correctly if deadlines are occasionally missed. E.g. video streaming. TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU penalty A single system may have all hard, soft and real real-time subsystems. In reality many systems will have a cost function associated with missing each deadline utility loss • benefit Hard real-time systems 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 6 Terminology Soft Real-Time Systems Soft real-time systems Utility (cost function) • Multiple requirements – Deadlines can be missed occasionally, but with… 1. an upper limit of misses within a defined interval 2. a constraint on the maximum number of consecutive deadline misses – Service can occasionally be delivered late, with an upper bound on lateness. • Hard real-time is hard, but soft real-time is harder! – Hard real-time deals with meeting individual deadlines – Soft real-time deals with maximizing the overall utility, which is much harder from an algorithmic point of view 1 3 2 time release deadline TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU Characteristics • Large and complex — vary from a few hundred lines of assembler or C to 20 million lines of Ada estimated for the International Space Station Freedom • Concurrent control of separate system components — devices operate in parallel in the real-world; better to model this parallelism by concurrent entities in the program • Facilities to interact with special purpose hardware — need to be able to program devices in a reliable and abstract way TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 2006 Characteristics • Extreme reliability and safe — systems typically control the environment in which they operate; failure to control can result in loss of life, damage to environment or economic loss • Guaranteed response times — we need to be able to predict with confidence the worst case response times for systems; efficiency is important but predictability is essential • Efficient implementation of the computations — the application developer must be concerned with the execution time of using a particular programming language feature. TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 7 Problem 1 Scheduling of computation (jobs, processes, tasks) Definition: – Hard real-time systems: Given a set of processes sequence their execution such that they all meet their deadlines. – Soft real-time systems: Given a set of processes, sequence their execution such that the overall utility is maximized. So – what are the problems? Let’s take a peek look at some problems in concurrent programming and real-time systems… TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU Problem 1 2006 Problem 2 Overload Management Does the schedule really matter? Definition (Overload): The situation where there are too many computations than the computer can handle This is shown in different ways: • Deadline misses • Overall utility is “too low” A scheduling problem can be mapped to the problem of assigning priorities to the processes. TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 8 Problem 2 Problem 2 Apollo 11, 1969, first lunar landing • The 1202 program alarm is being produced by unexpected flow of data concerning radar. • The computer has been programmed to recognize this data as being of secondary importance and will ignore it while it does more important computations. • Two possible solutions to overload: – Use time-triggered approach instead of an event-triggered approach – Control the workload by rejecting (not executing) some of the computations Michael Collins: At five minutes into the burn.. "Program Alarm," barks Neil, "It's a 1202." What the hell is that? I don't have the alarm numbers memorized for my own computer. I jerk out my own checklist and start thumbing through it, but before I can find 1202, Houston says, "Roger, we're GO on that alarm." No problem, in other words. My checklist says 1202 is an "executive overflow," meaning simply that the computer has been called upon to do too many things at once. A little farther along, at just three thousand feet above the surface, the computer flashes 1201, another overflow condition... TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 Problem 3 Problem 4 Priority Inversion Definition: The situation when a high priority process cannot be executed since it needs a resource that is used by a low priority process. Deadlock Avoidance and Management Definition (Deadlocks): A process is holding a resource and is waiting for another resource that is held by other waiting processes Deadline High Priority Process 1 Resource 1: File Low Priority Time Process Process 2 Resource 2: File High Priority Low Priority Time Common resource TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 9 Problem 4 Mars Pathfinder: • Autonomous robot designed to collect data about mars and transmit to earth • Pathfinder used a priority-based operating system. Each process had a priority. • The processes shared a common resource – the network • • Summary • Discussed – event-triggered systems – time-triggered systems – hard real-time systems – soft real-time systems • The basic characteristics of a real-time or embedded computer system are: – largeness and complexity, – extreme reliability and safety, – concurrent control of separate system components, – interaction with hardware interfaces, – efficient implementation. After a few days the robot started restarting itself It was found that the execution of a high priority process was delayed due to priority inversion, leading to the computer to restart itself. TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 What is an Operating System? Operating systems TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 • A program that acts as an intermediary between a user of a computer (user application) and the computer hardware. • Operating system goals: – Execute user programs – Provide services/functionality to user programs – Make the computer system convenient to use. – Use the computer hardware in an efficient manner. TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 10 Computer System Organization Computer-system operation • One or more CPUs, device controllers connect through common bus providing access to shared memory • Concurrent execution of CPUs and devices TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 Computer System Structure Computer-System Operation • Devices: – Each device controller is in charge of a particular device type. – Each device can operate in parallel with other devices – Each device controller has a local buffer. – CPU moves data from/to main memory to/from local device buffers – Device controller informs CPU that it has finished its operation by causing an interrupt. • When an interrupt occurs… – Interrupt transfers control to the interrupt service routine – Incoming interrupts are disabled while another interrupt is being processed. TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 Four Components of a Computer System Computer system can be divided into four components • Hardware – provides basic computing resources – CPU, memory, I/O devices • Operating system – Controls and coordinates use of hardware among various applications and users • Application programs – implement functionality and define the ways in which the system resources are used – Word processors, compilers, web browsers, database systems, video games • Users – People, machines, other computers TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 11 Operating System Definition • • OS is a resource allocator – Manages all resources – Decides between conflicting requests for efficient and fair resource use OS is a control program – Controls execution of programs to prevent errors and improper use of the computer TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 Operating System Services • User interface - Almost all operating systems have a user interface (UI) – Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch • Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error) • I/O operations - A running program may require I/O, which may involve a file or an I/O device. • File-system manipulation - The file system is of particular interest. Obviously, programs need to read and write files and directories, create and delete them, search them, list file Information, permission management. TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU Operating System Services (Cont.) • • Communications – Processes may exchange information, on the same computer or between computers over a network – Communications may be via shared memory or through message passing (packets moved by the OS) Error detection – OS needs to be constantly aware of possible errors – May occur in the CPU and memory hardware, in I/O devices, in user program – For each type of error, OS should take the appropriate action to ensure correct and consistent computing TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 2006 System Calls • System call provide an interface between a program and the services provided by the OS (previous slides) • Types of systems call: – Process control – File management – Device management – Communications TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 12 Example of System Calls System Call – OS Relationship System call sequence to copy the contents of one file to another file TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 Standard C Library Example C program invoking printf() library call, which calls write() system call TDDC47 - Real-Time Systems and Concurrent Programming M. Amirijoo, IDA, LiU 2006 13
© Copyright 2024