<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>PNTM - Integration of Petri Nets and Transactional Memory</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Weiyi Wu</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yao Zhang</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Shengyuan Wang</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yuan Dong</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer Science and Technology , Tsinghua University</institution>
          ,
          <addr-line>Beijing, 100084</addr-line>
          ,
          <country country="CN">China</country>
        </aff>
      </contrib-group>
      <fpage>196</fpage>
      <lpage>199</lpage>
      <abstract>
        <p>PNTM demonstrates a new concurrent programming model, providing explicit concurrency among cooperative transactions with correctness. It integrates a special Petri net and transactional memory, and improves the performance of transactions by decreasing the rate of conflicts. The GUI part of PNTM environment is based on PNK [1], the compiler is a modified GJC [2], and the runtime is based on DSTM2 [3]. Editor The IDE provides a simple GUI with a code editor and a net editor. The editor for Petri net system is modified from PNK. All elements can have extra fields and be edited visually. The extra fields such as resources in places and code in transitions all correspond special variables and functions in the code, as in Table 1.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>After checking the correctness at the level of Petri nets, the editor will append
a piece of code for building Petri Net simulator at runtime. Hence the simulator
is created and initialized at runtime. The runtime provide 5 APIs as below:
W. Wu, Y. Zhang, S. Wang, Y. Dong: Petri Nets and Transactional Memory</p>
    </sec>
    <sec id="sec-2">
      <title>1. AddTransition(transition, code) adds transition.</title>
      <p>2. AddPlace(place, resource) adds place.
3. AddArc(source, target, inscription) adds arc.
4. Start() starts simulation.
5. Join() terminates simulation.</p>
      <p>The runtime is a Petri nets VM using DSTM2. The first 3 API can build
up a simulator of a Petri net and the last 2 API control the simulator. The
simulator allocate a DSTM2 Thread for every transition in the net. The Threads
are all waiting for notification. Only notified Thread can consume resources,
call function and produce new resources. A global lock is used to protect all
resources in order to make manipulation on resources atomic and prevent
deadlock. Some optimizations accelerate the check-and-consume process. Hence the
overhead is relatively low. When the transition consumes resources and is ready
to fire, corresponding petrinet function is called using reflection. If all global
variables protected by STM successfully commit, the transition will produce new
resources. Otherwise the transition will revert all state and return consumed
resources.</p>
      <p>Compilation At the early stage of compilation, the compiler will recognize
and mark new keyword petrinet, resource, global. The global variables
need to transform to instances of pre-defined interfaces in order to meet
requirement of DSTM2’s APIs. For example, equivalent code to transformed
“ global int a;” is shown in Table 2. AInt refers to “ Atomic Integer”.</p>
      <p>After AST is built, the compiler will check the semantic correctness. The
functions with petrinet modifier and Petri nets themselves should meet
constraints below:
1. petrinet function must have function body.
2. petrinet function should have no parameter.
3. Only resource, global and local variables can be used in a petrinet
function.
4. Only petrinet function can be called in transition.
5. Resources in incoming arcs of a transition must be a superset of all resource
variable used in corresponding petrinet function.</p>
      <p>PNSE’11 – Petri Nets and Software Engineering</p>
      <p>In addition, all references of global variables and all left-values consisted
of global variables must be transformed to proper getter and setter in order
to meet requirement of DSTM2’s API. Equivalent code to getter and setter is
shown in Table 3.
transform type original code equivalent code
initializer global int a = 0; ...;a.setValue(0);
reference x = a + 1; x = a.getValue() + 1;
left-value a = x + 1; a.setValue(x + 1);
self-operation a++; a.setValue(a.getValue() + 1);</p>
    </sec>
    <sec id="sec-3">
      <title>The rest of compilation is the same with GJC.</title>
      <p>Future Work</p>
      <p>We are making efforts to some basic performance evaluation.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>1. INA:Integrated Net Analyzer, at http://www.informatik.huberlin.de/lehrstuehle/automaten/ina.</mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>2. GJC available at : http://www.sun.com/software/communitysource/j2se</mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>Maurice</given-names>
            <surname>Herlihy</surname>
          </string-name>
          , Victor Luchangco,
          <string-name>
            <given-names>Mark</given-names>
            <surname>Moir</surname>
          </string-name>
          ,
          <article-title>A Flexible Framework for Implementing Software Transactional Memory</article-title>
          ,
          <source>In Preceedings of OOPSLA'06</source>
          ,
          <string-name>
            <surname>Pages</surname>
          </string-name>
          253-
          <fpage>262</fpage>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>