<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi Tom,<br>
      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 :-)<br>
      <br>
      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...<br>
      <br>
      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 
<a class="moz-txt-link-freetext" href="http://ptolemy.eecs.berkeley.edu/ptolemyII/ptIIlatest/ptII8.0.1/ptolemy/domains/csp/doc/index.htm">http://ptolemy.eecs.berkeley.edu/ptolemyII/ptIIlatest/ptII8.0.1/ptolemy/domains/csp/doc/index.htm</a><br>
      <br>
      The code is at
      kepler/ptolemy/src/ptolemy/domains/csp/demo/DiningPhilosophers<br>
      <br>
      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.<br>
      <br>
      _Christopher<br>
      <br>
      <br>
      On 12/11/13 6:10 AM, Tom Parris wrote:<br>
    </div>
    <blockquote
cite="mid:CAJiB5bXFmSwYoziGzawnpp++mjVUwe6UX6rF0od8os4T28WvzQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Dear kepler-users:
        <div><br>
        </div>
        <div>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.  </div>
        <div><br>
        </div>
        <div><b>Nature of problem:  </b></div>
        <div>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).</div>
        <div><br>
        </div>
        <div><b>Possible fix:</b>  </div>
        <div>The GDAL discussions suggest using Java synchronization to
          avoid thread safety issues.  </div>
        <div><br>
        </div>
        <div><b>Questions:</b></div>
        <div>1. Will using java synchronization in an actor cause other
          problems with Kepler/Ptolemy under PN?</div>
        <div>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?  </div>
        <div>3. Are there other solutions we should consider?</div>
        <div><br>
        </div>
        <div>Many thanks,</div>
        <div>Tom Parris</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Thomas M. Parris</div>
        <div>Vice President</div>
        <div>ISciences, L.L.C.</div>
        <div>61 Main Street, Suite 200</div>
        <div>Burlington, VT  05401</div>
        <div>(802) 864-2999; <a moz-do-not-send="true"
            href="mailto:parris@isciences.com">parris@isciences.com</a></div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Kepler-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kepler-users@kepler-project.org">Kepler-users@kepler-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users">http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users</a>
</pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Christopher Brooks, PMP                       University of California
Academic Program Manager & Software Engineer  US Mail: 337 Cory Hall
CHESS/iCyPhy/Ptolemy/TerraSwarm               Berkeley, CA 94720-1774
<a class="moz-txt-link-abbreviated" href="mailto:cxh@eecs.berkeley.edu">cxh@eecs.berkeley.edu</a>, 707.332.0670           (Office: 545Q Cory)
</pre>
  </body>
</html>