Ptolemy Project Vision - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Ptolemy Project Vision

Description:

Objects in C , C#, or Java. Wrappers as service definitions. Concurrency ... Distributed objects wrapped in web services, Soap, CORBA, DCOM, ... Lee, Berkeley 3 ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 24
Provided by: edward101
Category:
Tags: dcom | project | ptolemy | vision

less

Transcript and Presenter's Notes

Title: Ptolemy Project Vision


1
Ptolemy Project Vision
  • Edward A. Lee
  • Robert S. Pepper Distinguished Professor
    andChair of EECS, UC Berkeley

2
Concurrent Composition of Subsystems,In
Mainstream SW Engineering,As of 2007
  • Component technologies
  • Objects in C, C, or Java
  • Wrappers as service definitions
  • Concurrency
  • Threads (shared memory, semaphores, mutexes, )
  • Message Passing (synchronous or not, buffered, )
  • Distributed computing
  • Distributed objects wrapped in web services,
    Soap, CORBA, DCOM,

3
Observations
  • Threads and objects dominate SW engineering.
  • Threads Sequential computation with shared
    memory.
  • Objects Collections of state variables with
    procedures for observing and manipulating that
    state.
  • Even distributed objects create the illusion of
    shared memory through proxies.
  • The components (objects) are (typically) not
    active.
  • Threads weave through objects in unstructured
    ways.
  • This is the source of many software problems.

4
To Examine the Problems With Threads and Objects,
Consider a Simple Example
  • The Observer pattern defines a one-to-many
    dependency between a subject object and any
    number of observer objects so that when the
    subject object changes state, all its observer
    objects are notified and updated automatically.
  • Design Patterns, Eric Gamma, Richard Helm, Ralph
    Johnson, John Vlissides (Addison-Wesley
    Publishing Co., 1995. ISBN 0201633612)

5
Observer Pattern in Java
public void addListener(listener) public
void setValue(newValue) myValue
newValue for (int i 0 i lt
myListeners.length i)
myListenersi.valueChanged(newValue)
Will this work in a multithreaded context?
Thanks to Mark S. Miller for the details of this
example.
6
Observer PatternWith Mutual Exclusion (Mutexes)
public synchronized void addListener(listener)
public synchronized void setValue(newValue)
myValue newValue for (int i 0 i
lt myListeners.length i)
myListenersi.valueChanged(newValue)
Javasoft recommends against this. Whats wrong
with it?
7
Mutexes are Minefields
public synchronized void addListener(listener)
public synchronized void setValue(newValue)
myValue newValue for (int i 0 i
lt myListeners.length i)
myListenersi.valueChanged(newValue)
valueChanged() may attempt to acquire a lock on
some other object and stall. If the holder of
that lock calls addListener(), deadlock!
8
After years of use without problems, a Ptolemy
Project code review found code that was not
thread safe. It was fixed in this way. Three days
later, a user in Germany reported a deadlock that
had not shown up in the test suite.
9
Simple Observer Pattern BecomesNot So Simple
public synchronized void addListener(listener)
public void setValue(newValue)
synchronized(this) myValue newValue
listeners myListeners.clone()
for (int i 0 i lt listeners.length i)
listenersi.valueChanged(newValue)
while holding lock, make copy of listeners to
avoid race conditions
notify each listener outside of synchronized
block to avoid deadlock
This still isnt right. Whats wrong with it?
10
Simple Observer PatternHow to Make It Right?
public synchronized void addListener(listener)
public void setValue(newValue)
synchronized(this) myValue newValue
listeners myListeners.clone()
for (int i 0 i lt listeners.length i)
listenersi.valueChanged(newValue)
Suppose two threads call setValue(). One of them
will set the value last, leaving that value in
the object, but listeners may be notified in the
opposite order. The listeners may be alerted to
the value changes in the wrong order!
11
If the simplest design patterns yield such
problems, what about non-trivial designs?
/ CrossRefList is a list that maintains
pointers to other CrossRefLists. _at_author
Geroncio Galicia, Contributor Edward A.
Lee _at_version Id CrossRefList.java,v 1.78
2004/04/29 145000 eal Exp _at_since Ptolemy II
0.2 _at_Pt.ProposedRating Green (eal) _at_Pt.AcceptedRat
ing Green (bart) / public final class
CrossRefList implements Serializable
protected class CrossRef implements
Serializable // NOTE
It is essential that this method not be
// synchronized, since it is called by
_farContainer(), // which is. Having it
synchronized can lead to // deadlock.
Fortunately, it is an atomic action, //
so it need not be synchronized. private
Object _nearContainer() return
_container private
synchronized Object _farContainer()
if (_far ! null) return _far._nearContainer()
else return null

