What is a Concurrent Program?

Download Report

Transcript What is a Concurrent Program?

CSC 321 Concurrent Programming
Course web site
http://www.cs.qub.ac.uk/csc321
CSC321 §1 Concurrent Programming
1
Lectures
Lecturer:
Professor NS Scott
Room 2.08, Computer Science Building
Phone: 028 9027 4647
E-mail: [email protected]
Lectures:
Monday 10-11, 209 PFC
Wednesday 11-12, 1.15 Crossland
Friday 11-12, 1.15 Crossland
CSC321 §1 Concurrent Programming
Course Administrator:
Dr Ashok Ramasubbu
Room 2.08, Computer Science Building
Phone : 028 9027 4644
E-mail: [email protected]
Approximately 30 lectures, starting
Monday 24 September 2001
2
Book List
 Jeff Magee & Jeff Kramer, Concurrency: state models and
Java Programs, Wiley
http://www-dse.doc.ic.ac.uk/concurrency
 Java examples and demonstration programs
 State models for the examples
 Labelled Transition System Analyser (LTSA) for modelling concurrency,
model animation and model property checking.
 M. Ben-Ari, Principles of Concurrent and Distributed
Programming, Prentice-Hall.
CSC321 §1 Concurrent Programming
3
Practical Classes
There will be no formal practical classes.
However, it is essential that each student, in his/her own time,
works through the collection of practical exercises located on the
course web site at http://www.cs.qub.ac.uk/csc321.
Weekly advisory sessions to help with queries will be available at a
time to be announced.
CSC321 §1 Concurrent Programming
4
Method of Assessment
 Two programming assignments each contributing 5%
to the final grade.
 Two written assignments each contributing 5% to the
final grade.
 A final three-hour written examination contributing
80% to the final grade.
CSC321 §1 Concurrent Programming
5
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.
CSC321 §1 Concurrent Programming
6
Why Concurrent Programming?
 Performance gain from multiprocessing hardware
 parallelism.
 Increased application throughput
 an I/O call need only block one thread.
 Increased application responsiveness
 high priority thread for user requests.
 More appropriate structure
 for programs which interact with the environment, control
multiple activities and handle multiple events.
CSC321 §1 Concurrent Programming
7
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.
CSC321 §1 Concurrent Programming
8
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?
CSC321 §1 Concurrent Programming
9
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.
CSC321 §1 Concurrent Programming
10
Modelling the Cruise Control System
LTSA Animator to step through
system actions and events.
engineOn
0
1
engineOff
speed
LTS of the process
that monitors speed.
Later sections will explain how to
construct models such as this so as to
perform animation and verification.
CSC321 §1 Concurrent Programming
11
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 sections
will explain how to construct Java programs such as
the Cruise Control System.
“Toy” problems are also used as they
crystallize particular aspects of
concurrent programming problems!
CSC321 §1 Concurrent Programming
12
Course Objectives
This course is intended:
 to assist the student in obtaining an appreciation of
the difference between sequential and concurrent
programs;
 to provide the student with a sound understanding of
the concepts, models and practice involved in designing
concurrent software;
 to provide the student with concurrent programming
practice and experience through the use of Java.
CSC321 §1 Concurrent Programming
13
Course Objectives
The emphasis on principles and concepts provides a
thorough understanding of both the problems and the
solution techniques. Modelling provides insight into
concurrent behaviour and aids reasoning about
particular designs.
After the course the student should understand the
problems that are specific to concurrent programs and
the means by which such problems can be avoided or
overcome.
CSC321 §1 Concurrent Programming
14
Course Outline
Concurrent Programming Abstraction & Java Threads
 The Mutual Exclusion Problem
 Semaphores
 Monitors
Modelling Process using FSP
Modelling Concurrency using FSP
 Implementing FSP Models in Java
 Deadlock
 Safety and Liveness Properties
 Message Passing
CSC321 §1 Concurrent Programming
15