Academia.eduAcademia.edu

Concurrency - state models and Java programs

1999

Concurrency State Models and Java Programs Jeff Magee Concurrency: introduction and Jeff Kramer 1 ©Magee/Kramer 2nd Edition What is a Concurrent Program? A sequential program has a single thread of control. A concurrent program has multiple threads of control allowing it perform multiple computations in parallel and to control multiple external activities which occur at the same time. Concurrency: introduction 2 ©Magee/Kramer 2nd Edition Concurrent and Distributed Software? Communication Network Interacting, concurrent software components of a system: single machine -> shared memory interactions multiple machines -> network interactions Concurrency: introduction 3 ©Magee/Kramer 2nd Edition Why Concurrent Programming? ‹ Performance gain from multiprocessing hardware z parallelism. ‹ Increased application throughput z an I/O call need only block one thread. ‹ Increased application responsiveness z high priority thread for user requests. ‹ More appropriate structure z for programs which interact with the environment, control multiple activities and handle multiple events. Concurrency: introduction 4 ©Magee/Kramer 2nd Edition Do I need to know about concurrent programming? Concurrency is widespread but error prone. ♦ Therac - 25 computerised radiation therapy machine Concurrent programming errors contributed to accidents causing deaths and serious injuries. ♦ Mars Rover Problems with interaction between concurrent tasks caused periodic software resets reducing availability for exploration. Concurrency: introduction 5 ©Magee/Kramer 2nd Edition a Cruise Control System When the car ignition is switched on and the on button is pressed, the current speed is recorded and the system is enabled: it maintains the speed of the car at the recorded setting. buttons ♦ Is the system safe? Pressing the brake, accelerator or off button disables the system. Pressing resume re-enables the system. ♦ Would testing be sufficient to discover all errors? Concurrency: introduction 6 ©Magee/Kramer 2nd Edition models A model is a simplified representation of the real world. Engineers use models to gain confidence in the adequacy and validity of a proposed design. ♦ focus on an aspect of interest - concurrency ♦ model animation to visualise a behaviour ♦ mechanical verification of properties (safety & progress) Models are described using state machines, known as Labelled Transition Systems LTS. These are described textually as finite state processes (FSP) and displayed and analysed by the LTSA analysis tool. Concurrency: introduction 7 ©Magee/Kramer 2nd Edition modeling the Cruise Control System LTSA Animator to step through system actions and events. engineOn 0 1 speed engineOff LTS of the process that monitors speed. Later chapters will explain how to construct models such as this so as to perform animation and verification. Concurrency: introduction 8 ©Magee/Kramer 2nd Edition programming practice in Java Java is ♦ widely available, generally accepted and portable ♦ provides sound set of concurrency features Hence Java is used for all the illustrative examples, the demonstrations and the exercises. Later chapters will explain how to construct Java programs such as the Cruise Control System. “Toy” problems are also used as they exemplify particular aspects of concurrent programming problems! Concurrency: introduction 9 ©Magee/Kramer 2nd Edition course objective This course is intended to provide a sound understanding of the concepts, models and practice involved in designing concurrent software. The emphasis on principles and concepts provides a thorough understanding of both the problems and the solution techniques. Modeling provides insight into concurrent behavior and aids reasoning about particular designs. Concurrent programming in Java provides the programming practice and experience. Concurrency: introduction 10 ©Magee/Kramer 2nd Edition Book Concurrency: State Models & Java Programs, 2nd Edition Jeff Magee & Jeff Kramer WILEY 1st edition Concurrency: introduction 11 ©Magee/Kramer 2nd Edition Course Outline 2. Processes and Threads 3. Concurrent Execution 4. Shared Objects & Interference 5. Monitors & Condition Synchronization Models 6. Deadlock 7. Safety and Liveness Properties Practice 8. Model-based Design The main basic Concepts Advanced topics … 9. Dynamic systems 12. Timed Systems 10. Message Passing 13. Program Verification 11. Concurrent Software Architectures 14. Logical Properties Concurrency: introduction 12 ©Magee/Kramer 2nd Edition Web based course material http://www.wileyeurope.com/college/magee ‹ Java examples and demonstration programs ‹ State models for the examples ‹ Labelled Transition System Analyser (LTSA) for modeling concurrency, model animation and model property checking. Concurrency: introduction 13 ©Magee/Kramer 2nd Edition Summary ‹ Concepts z we adopt a model-based approach for the design and construction of concurrent programs ‹ Models z we use finite state models to represent concurrent behavior. ‹ Practice z we use Java for constructing concurrent programs. Examples are used to illustrate the concepts, models and demonstration programs. Concurrency: introduction 14 ©Magee/Kramer 2nd Edition