<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:space="preserve" xmlns="http://www.tei-c.org/ns/1.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.tei-c.org/ns/1.0 https://raw.githubusercontent.com/kermitt2/grobid/master/grobid-home/schemas/xsd/Grobid.xsd"
 xmlns:xlink="http://www.w3.org/1999/xlink">
	<teiHeader xml:lang="en">
		<fileDesc>
			<titleStmt>
				<title level="a" type="main">Transitions as Transactions ⋆</title>
			</titleStmt>
			<publicationStmt>
				<publisher/>
				<availability status="unknown"><licence/></availability>
			</publicationStmt>
			<sourceDesc>
				<biblStruct>
					<analytic>
						<author>
							<persName><forename type="first">Shengyuan</forename><surname>Wang</surname></persName>
							<affiliation key="aff0">
								<orgName type="department">Department of Computer Science</orgName>
								<orgName type="institution">Technology Tsinghua University</orgName>
								<address>
									<postCode>100084</postCode>
									<settlement>Beijing</settlement>
									<country key="CN">China</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Weiyi</forename><surname>Wu</surname></persName>
							<affiliation key="aff0">
								<orgName type="department">Department of Computer Science</orgName>
								<orgName type="institution">Technology Tsinghua University</orgName>
								<address>
									<postCode>100084</postCode>
									<settlement>Beijing</settlement>
									<country key="CN">China</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Yao</forename><surname>Zhang</surname></persName>
							<affiliation key="aff0">
								<orgName type="department">Department of Computer Science</orgName>
								<orgName type="institution">Technology Tsinghua University</orgName>
								<address>
									<postCode>100084</postCode>
									<settlement>Beijing</settlement>
									<country key="CN">China</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Yuan</forename><surname>Dong</surname></persName>
							<affiliation key="aff0">
								<orgName type="department">Department of Computer Science</orgName>
								<orgName type="institution">Technology Tsinghua University</orgName>
								<address>
									<postCode>100084</postCode>
									<settlement>Beijing</settlement>
									<country key="CN">China</country>
								</address>
							</affiliation>
						</author>
						<title level="a" type="main">Transitions as Transactions ⋆</title>
					</analytic>
					<monogr>
						<imprint>
							<date/>
						</imprint>
					</monogr>
					<idno type="MD5">6B875022D6CBD80F8ED08F27D839A813</idno>
				</biblStruct>
			</sourceDesc>
		</fileDesc>
		<encodingDesc>
			<appInfo>
				<application version="0.7.2" ident="GROBID" when="2023-03-24T00:45+0000">
					<desc>GROBID - A machine learning software for extracting information from scholarly documents</desc>
					<ref target="https://github.com/kermitt2/grobid"/>
				</application>
			</appInfo>
		</encodingDesc>
		<profileDesc>
			<textClass>
				<keywords>
					<term>Concurrent Programming</term>
					<term>Transactional Memory</term>
					<term>Petri Nets</term>
				</keywords>
			</textClass>
			<abstract>