Code that had been in use for four years, central
to Ptolemy II, with an extensive test suite with
100 code coverage, design reviewed to yellow,
then code reviewed to green in 2000, causes a
deadlock during a demo on April 26, 2004.
12
Our Claim
  • Nontrivial software written with threads,
    semaphores, and mutexes are incomprehensible to
    humans.

13
Perhaps Concurrency is Just Hard
  • Sutter and Larus observe
  • humans are quickly overwhelmed by concurrency
    and find it much more difficult to reason about
    concurrent than sequential code. Even careful
    people miss possible interleavings among even
    simple collections of partially ordered
    operations.
  • H. Sutter and J. Larus. Software and the
    concurrency revolution. ACM Queue, 3(7), 2005.

14
If concurrency were intrinsically hard, we would
not function well in the physical world
It is not concurrency that is hard
15
It is Threads that are Hard!
  • Threads are sequential processes that share
    memory. From the perspective of any thread, the
    entire state of the universe can change between
    any two atomic actions (itself an ill-defined
    concept).
  • Imagine if the physical world did that

16
Succinct Problem Statement
  • Threads are wildly nondeterministic.
  • The programmers job is to prune away the
    nondeterminism by imposing constraints on
    execution order (e.g., mutexes) and limiting
    shared data accesses (e.g., OO design).

17
Do Threads Have a Sound Foundation?
  • If the foundation is bad, then we either tolerate
    brittle designs that are difficult to make work,
    or we have to rebuild from the foundations.

Note that this whole enterprise is held up by
threads
18
Our Solution Actor-Oriented Design
Things happen to objects
Actors make things happen
19
Succinct Solution StatementActor-Oriented
Coordination Languages
  • Each actor is a process, communication is via
    rendezvous, and the Merge explicitly represents
    nondeterministic multi-way rendezvous.

This is realized here in a coordination language
with a visual syntax.
20
A Rich Design Space
  • In this solution, the Observer need not keep up
    with nor block the value producers or consumer.

The Java solution never got this level of design
21
Potential for Timed Semantics
  • In this solution, timing is specified.

Timed models of computation have enormous
potential for embedded systems.
22
Research Directions of the Ptolemy Project
  • Real-time systems
  • Distributed real-time software, PRET machines,
    robust software, wireless sensor networks
  • Concurrent software
  • Understandable, scalable concurrency,
    service-oriented architectures, distributed
    computing
  • Scalable composition of subsystems
  • Integration technologies, higher-order
    components, supervisory models, interface
    formalisms, data models
  • Hybrid systems
  • Integration of SR, DE, and CT

23
Acknowledgements
  • Recent PhD graduates
  • Adam Cataldo (Agilent)
  • Xiaojun Liu (Sun Microsystems)
  • Recent masters graduates
  • Shamik Bandyopadhyay
  • Current sponsors
  • Air Force Research Labs (AFRL)
  • Air Force Office of Scientific Research (AFOSR)
  • Army Research Office (ARO)
  • Agilent
  • California MICRO Program
  • DGIST
  • Hewlett-Packard
  • Microsoft
  • National Instruments
  • National Science Foundation (NSF)
  • Toyota
  • Current students
  • Elaine Cheong
  • Thomas Huining Feng
  • Jackie (Man-Kit) Leung
  • Eleftherios Matsikoudis
  • Yang Zhao (to Oracle)
  • Haiyang Zheng (to MathWorks)
  • Gang Zhou
  • Rachel Zhou (to Marvell)
  • Staff
  • Christopher Brooks
  • Tracey Richards
  • Mary Stewart
Write a Comment
User Comments (0)
About PowerShow.com