[kepler-dev] Handling shared-resources
Edward A. Lee
eal at eecs.berkeley.edu
Fri Mar 9 09:02:10 PST 2007
This is a very interesting question.
There are some major potential pitfalls with shared resources
in actor-oriented models, but there are also patterns that work.
The biggest pitfall is unexpected nondeterminism. Patterns
that could work:
- Represent the resource in a token, and pass the token
around. For your example, in order to write to a file,
an actor would need to receive a token at its input
representing that file. Passing the token to multiple
actors at the same time would result in nondeterministic
interleaving of the writes. The token would need to
somehow implement a reference counting mechanism to
keep track of how many references to it are in use,
and close the file only when these drop to zero.
- Use the Rendezvous domain. Rendezvous is all about
simultaneous access to shared resources.
A pool of resources could be offered using the
ResourcePool actor in the Rendezvous domain...
- The Metropolis project (a sister project in Chess) has made
a major effort in this direction. Metropolis has so called
"quantity managers" that would not be hard to emulate in
Ptolemy II and that model resource sharing.
It would be a worthwhile project to provide a systematic way
to do this...
At 09:32 AM 3/7/2007, Norbert Podhorszki wrote:
>Does anyone handle a "resource" in a workflow "shared" among actors?
>I mean like org.kepler.actor.Logger that opens a file once but many
>instances of that actor in the workflow can write into the same file. So
>there is no need to drag channels from many actors to one single Logger
>actor. The file is then (supposed to be) closed at the end of the workflow
>Or, the org.kepler.actor.ssh.* actors that share an established ssh
>session to perform remote operations. The session should be closed at the
>very end of the execution.
>I have learnt from the recent thread "Wrapup sequence question" that I was
>wrong about that actors can be aware of the finalization stage of the
>model/workflow, I have put the finalization of shared resources into the
>wrapup() method. However, under PN, individual actors can wrap-up
>surprisingly early, even before another actors start working.
>My question is to those who handle shared resources: When and how do you
>I am not sure that actor-oriented modelling allows shared resources at
>all, or they are just examples of violating it.
> Norbert Podhorszki
> University of California, Davis
> Department of Computer Science
> 1 Shields Ave, 2236 Kemper Hall
> Davis, CA 95616
> (530) 752-5076
> pnorbert at cs.ucdavis.edu
>Kepler-dev mailing list
>Kepler-dev at ecoinformatics.org
Edward A. Lee
Chair of EECS and Robert S. Pepper Distinguished Professor
231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
phone: 510-642-0253, fax: 510-642-2845
eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal
More information about the Kepler-dev