<div xmlns="http://www.tei-c.org/ns/1.0"><p>As newly developed transactional memory technology has received significant attention as a way to dramatically simplify sharedmemory concurrent programming, user-level transactional concurrent programming models have become a very interesting topic in the programming community. However, the fact is that, in existing transactional concurrent programming models, user-level mechanisms have not been well developed. The dilemma is how to make a balance between the performance and correctness of a program. Explicit concurrency among cooperative transactions can undoubtedly decrease the rate of conflicts and improve the performance, but it is harmful to the correctness. In this paper, a transactional concurrent programming approach, based on Petri nets, is presented, which can easily specify concurrency among transactions and do not aggravate programmers remarkably in writing correct transactional concurrent programs. In this approach, a special Petri net system with transition markings is developed. Although such a Petri net system is not defined conventionally, it is shown that its behavior can be simulated through a conventional net, so existing analysis and verification approaches for usual Petri nets can be applied indirectly.</p></div>
			</abstract>
		</profileDesc>
	</teiHeader>
	<text xml:lang="en">
		<body>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">Introduction</head><p>Transactional memory mechanism has recently received significant attention as a way to dramatically simplify memory-sharing concurrent programming, in which mutual exclusion and synchronization can be constructed without using any locks <ref type="bibr" target="#b0">[1]</ref>. For convenience,a concurrent programming model based on transactional memory mechanism is called a transactional concurrent programming model in this paper.</p><p>In existing user-level transactional concurrent programming models, there are two major solutions. One of them is to use directly some API's for transactional memory mechanism, which may be implemented by hardware, software or hybrid. For example, programmers can write transactional concurrent programs in Java together with the library DSTM2 <ref type="bibr" target="#b1">[2]</ref>, or in C together with the library TL2-x86 <ref type="bibr" target="#b2">[3]</ref>. The advantage of this solution is that one can use existing common languages without changing their compilers, but programmers have to use non-structural library functions carefully.</p><p>Another solution is to extend conventional programming languages with some transactional features, such as atomic statement-blocks, as in some new languages Fortress <ref type="bibr" target="#b3">[4]</ref>, X10 <ref type="bibr" target="#b4">[5]</ref>, Chapel <ref type="bibr" target="#b5">[6]</ref>, etc. In this solution, it is easier for programmers to write correct transactional concurrent programs, however, an appropriate compiler must be provided.</p><p>To develop a user-level transactional concurrent programming mechanisms, one dilemma is how to make a balance between the performance and correctness of a program. On the one hand, to write an efficient program in the transactional programming paradigm, it still needs programmers' wisdom to build the explicit parallelism among cooperative transactions, in order to decrease the rate of conflicts. On the other hand, however, explicit parallelism is harmful to the correctness of a program, while one of the initial intents of the transactional memory mechanism is to alleviate the burden for a programmer to write concurrent programs.</p><p>There have been some contributions in the literature to introduce transactions into existing concurrent programming model. For example, a CCR-based transactional concurrent programming model was proposed by T. Harris and K. Fraser <ref type="bibr" target="#b6">[7]</ref>, and Baek et al extend the API's of OpenMP <ref type="bibr" target="#b7">[8]</ref> to OpenTM <ref type="bibr" target="#b8">[9]</ref>. Unfortunately, these approaches still have the usual drawbacks of concurrent programs, that is, not easy to write and not easy to verify.</p><p>As well known, Petri nets <ref type="bibr" target="#b9">[10]</ref> are useful tools in the specification and verification of concurrent applications. With true concurrency dynamical semantics, a Petri net system has a good opportunity to become a realistic part of a concurrent program for multi-core or multi-thread architecture. In this paper, we present informally a transactional concurrent programming mechanism based on a Petri net, in order to specify concurrency among transactions explicitly while not to aggravate programmers remarkably in writing correct concurrent programs.</p><p>Fig. <ref type="figure">1</ref> shows a simple example described in a typical transactional concurrent program structure, where an atomic statement-block declares a transactional region, and fork 1, fork 2, fork 3 and cake_c are shared objects among cooperative transactions.</p><p>In the Petri net system shown in Fig. <ref type="figure" target="#fig_0">2</ref>, to be explained in more details, each of the transitions declares a transactional region, and fork 1, fork 2, fork 3 and cake_c are shared objects among three cooperative transactions. Since the accesses of fork 1, fork 2 , and fork 3 will never conflict, the rate of access conflicts among transactions is decreased, compared to the program in Fig. <ref type="figure">1</ref>.</p><p>Extremely, we can protect all shared objects by the Petri net system, corresponding to the so-called conservative concurrency control. However, if the number of shared objects increases dramatically, the net system may get too big in size. Fortunately, we can leave some shared objects to be protected by the int fork1 = 0, fork2 = 0, fork3 = 0; int cake_c = transactional memory mechanism, if the probability of access conflicts for those shared objects is not that big. For example, we have not made the accesses to cake_c protected by the net system in Fig. <ref type="figure" target="#fig_0">2</ref>.</p><p>We call a shared object to be critical or non-critical according to its probability of access conflicts. So in the transactional concurrent programming approach suggested in this paper, programmers are encouraged to implement the protection of critical shared objects through Petri net systems, and to leave the non-critical shared objects to be protected automatically by the transactional memory system. In the example shown in Fig. <ref type="figure">1</ref> and Fig. <ref type="figure" target="#fig_0">2</ref>, the shared object cake_c is less frequently accessed than fork i's, hence, it is assumed that fork i's be critical shared objects among phi's, and cake_c be the non-critical shared object among them.</p><p>The Petri net model we use is a special colored Petri net model <ref type="bibr" target="#b10">[11]</ref>, called resource nets, which guarantee the access consistency for shared objects. The semantics for a transactional memory mechanism is inspired by the implementation of DSTM2 <ref type="bibr" target="#b1">[2]</ref>.</p><p>The rest of the paper is organized as follows. In Section 2, we make some informal interpretation to the Petri net model, resource nets. Further in Section 3, the behavior simulation of a resource net system is discussed. Then in Section 4, the program model is briefly presented. Section 5 shows a sample user-level transactional concurrent programming tool, where the concept resource nets is applied. Finally, Section 6 gives some remarks and the future work.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">The Net Model</head><p>As stated above, a transactional concurrent program can access two classes of shared objects, critical or non-critical ones. We use resource variables to access critical shared objects, and global variables to access non-critical shared objects. In the following, the set of resource variables is denoted by V R , and the set of global variables is denoted by V T .</p><p>A resource net system is a special colored Petri net system N = (P, T, A, W, m 0 , M F ), where ¡1:   </p><formula xml:id="formula_0">••••• •••••• fork1 fork2 fork3 •••••• cake_c : 12</formula><formula xml:id="formula_1">-A = (P × T) ∪ (T × P) is the set of arcs. -W : A → {S | S ⊆ V R } is the inscription function. -m 0 ∈ Marking is the initial marking, where Marking = {m | m : (P ∪ T) → {S | S ⊆ V R }}. -M F ⊆ Marking is the set of final markings.</formula><p>A resource net system N = (P, T, A, W, m 0 , M F ) has the following features:</p><formula xml:id="formula_2">-For each transition (τ k , I k ) ∈ T, a command sequence I k is attached. When a transition (τ k , I k</formula><p>) is fired, it starts a transaction for the command sequence I k . A command in I k can access shared variables in V R ∪V T , and the variables local to τ k . -A transition can hold a token while its transaction is executing, and the token does not return to the net system until the computation is committed or aborted. So we extend the definition of marking with transition markings.</p><p>-It is possible that M F is empty, which is the usual case in conventional Petri net systems..</p><p>It is worth to noting that variables in V R should be disjoined in locations with each other, which are usually implemented by the compiler.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1">An Example</head><p>Example 1 Fig. <ref type="figure" target="#fig_0">2</ref> shows a transactional concurrent program with V R = { fork 1, fork 2,fork 3} and V T = { cake_c }. The resource net system N = (P, T, A, W, m 0 , M F ), where</p><formula xml:id="formula_3">-P = {f k1, f k2, f k3}. -T = {tr1, tr2, tr3}</formula><p>, where tr1 = (ph1, I 1 ), tr2 = (ph2, I 2 ), and tr3 = (ph3, I 3 ), where I 1 , I 2 and I 3 are command sequences attached to transitions ph1, ph2, and ph3 respectively, as is illustrated in Fig. <ref type="figure" target="#fig_0">2</ref>.</p><formula xml:id="formula_4">-A = {(tr1,f k1), (tr1,f k2), (tr2,f k2), (tr2,f k3), (tr3,f k3), (tr3,f k1), (f k1,tr1), (f k1, tr3), (f k2, tr2), (f k2, tr1), (f k3, tr3), (f k3, tr2)}.</formula><p>-W is defined by:</p><formula xml:id="formula_5">W (f k1, tr1) = W (tr1, f k1) = W (f k1, tr3) = W (tr3, f k1) = {fork1}, W (f k2, tr2) = W (tr2, f k2) = W (f k2, tr1) = W (tr1, f k2) = {fork2}, W (f k3, tr2) = W (tr2, f k3) = W (f k3, tr3) = W (tr3, f k3) = {fork3}. -m 0 ∈ Marking is defined by: m 0 (f k1) = {fork1}, m 0 (f k2) = {fork2}, m 0 (f k3) = {fork3}, and m 0 (τ ) = ∅ for τ = tr1, tr2, tr3. -M F = ∅.</formula></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">Well-Formed Resource Net Systems</head><p>A resource net system N = (P, T, A, W, m 0 , M F ) is well-formed, if</p><formula xml:id="formula_6">-P ∩ T = ∅. -∀ρ ∈ P.∀v 1 , v 2 ∈ m 0 (ρ).(v 1 = v 2 )</formula><p>, that is, at the initial marking, all tokens owned by a place are corresponding to different resource variables.</p><formula xml:id="formula_7">-∀ρ 1 , ρ 2 ∈ P.∀v 1 ∀v 2 .(ρ 1 = ρ 2 ∧ v 1 ∈ m 0 (ρ 1 ) ∧ v 2 ∈ m 0 (ρ 2 ) → v 1 = v 2 ), that is,</formula><p>at the initial marking, tokens owned by different places have disjoint resource variables.</p><p>-∀τ ∈ T.(m 0 (τ ) = ∅), that is, at the initial marking, every transition contains no tokens. -∀m ∈ M F .∀τ ∈ T.(m(τ ) = ∅), that is, at each of final markings, every transition will not contain any tokens.</p><formula xml:id="formula_8">-∀τ ∈ T.∀ρ 1 , ρ 2 ∈ •τ.∀v 1 ∀v 2 .(ρ 1 = ρ 2 ∧ v 1 ∈ W (τ, ρ 1 ) ∧ v 2 ∈ W (τ, ρ 2 ) → v 1 = v 2 )</formula><p>, that is, all sets of resource variables on the incoming arcs of the same transition are disjoined with each other.</p><p>-</p><formula xml:id="formula_9">∀τ ∈ T.∀ρ 1 , ρ 2 ∈ τ • .∀v 1 ∀v 2 .(ρ 1 = ρ 2 ∧ v 1 ∈ W (ρ 1 , τ ) ∧ v 2 ∈ W (ρ 2 , τ ) → v 1 = v 2 )</formula><p>, that is, all sets of memory blocks on the outgoing arcs of the same transition are disjoined with each other.</p><formula xml:id="formula_10">-∀τ ∈ T.∀ρ ∈ τ • .(W (τ, ρ) ⊆ ρ ′ ∈•τ (W ((ρ ′ , τ )))</formula><p>, that is, no extra shared objects be produced within a transaction associated to each of transitions.</p><p>For simplification,in this paper, we don't consider the dynamic memory allocation for a shared object within a transaction.</p><p>In the above,the pre-set and post-set of a transition τ ∈ T or a place ρ ∈ P are used, which are defined as usual:</p><formula xml:id="formula_11">•τ = {ρ | (ρ, τ ) ∈ A}, τ • = {ρ | (τ, ρ) ∈ A}, •ρ = {τ | (τ, ρ) ∈ A}, and ρ• = {τ | (ρ, τ ) ∈ A}.</formula><p>Example 2 It is easy to show that the resource net system in Example 1 is well-formed.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.3">Execution Semantics</head><p>To show the execution semantics of a resource net system, we define TranState = {blocked, active, aborted, committed }, consisting of 4 transaction states of a transition. At the initial marking, every transition has the state blocked.</p><p>Entering a Transition Whenever a transition τ in the resource net system is in state blocked, and the firing condition for τ is satisfied under the current marking m, that is, ∀ρ ∈ •τ.(m(ρ) ⊇ W (ρ, τ )), and in the same time, the current marking is not a final state, that is, m / ∈ MF , the system can enter the transition such that a transaction is started and the transition gets to hold tokens. When it occurs, the state of the τ will be active.</p><p>Execution of a Command Sequence Whenever a transition τ in the resource net system is in state active, and the next command in its remained command sequence is c, the transition can make a progress by executing the command c. We need several separate rules respectively for several cases:</p><p>(1) If c reads or writes to a global variable which has been written most recently by some other transition but τ , a read/write confliction occurs, and τ will be in the state aborted.</p><p>(2) If the execution of c has no read/write confliction and c has no write operation to any global variables, the transition will keep in state active.</p><p>(3) If the execution of c has no read/write confliction and c has a write operation to some global variable x, the transition will keep in state active, while the system will record τ to be the transition that most recently written to x.</p><p>Ready to Commit a Transaction Whenever a transition τ in the resource net system is in state active, and there is no next command in its remained command sequence, the system can make a progress to change the state of τ from active to committed, meaning that the transaction associated to τ is ready to commit.</p><p>Committing a Transaction Whenever a transition τ in the resource net system is in state committed, the system can make a progress to commit the transaction associated to τ , changing the state of τ from committed to blocked.</p><p>Aborting a Transaction Whenever a transition τ in the resource net system is in state aborted, the system can make a progress to return tokens to places in the pre-set of τ , changing the state of τ from aborted to blocked.</p><p>Let N = (P, T, A, W, m0, MF ) be a well-formed resource net system, it is easy to show that for any reachable marking m from the initial marking m0, the following two properties are satisfied -∀x ∈ P ∪ T.∀v1, v2 ∈ m(x).(v1 = v2),that is, at the marking m, all tokens owned by a place or a transition are corresponding to different resource variables.</p><formula xml:id="formula_12">-∀x1, x2 ∈ P ∪ T.∀v1∀v2.(x1 = x2 ∧ v1 ∈ m(x1) ∧ v2 ∈ m(x2) → v1 = v2), that is,</formula><p>at the marking m, all tokens owned by different places or transitions have disjoint resource variables.</p><p>Example 3 Since the resource net system N = (P, T, A, W, m0, MF ) in Example 1 is well-formed. So the above two properties will keep in a well-formed program state during its execution.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">Behavior Simulation of a Resource Net System</head><p>In this section, it will be shown that a well-formed resource net system N can be reduced to an usual colored Petri net system desugar(N ) so that the behavior of N can be simulated by desugar(N ), which can be analyzed and verified by using existing approaches in the Petri net community. The transformation from N to desugar(N ) is called desugaring. Before and after desugaring, the change of net structure can be illustrated by Fig. <ref type="figure">3</ref>. </p><formula xml:id="formula_13">-P ′ = {f k1, f k2, f k3, ρ ph1 , ρ ph2 , ρ ph3 }.</formula><p>-T ′ = {ph1enter, ph2enter, ph3enter, ..., ph3commit} -A ′ = {(ph1enter, ρ ph1 ), (ph2enter, ρ ph2 ), (ph3enter, ρ ph3 ), ..., (f k1, ph1enter), (f k1, ph3enter), ..., (ph1 rollback , f k1), (ph3 rollback , f k1), ..., (ph1commit, f k1), (ph3commit, f k1), ..., ..., (ph3commit, f k3)}. -The definition of W ′ is illustrated in Table <ref type="table">1</ref> </p><formula xml:id="formula_14">(partly). -m ′ 0 is defined by m ′ 0 (ρ ph1 ) = m ′ 0 (ρ ph2 ) = m ′ 0 (ρ ph3 ) = ∅, m ′ 0 (f k1) = {{fork1}}, m ′ 0 (f k2) = {{fork2}}, and m ′ 0 (f k3) = {{fork3}}. -M ′ F = ∅.</formula><p>It is not difficult to establish a behavior simulation relation between N and desugar(N ), and show that many behavior properties, including deadlock-freeness, for N can be verified indirectly by verifying those for desugar(N ). For example, it is easy to verify that the usual Petri net system desugar(N ) in Example 4 is deadlock-free, so we can conclude that the resource net system N is also deadlock-free.</p><p>It is worth to noting that the execution semantics can guarantee behaviour consistence between N and desugar(N ). For every transition τ in N and ρτ in desugar(N ) as illustrated in Fig. <ref type="figure">3</ref>, we have -If τ is in state blocked, there no token in ρτ , and τenter is enabled. If τenter fires, τ will be in state active at the same time.</p><p>-If τ is in state active, nether τcommit or τ rollback will fire though there exist tokens in ρτ .</p><formula xml:id="formula_15">-If τ is in state committed, τcommit is enabled. -If τ is in state aborted, τ rollback is enabled.</formula><p>τ is in state active, committed, or aborted, iff there no token in ρτ .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Table 1. W</head><formula xml:id="formula_16">′ : A ′ → {L | L ⊆ 2 Label } if a = then W ′ (a) = (ph1enter, ρ ph1 ) {{fork1}, {fork2}} (ph2enter, ρ ph2 ) {{fork2}, {fork3}} (ph3enter, ρ ph3 ) {{fork3}, {fork1}} ... ... (f k1, ph1enter) {{fork1}} (f k1, ph3enter) {{fork1}} ... ... (ph1 rollback , f k1) {{fork1}} (ph3 rollback , f k1) {{fork1}} ... ... (ph1commit, f k1) {{fork1}} (ph3commit, f k1) {{fork1}} ... ... (ph3commit, f k3) {{fork3}}</formula><p>For the sake of limited space, in this paper, we have not formally defined the desugaring and the behavior simulation relation.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">The Program Model</head><p>In the transactional concurrent programming approach of this paper, a program consists of a set of Petri net systems, which are protected parts in the system, and a set of unprotected threads which contains an initial thread identified root and other unprotected threads. Resource variables can only be accessed within protected parts. At the beginning, the thread root is initialized to execute at the level which we call top level.</p><p>A set of Petri net systems can spawn outside a Petri net system, initialized with new allocated resource variables or their references. When a transition in a Petri net system is fired, it becomes a (transactional) transition thread, which will eventually commit, or rollback due to conflicts to access the shared memory.</p><p>An unprotected thread except for the thread root can be spawned outside a Petri net system.</p><p>The program ends if all the Petri net systems achieve one of their final states, and in the same time all the unprotected threads execute to the end.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">A sample user-level transactional concurrent programming tool</head><p>A sample user-level transactional concurrent programming tool has been developing in our lab, based on available software sources, DSTM2 <ref type="bibr" target="#b1">[2]</ref>, PNK <ref type="bibr" target="#b12">[13]</ref> and GJC <ref type="bibr" target="#b13">[14]</ref>. In the programming model of this sample programming tool, a program consists of a set of Petri net systems, corresponding to resource net systems in this paper, and other part written in Java Language.</p><p>A simple visual IDE for this programming model has been developing.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Fig. 5. A basic editing view</head><p>Editors In the IDE, each of the elements of a program can be visually edited. Fig. <ref type="figure">5</ref> shows a basic editing view. A editor for a Petri net system is similar to that provided in PNK source, but some modifications to add code editing area, to make the code editing to be the main input area, and to integrate with associate compilation operations.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Fig. 6. A visual Petri net system</head><p>A visually edited Petri net system will be automatically translated to some code to be fed to the compiler. It actually completes a class inherited from a class PetriNet for the programmer, where PetriNet is the class encapsulated for a special Petri net virtual machine. For example, for the Petri net system in Fig. <ref type="figure">6</ref>, the result class will be the one in Fig. <ref type="figure">7</ref>.</p><p>package base_directory.pnml.compile; public class PNTest extends PetriNet{ public PNTest(Object objectSource) { super(objectSource); this.AddTransition("t1","code", "f1"); this.AddTransition("t2","code", "f2"); this.AddTransition("t3","code", "f3"); this.AddPlace("p1", "a,b", "marking"); this.AddPlace("p2", "", "marking"); this.AddArc("p1", "t1", "a", "inscription"); this.AddArc("t1", "p2", "a", "inscription"); this.AddArc("p1", "t2", "b", "inscription"); this.AddArc("t2", "p2", "b", "inscription"); this.AddArc("p2", "t3", "a,b", "inscription"); } } Fig. <ref type="figure">7</ref>. Class for a Petri net system Associate Compilation The associate compilation makes the static check of a Petri net system, then associates its code with all other parts of opened codes and compiles them together with each other. At the early time of the compilation, the Petri net system is translated into its internal form as the Petri net virtual machine instructions, which then is added to its specific class.</p><p>Variables corresponding to transaction memory blocks and resource memory blocks are declared with the modifiers global and resource respectively. Besides, the code for each transition of a Petri net system is defined by a specific member function with the modifier petrinet. In the associate compilation, the lexical, syntactical, and semantical analysis associate to the modifiers global, resource and petrinet has been processed carefully.</p><p>The compiler has been implemented based on GJC <ref type="bibr" target="#b13">[14]</ref>, a open Java compiler released by Sun, and kept the original logic of GJC unchanged.</p><p>The statical semantic check for a Petri net system is corresponding to the definition of a well-formed resource net system in Section 2.2.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>STM Integration</head><p>The transactional memory support is based on DSTM2 <ref type="bibr" target="#b1">[2]</ref>, with each piece of transition code automatically trisected by invoking provided STM APIs. Hence the variable with modifier Global can be protected by the transactional memory system.</p><p>In order to integrate DSTM2's API, we need to make some modification to GJC. We need to change the type of every variable with modifier Global to a wrapper class with a factory. Also we need to change every reference of those variables and every left-value consisted of those variables to corresponding DSTM2's APIs.  where AddTransition, AddPlace, and AddArc are used to construct a Petri net system, and Start and Join used for scheduling the execution of a Petri net system.</p><p>Fig. <ref type="figure">9</ref> shows an example to start the Petri net system defined in Fig. <ref type="figure">6</ref> or Fig. <ref type="figure">7</ref>. One possible execution result will be "a=1 a=1 b=3", and another possible result is "a=0 a=1 b=3", as is illustrated in Fig. <ref type="figure">10</ref>. Fig. <ref type="figure">11</ref> and Fig. <ref type="figure" target="#fig_0">12</ref> illustrate the integration of a simple Petri net transition simulator and DSTM routine. The left routine in Fig. <ref type="figure">11</ref> simulate a Petri net transition to do something, and the right part is the DSTM routine to do the same task. Fig. <ref type="figure" target="#fig_0">12</ref> integrates the functions of two routines in Fig. <ref type="figure">11</ref>, getting a so-called PNTM routine.</p><p>The Petri net virtual machine can be implemented on any architecture you like, especially, it will be helpful if the target architecture can efficiently support concurrent programming, such as a CMP system. Until now, we have just implemented the Petri net virtual machine based on JVM.</p><p>The latest stable version of source code, in which the invoking of STM API's in DSTM2 has not been packaged, can be downloaded at the URL: http://soft.cs.tsinghua.edu.cn/~wang/projects/NSFC90818019/software/pntm.rar</p><p>We are making a research plan to extend the virtual machine and its implementation based on some reconfigurable simulator for multi-core architectures such that some basic performance analysis could be made.  The paper presents an approach to integrate a Petri net system with a transitional memory mechanism, which has currently been applied to the implementation of a userlevel transactional concurrent programming tool in our lab. There is few formalism to play such a role as we have known so far. There exist researches based on Petri nets to model atomic or transactional threads, however the net system is not a part of the program. For example, an approach to check causal atomicity is proposed by modeling programs using Petri Nets <ref type="bibr" target="#b11">[12]</ref>. At some extent, concurrent programming models based on Petri nets, such as OPN <ref type="bibr" target="#b14">[15]</ref>, CLOWN <ref type="bibr" target="#b15">[16]</ref>, COO <ref type="bibr" target="#b16">[17]</ref>, CO-OPN/2 <ref type="bibr" target="#b17">[18]</ref>, and Elementary Object Nets <ref type="bibr" target="#b18">[19]</ref> may be extended to support various transaction semantics with the conservative concurrency control.</p><p>We observed that the integration of Petri nets with transactional memory can bring benefits to both side, which is the motivation of the paper. On the one hand, with whose access policy is driven by a transactional memory model, with possible conflicts, resolved by a commit-rollback protocol.</p><p>That is, our approach advocates the methodology that critical objects shared among concurrent transactions will be protected through a resource net system, while noncritical shared objects be left protected automatically by the transactional memory system. Thus the net system can be designed flexibly to keep a moderate size and in a finer granularity than usual net system.</p><p>It is shown that the behavior of a well-formed resource net system can be simulated by its desugar net system, which can be analyzed and verified by using existing approaches in the Petri net community. Behavior properties for a well-formed resource net system, such as deadlock-freeness, can be verified indirectly by verifying those for its desugaring net system. For example, INA tool <ref type="bibr" target="#b19">[20]</ref> can be directly integrated into our programming tool being developed, as has been done in PNK.</p><p>A practical user-level transactional concurrent programming tool, based on DSTM2 <ref type="bibr" target="#b1">[2]</ref>, PNK <ref type="bibr" target="#b12">[13]</ref> and GJC <ref type="bibr" target="#b13">[14]</ref>, has been developing in our lab. The version so far is not suitable to make a performance analysis because the target virtual machine on which a program with Petri net structures runs is implemented simply based on JVM. We are making a plan to extend the virtual machine and its implementation such that some basic performance analysis could be made.</p><p>Certainly, the approach could be extended to other formalisms as well. Furthermore, how to decide critical or non-critical shared objects, we believe, would become an interesting area in software design methodology.</p></div><figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_0"><head>Fig. 2 .</head><label>2</label><figDesc>Fig. 2. A resource net system for Dining Philosophers</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_1"><head>Fig. 3 . 4 Fig. 4 .</head><label>344</label><figDesc>Fig. 3. Net structure before and after desugaring</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_2"><head>Fig</head><label></label><figDesc>Fig.8illustrates how to transact a global variable in our implementation. Currently we only support basic types or simple "copyable" types.</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_3"><head>Fig. 9 .Fig. 10 .</head><label>910</label><figDesc>Fig. 9. Example for starting a Petri net system</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" type="table" xml:id="tab_3"><head></head><label></label><figDesc>.8 illustrates how to transact a global variable in our implementation. Currently we only support basic types or simple "copyable" types.Petri Net Virtual Machine As stated above, a Petri net system is finally translated to some class inherited from a class PetriNet, which encapsulates interfaces for a special Petri net virtual machine. The Petri net virtual machine is now simply designed with the following instructions:</figDesc><table><row><cell></cell><cell>@atomic interface _T {</cell></row><row><cell></cell><cell>T getValue ();</cell></row><row><cell></cell><cell>void setValue (T value);</cell></row><row><cell></cell><cell>}</cell></row><row><cell></cell><cell>Factory&lt;_T&gt; factory_T =</cell></row><row><cell></cell><cell>Thread.makeFactory(_T.class);</cell></row><row><cell>global T a;</cell><cell>_T _a = factory_T.create();</cell></row><row><cell>a = x;</cell><cell>_a.setValue(x);</cell></row><row><cell>x = a;</cell><cell>x = _a.getValue();</cell></row><row><cell cols="2">Fig. 8. Transactional global variables</cell></row><row><cell>-AddTransition (name,code)</cell><cell></cell></row><row><cell>-AddPlace (name,resource)</cell><cell></cell></row><row><cell cols="2">-AddArc (Source, Target, Inscription) -Start ()</cell></row><row><cell>-Join ()</cell><cell></cell></row></table></figure>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_0">PNSE'11 -Petri Nets and Software Engineering</note>
		</body>
		<back>

			<div type="funding">
