Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
11© Wolfgang Emmerich, Mark Handley 1998 - 2003
Mark Handley
Anthony Steed
3C03 Concurrency:
Introduction
2© Wolfgang Emmerich, Mark Handley 1998 - 2003
Course Overview
n Introduction to Concurrency
n Problems
n Process Algebras
n Analysis of Labelled Transition Systems
n Concurrent programming in Java
n Deadlocks
n Fairness
n Liveness
n Concurrency Control in Databases
23© Wolfgang Emmerich, Mark Handley 1998 - 2003
Communication
n E-Mail to us:
• m.handley@cs.ucl.ac.uk
• a.steed@cs.ucl.ac.uk
n E-Mail to rest of the course
• 3c03@cs.ucl.ac.uk
n If you have not already done so, subscribe to the e-mail
list 3c03!
4© Wolfgang Emmerich, Mark Handley 1998 - 2003
How to reach me.
Pearson Building, room 113
020 7679 7296
www.cs.ucl.ac.uk/staff/m.handley
35© Wolfgang Emmerich, Mark Handley 1998 - 2003
Organisation
n Lectures
Three per week
• Tuesday 1-2pm
• Wednesday 1-2pm
• Thursday 11am-12noon
n Tutorials
• Thursday 11am-12noon
n Labs (choose one)
• Tuesday 3-4pm (B13)
• Thursday 10-11am (B13+B26)
6© Wolfgang Emmerich, Mark Handley 1998 - 2003
Bibliography
n J. Magee & J. Kramer. Concurrency - State Models and
Java Programs. Wiley. 1999
n A. Burns & G. Davis. Concurrent Programming. Addison
Wesley - International Computer Science Series 1993
n G.R. Andrews. Concurrent Programming: Principles and
Practice. Benjamin/Cummings, 1991
n D. Lea. Concurrent Programming in Java™: Design
Principles and Patterns. The Java Series, Addison-
Wesley, 1996
n David Flanagan.Java in a Nutshell. O’Reilly &
Associates Inc. 1996
47© Wolfgang Emmerich, Mark Handley 1998 - 2003
What are you going to learn?
n Problems that occur when writing concurrent programs
n Formalisms to specify concurrency
n Analysis techniques to reason about correctness of
specifications
n Implementation of concurrency in Java
n Practical experience (specification, analysis,
implementation) in exercises and coursework
8© Wolfgang Emmerich, Mark Handley 1998 - 2003
Lecture Plan until Reading Week
1 Introduction
2 Modelling Processes
3 Modelling Concurrency
in FSP
4 FSP Tutorial
5 LTSA Lab
6 Programming in Java
7 Concurrency in Java
8 Lab: Java Thread
Programming
9 Mutual Exclusion
10 Lab: Synchronization in
Java
11 Semaphores and
Monitors
12 Conditional
Synchronization
13 Fairness & Liveness
14 Safety
15 Tutorial: Model
Checking
59© Wolfgang Emmerich, Mark Handley 1998 - 2003
Why Concurrent Programming?
n Performance gain from multiprocessing hardware
• Parallelism
n Increased application throughput
• A blocking I/O call only blocks one thread.
n Increased application responsiveness
• High priority thread for user requests.
n More appropriate structure
• For programs which control multiple activities and
handle multiple events.
n Distributed Systems
10© Wolfgang Emmerich, Mark Handley 1998 - 2003
Engineering of Concurrent Systems
n Concurrency in safety-critical systems
• Therac-25 failed due to race conditions
n Concurrency in mission-critical systems
• Increasing amount of business applications uses
concurrency
n Concurrency in operating systems
• Multi-processor systems are now cheap.
n Availability of concurrency in mainstream programming
languages
• e.g. Java and Ada-95
611© Wolfgang Emmerich, Mark Handley 1998 - 2003
Modelling Concurrency
n Analogy to Models in Engineering
n Modelling Concurrency
• Process Algebras in FSP
n Analysis of Models
• Using Labelled Transition System Analysis
n Transformation of Models
• into Java Implementations using Threads
12© Wolfgang Emmerich, Mark Handley 1998 - 2003
FSP Example
ITCH =            (scratch->STOP).
CONVERSE =        (think->talk->STOP).
||CONVERSE_ITCH = (ITCH || CONVERSE).
713© Wolfgang Emmerich, Mark Handley 1998 - 2003
LTS Example
0 1 2 3 4 5
think talk scratch
talk think
scratch
scratch
14© Wolfgang Emmerich, Mark Handley 1998 - 2003
n Parallelism
• Physically simultaneous processing
• Involves multiple processing elements or
independent device operations.
n Interleaved Concurrency
• Logically simultaneous processing
• Does not imply multiple processing elements.
• Interleaved execution on single processing element.
Definitions
815© Wolfgang Emmerich, Mark Handley 1998 - 2003
Interleaved Model of Concurrency
Time
C
B
A
n Executing 3 processes on 1 processor:
16© Wolfgang Emmerich, Mark Handley 1998 - 2003
Parallelism vs Concurrency
n Usually use the terms interchangeably.
n Model systems in terms of interleaved concurrency
• Even if implementations run on different processors.
• Most of the same principles and techniques apply to
both interleaved execution and physical
concurrency.
917© Wolfgang Emmerich, Mark Handley 1998 - 2003
Summary
n Motivation for concurrent programs
n Engineering approach to concurrency
n Finite State Processes
n Labelled Transition Systems
n Parallelism vs. concurrency
n Interleaved model of concurrency
Next Lecture: modelling processes in FSP