[kepler-users] Thread Safety in Actors using external libraries

Christopher Brooks cxh at eecs.berkeley.edu
Fri Dec 13 16:29:40 PST 2013


Hi Tom,
If I was limited to a yes or no answer to the question "Will using java 
synchronization in an actor cause other problems with Kepler/Ptolemy 
under PN?", I would have to say "yes", because threads rarely don't 
cause problems :-)

That said, using Java synchronization within the actor should be 
possible.  At the worst, you could stall the execution of the actor.  In 
PN, you would probably probably have the actor some how signal to the 
director that it was not ready to fire, but it could fire in the 
future.  Probably the way to do this is not read inputs or write 
outputs, but I'm not sure...

In Ptolemy II, you might look at the DiningPhilosophers CSP demo. That 
demo is very old, but it might help you.  Unfortunately, those classes 
are not built by Kepler, so you would probably need to download 
PtolemyII separately.  Or, you could try the applet at 
http://ptolemy.eecs.berkeley.edu/ptolemyII/ptIIlatest/ptII8.0.1/ptolemy/domains/csp/doc/index.htm

The code is at 
kepler/ptolemy/src/ptolemy/domains/csp/demo/DiningPhilosophers

We've seen this sort of pattern before where you have a model that has 
asynchronous reads and writes to an external data source.  I believe we 
have some sample demos, but they are not coming to mind.

_Christopher


On 12/11/13 6:10 AM, Tom Parris wrote:
> Dear kepler-users:
>
> We have constructed some Java/JNI actors that make use of GDAL as an 
> external library for i/o.  A recent change in computing platforms 
> exposed some thread-safety issues in GDAL that we are now struggling 
> to address.
>
> *Nature of problem: *
> We have two GDAL-based actors.  One for reading raster imagery (ERDAS 
> IMG files) into a matrix, one for writing raster imagery into a matrix 
> (and, at some point, we would like to contribute these to Kepler). 
> These actors are used heavily in PN workflows.  While GDAL is thread 
> safe for reading (multiple thread can read at the same time), it is 
> not thread safe for writing (problems occur if any thread is writing 
> while other threads are either reading or writing).
>
> *Possible fix:*
> The GDAL discussions suggest using Java synchronization to avoid 
> thread safety issues.
>
> *Questions:*
> 1. Will using java synchronization in an actor cause other problems 
> with Kepler/Ptolemy under PN?
> 2. Does anybody have a model of an actor that uses java 
> synchronization to avoid thread safety issues in external libraries 
> that they would be willing to share?
> 3. Are there other solutions we should consider?
>
> Many thanks,
> Tom Parris
>
>
> Thomas M. Parris
> Vice President
> ISciences, L.L.C.
> 61 Main Street, Suite 200
> Burlington, VT  05401
> (802) 864-2999; parris at isciences.com <mailto:parris at isciences.com>
>
>
>
> _______________________________________________
> Kepler-users mailing list
> Kepler-users at kepler-project.org
> http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users


-- 
Christopher Brooks, PMP                       University of California
Academic Program Manager & Software Engineer  US Mail: 337 Cory Hall
CHESS/iCyPhy/Ptolemy/TerraSwarm               Berkeley, CA 94720-1774
cxh at eecs.berkeley.edu, 707.332.0670           (Office: 545Q Cory)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20131213/f721912f/attachment.html>


More information about the Kepler-users mailing list