<div xmlns="http://www.tei-c.org/ns/1.0"><p>⋆ Supported by the National Natural Science Foundation of China under grant No.</p></div>
			</div>

			<div type="annex">
<div xmlns="http://www.tei-c.org/ns/1.0"><p>transactional memory, a finer granularity of concurrency can be achieved in a Petri net system, and the scale of the net model can be controlled flexibly. On the other hand, with a Petri net system, the concurrency among cooperative transactions can be built explicitly, which can undoubtedly decrease the rate of conflicts and improve the performance, while the analysis and verification capability of a Petri net model can be inherited.</p><p>The main idea in a resource net system, the net system presented in the paper, is to classify shared resources in two classes: (1) resources such that the access policy is driven by the net structure, so that mutual exclusion is guaranteed; (2) resources</p></div>			</div>
			<div type="references">

				<listBibl>

<biblStruct xml:id="b0">
	<analytic>
		<title level="a" type="main">Transactional Memory: An Overview</title>
		<author>
			<persName><forename type="first">Tim</forename><surname>Harris</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">IEEE Micro</title>
		<imprint>
			<biblScope unit="volume">27</biblScope>
			<biblScope unit="issue">3</biblScope>
			<biblScope unit="page" from="8" to="29" />
			<date type="published" when="2007">2007</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b1">
	<analytic>
		<title level="a" type="main">A Flexible Framework for Implementing Software Transactional Memory</title>
		<author>
			<persName><forename type="first">Maurice</forename><surname>Herlihy</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Victor</forename><surname>Luchangco</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Mark</forename><surname>Moir</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Preceedings of OOPSLA&apos;06</title>
				<imprint>
			<date type="published" when="2006">2006</date>
			<biblScope unit="page" from="253" to="262" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b2">
	<monogr>
		<ptr target="http://stamp.stanford.edu/" />
		<title level="m">Stanford Transactional Applications for Multi-Processing</title>
				<imprint/>
	</monogr>
	<note>TL2-x86</note>
