Concurrency Control Techniques for Multi-Threaded Programs in C++ and Java
Understanding multithreading and its impact on software development
is a demanding task. This lecture discusses the design of object-oriented,
concurrent applications using multiple threads, and the implementation
of such applications in C++ and Java. Naturally, a 3-hours presentation
cannot cover all aspects relevant to multithreading. The talk instead focuses
on one particularly important aspect: concurrency control techniques, among
them mutual exclusion, guarded suspension, and more advanced techniques
such as reader/writer synchronization. In order to implement these patterns
in C++ or Java, one needs to know which concurrency control instruments
are supported in each of the languages. Along with an introduction to the
respective features in C++ and Java, strengths and weaknesses in both languages
are discussed.
Not covered in this talk are thread activities and cooperative interaction
e.g. starting threads, thread completion, termination policies. Also omitted
are differences between thread APIs, as well as thread scheduling and priorities.
These aspects are subject of a full-day seminar.
Access to shared resources.
In multithreaded environments concurrently
running components often share resources. Concurrent access to shared resources
can corrupt the resource or put it into an inconsistent state if access
for modification of the resource through two concurrent threads is interleaved.
For this reason, one of the most urgent problem to be tackled in multithreaded
programming is control of access to shared resources and, in particular,
to shared data. The talk explains which data is shared, explicitly or implicitly,
in C++ and Java, and suggests programming techniques for concurrency control
in both languages. One of the suggested techniques is classification of
access methods using the conflict set method.
Concurrency Control Techniques.
In order to control the access
to shared data, multithreaded environments support concurrency control
instruments like mutex and condition variable. The talk explains how these
instruments can be used and discusses three typical control patterns and
their implementation in object-oriented languages such as C++ and Java:
monitor, guarded suspension, and reader/writer. Tips and tricks are provided
for improving the design of a concurrent program. Performance tuning is
suggested by avoiding useless notifications or unnecessary waiting or polling.
Also, typical pitfalls are mentioned: the notorious nested monitor problem
is explained.
Implementation Aspects.
The third part of the talk is devoted
to implementation aspects such as programming techniques for turning existing
classes into thread-safe classes or designing new classes especially for
use in multithreaded systems. The decomposition into concurrency control
and ground functionality is proposed and a discussion of combining both,
via inheritance or delegation, completes the talk.
|
|
PREREQUISITES
|
|
Level:
|
intermediate |
Duration:
|
1.5-3.0 hours |
Prerequisites:
|
working knowledge of C++ or Java; familiarity
with concurrency control not required |
Presented at:
|
Software
Development
, Washington DC,
September 1997
Object
World
, Frankfurt, October 1997
C++
World
, San Jose CA, November 1997
Object
Expo France
, Paris, November 1997
C++ World / OOP, Munich, February 1998
(presented by Klaus Kreft)
Software Development
,
San Francisco CA, February 1998 |
If you are interested to hear more about this
and related topics you might want to check out the following seminar or
skim through some further reading:
|
|
Seminars
|
Paper
|
|