</biblStruct>

<biblStruct xml:id="b3">
	<monogr>
		<title level="m" type="main">The Fortress Language Specification</title>
		<author>
			<persName><forename type="first">E</forename><surname>Allen</surname></persName>
		</author>
		<imprint>
			<date type="published" when="2005">2005</date>
			<publisher>Sun Microsystems</publisher>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b4">
	<analytic>
		<title level="a" type="main">X10: An Object-Oriented Approach to Non-Uniform Cluster Computing</title>
		<author>
			<persName><forename type="first">P</forename><surname>Charles</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Proc. 20th Ann. ACM SIGPLAN Conf Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA05)</title>
				<meeting>20th Ann. ACM SIGPLAN Conf Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA05)</meeting>
		<imprint>
			<publisher>ACM Press</publisher>
			<date type="published" when="2005">2005</date>
			<biblScope unit="page" from="519" to="538" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b5">
	<monogr>
		<ptr target="http://chapel.cs.washington.edu/Specification.pdf" />
		<title level="m">Chapel Specification 0</title>
				<imprint>
			<publisher>Cray Inc</publisher>
			<date type="published" when="2005">2005</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b6">
	<analytic>
		<title level="a" type="main">Language Support for Lightweight Transactions</title>
		<author>
			<persName><forename type="first">Tim</forename><surname>Harris</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Keir</forename><surname>Fraser</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">OOP-SLA&apos;03</title>
				<imprint>
			<date type="published" when="2003">October 26-30, 2003</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b7">
	<monogr>
		<title level="m" type="main">The OpenMP API specification for parallel programming</title>
		<ptr target="http://openmp.org" />
		<imprint/>
	</monogr>
</biblStruct>

<biblStruct xml:id="b8">
	<analytic>
		<title level="a" type="main">The OpenTM Transactional Application Programming Interface</title>
		<author>
			<persName><forename type="first">W</forename><surname>Baek</surname></persName>
		</author>
		<author>
			<persName><forename type="first">C</forename><forename type="middle">C</forename><surname>Minh</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Trautmann</surname></persName>
		</author>
		<author>
			<persName><forename type="first">C</forename><surname>Kozyrakis</surname></persName>
		</author>
		<author>
			<persName><forename type="first">K</forename><surname>Olukotun</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">PACT&apos;07: Proceedings of the 16th international conference on Parallel architectures and compilation techniques</title>
				<meeting><address><addrLine>Washington, DC, USA</addrLine></address></meeting>
		<imprint>
			<publisher>IEEE Computer Society</publisher>
			<date type="published" when="2007">2007</date>
			<biblScope unit="page" from="376" to="387" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b9">
	<analytic>
		<title level="a" type="main">Petri Nets</title>
		<author>
			<persName><forename type="first">W</forename><surname>Reisig</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">PNSE&apos;11 -Petri Nets and Software Engineering</title>
		<title level="s">EATCS Monagraphs on Theoretical Computer Science</title>
		<imprint>
			<publisher>Springer Verlag</publisher>
			<date type="published" when="1985">1985</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b10">
	<analytic>
		<title level="a" type="main">Coloured Petri Nets: Basic Concepts, Analysis Methods and Practical Use</title>
		<author>
			<persName><forename type="first">K</forename><surname>Jensen</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="s">EATCS Monographs in Computer Science</title>
		<imprint>
			<biblScope unit="volume">1</biblScope>
			<date type="published" when="1992">1992</date>
			<publisher>Springer verlag</publisher>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b11">
	<analytic>
		<title level="a" type="main">Causal Atomicity</title>
		<author>
			<persName><forename type="first">P</forename><surname>Azadeh Farzan</surname></persName>
		</author>
		<author>
			<persName><surname>Madhusudan</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Proceedings of Computer Aided Verification (CAV) 2006</title>
		<title level="s">Lecture Notes in Computer Science</title>
		<meeting>Computer Aided Verification (CAV) 2006</meeting>
		<imprint>
			<date type="published" when="2006">2006</date>
			<biblScope unit="volume">4144</biblScope>
			<biblScope unit="page" from="315" to="328" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b12">
	<analytic>
		<title level="a" type="main">The Petri Net Kernel: An infrastructure for building Petri net tools</title>
		<author>
			<persName><forename type="first">Ekkart</forename><surname>Kindler</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Michael</forename><surname>Weber</surname></persName>
		</author>
		<ptr target="http://www2.informatik.hu-berlin.de/top/pnk/" />
	</analytic>
	<monogr>
		<title level="j">International Journal on Software Tools for Technology Transfer (STTT)</title>
		<imprint>
			<biblScope unit="volume">3</biblScope>
			<biblScope unit="page" from="486" to="497" />
			<date type="published" when="2001">2001</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b13">
	<monogr>
		<title/>
		<author>
			<persName><surname>Gjc</surname></persName>
		</author>
		<ptr target="http://www.sun.com/software/communitysource/j2se/java2/download.xml" />
		<imprint/>
	</monogr>
</biblStruct>

<biblStruct xml:id="b14">
	<analytic>
		<title level="a" type="main">Object-Oriented Modelling with Object Petri Nets, Concurrent Object-Oriented Programming and Petri Nets</title>
		<author>
			<persName><forename type="first">C</forename><forename type="middle">A</forename><surname>Lakos</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Lecture Notes in Computer Science 2001</title>
				<editor>
			<persName><forename type="first">G</forename><surname>Agha</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">F</forename><forename type="middle">D</forename><surname>Cindio</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">G</forename><surname>Rozenberg</surname></persName>
		</editor>
		<imprint>
			<publisher>Springer-Verlag</publisher>
			<date type="published" when="2001">2001</date>
			<biblScope unit="page" from="1" to="37" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b15">
	<analytic>
		<title level="a" type="main">CLOWN as a Testbed for Concurrent Object-Oriented Concepts, Concurrent Object-Oriented Programming and Petri Nets</title>
		<author>
			<persName><forename type="first">E</forename><surname>Batiston</surname></persName>
		</author>
		<author>
			<persName><forename type="first">A</forename><surname>Chizzoni</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Fiorella</forename><surname>De Cindo</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Lecture Notes in Computer Science 2001</title>
				<editor>
			<persName><forename type="first">G</forename><surname>Agha</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">F</forename><forename type="middle">D</forename><surname>Cindio</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">G</forename><surname>Rozenberg</surname></persName>
		</editor>
		<imprint>
			<publisher>Springer-Verlag</publisher>
			<date type="published" when="2001">2001</date>
			<biblScope unit="page" from="131" to="163" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b16">
	<analytic>
		<title level="a" type="main">CoOperative Objects: Principles, Use and Implementation, Concurrent Object-Oriented Programming and Petri Nets</title>
		<author>
			<persName><forename type="first">C</forename><surname>Sibertin-Blanc</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Lecture Notes in Computer Science 2001</title>
				<editor>
			<persName><forename type="first">G</forename><surname>Agha</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">F</forename><forename type="middle">D</forename><surname>Cindio</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">G</forename><surname>Rozenberg</surname></persName>
		</editor>
		<imprint>
			<publisher>Springer-Verlag</publisher>
			<date type="published" when="2001">2001</date>
			<biblScope unit="page" from="216" to="246" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b17">
	<analytic>
		<title level="a" type="main">Object-Oriented Nets with Algebraic Specifications: The CO-OPN/2 Formalism, Concurrent Object-Oriented Programming and Petri Nets</title>
		<author>
			<persName><forename type="first">O</forename><surname>Biberstein</surname></persName>
		</author>
		<author>
			<persName><forename type="first">D</forename><surname>Buchs</surname></persName>
		</author>
		<author>
			<persName><forename type="first">N</forename><surname>Guelfi</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Lecture Notes in Computer Science 2001</title>
				<editor>
			<persName><forename type="first">G</forename><surname>Agha</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">F</forename><forename type="middle">D</forename><surname>Cindio</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">G</forename><surname>Rozenberg</surname></persName>
		</editor>
		<imprint>
			<publisher>Springer-Verlag</publisher>
			<date type="published" when="2001">2001</date>
			<biblScope unit="page" from="73" to="130" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b18">
	<analytic>
		<title level="a" type="main">Petri Nets as Token Objects An Introduction to Elementary Object Nets</title>
		<author>
			<persName><forename type="first">R</forename><surname>Valk</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Proceedings of 19th International Conference on the Application and Theory of Petri Nets</title>
				<meeting>19th International Conference on the Application and Theory of Petri Nets</meeting>
		<imprint>
			<publisher>Springer-Verlag</publisher>
			<date type="published" when="1998">1998</date>
			<biblScope unit="volume">1420</biblScope>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b19">
	<monogr>
		<ptr target="http://www.informatik.hu-berlin.de/lehrstuehle/automaten/ina" />
		<title level="m">INA:Integrated Net Analyzer</title>
				<imprint/>
	</monogr>
</biblStruct>

				</listBibl>
			</div>
		</back>
	</text>
</TEI>
