By
Dr Chris Ling
School of Computer Science & Software Engineering
Monash University
Chris.Ling@csse.monash.edu.au
Introduction
First introduced by Carl Adam Petri in
1962.
A diagrammatic tool to model concurrency
and synchronization in distributed systems.
Very similar to State Transition Diagrams.
Used as a visual communication aid to
model the system behaviour.
Based on strong mathematical foundation.
(C) Copyright
Initial
1 digit
d1
1 digit
d2
1 digit
d3
1 digit
d4
OK
OK
OK
OK
Final state
(C) Copyright
Reject
OK
pressed
approve
Rejected
Initial state
OK
Approved
1 digit
d1
OK
1 digit
d2
OK
1 digit
d4
d3
OK
OK
OK
OK
pressed
Rejected!
Reject
approve
approved
(C) Copyright
EFTPOS System
Scenario 1: Normal
Enters all 4 digits and press OK.
Scenario 2: Exceptional
Enters only 3 digits and press OK.
(C) Copyright
1 digit
d1
OK
1 digit
d2
OK
1 digit
d4
d3
OK
OK
OK
OK
pressed
Rejected!
Reject
approve
approved
(C) Copyright
A Change of State
is denoted by a movement of token(s)
A Change of State
A transition is firable or enabled when there
(C) Copyright
De
po
sit
10
10 cents
5c
t
i
os
p
De
Deposit 10c
(C) Copyright
15 cents
Deposit 5c
0 cent
5 cents
Deposit 5c
5
t
i
os
p
De
Deposit 10c
20 cents
Deposit 10c
5c
15c
Deposit 5c
0c
Deposit
5c
Deposit 10c
10c
(C) Copyright
Deposit
5c
Deposit
5c
20c
Deposit 10c
Scenario 1:
Deposit 5c, deposit 5c, deposit 5c, deposit 5c,
take 20c snack bar.
Scenario 2:
Deposit 10c, deposit 5c, take 15c snack bar.
Scenario 3:
Deposit 5c, deposit 10c, deposit 5c, take 20c
snack bar.
(C) Copyright
Deposit 10c
5c
15c
Deposit 5c
0c
Deposit
5c
Deposit 10c
10c
(C) Copyright
Deposit
5c
Deposit
5c
20c
Deposit 10c
time.
A system may have many local states to
form a global state.
There is a need to model concurrency and
synchronization.
(C) Copyright
Customer 1
Customer 2
Take
order
Take
order
wait
eating
Serve food
(C) Copyright
Order
taken
Tell
kitchen
wait
eating
Serve food
Customer 1
Customer 2
Take
order
Take
order
wait
eating
Serve food
(C) Copyright
Order
taken
Tell
kitchen
wait
eating
Serve food
Customer 1
Customer 2
Take
order
Take
order
wait
eating
Serve food
(C) Copyright
Order
taken
Tell
kitchen
wait
eating
Serve food
Net Structures
A sequence of events/actions:
e1
e2
e3
Concurrent executions:
e2
e3
e4
e5
e1
(C) Copyright
Net Structures
Non-deterministic events - conflict, choice or
e2
e3
e4
(C) Copyright
Net Structures
Synchronization
e1
(C) Copyright
Net Structures
Synchronization and Concurrency
e1
(C) Copyright
Another Example
A producer-consumer system, consist of one
(C) Copyright
A Producer-Consumer System
k=2
k=1
accepted
ready
p1
produce
t2
t1
p4
Storage p3
send
p2
2
k=5
accept
t3
t4
p5
idle
ready
k=1
k=2
Producer
Consumers
(C) Copyright
consume
A Producer-Consumer Example
In this Petri net, every place has a capacity
(C) Copyright
Behavioural Properties
Reachability
Can we reach one particular state from
another?
Boundedness
Will a storage place overflow?
Liveness
Will the system die in a particular state?
(C) Copyright
Deposit 10c
5c
15c
Deposit 5c
0c
Deposit
5c
Deposit 10c
10c
(C) Copyright
Deposit
5c
Deposit
5c
20c
Deposit 10c
p4
t4
p2
t1
p1
t3
t2
(C) Copyright
t5
t6
p3
t9
t7
M0 = (1,0,0,0,0)
M1 = (0,1,0,0,0)
M2 = (0,0,1,0,0)
M3 = (0,0,0,1,0)
M4 = (0,0,0,0,1)
Initial marking:M0
p5
Reachability
t8
p4
t4
M0 = (1,0,0,0,0)
p2
M1 = (0,1,0,0,0)
t1
M2 = (0,0,1,0,0)
p1
t3
t7
t5
p3
t6
t2
p5
M3 = (0,0,0,1,0)
M4 = (0,0,0,0,1)
Initial marking:M0
t9
M0
t1
M1
t3
(C) Copyright
M2
t5
M3
t8
M0
t2
M2
t6
M4
Reachability
A firing or occurrence sequence:
M0
t1
M1
t3
M2
t5
M3
t8
M0
t2
M2
t6
M4
Boundedness
A Petri net is said to be k-bounded or
Liveness
A Petri net with initial marking M0 is live if,
Liveness
The vending machine is live and the
(C) Copyright
An Example
t1
p3
p2
p1
t2
t3
t4
p4
M0 = (1,0,0,1)
M1 = (0,1,0,1)
M2 = (0,0,1,0)
M3 = (0,0,0,1)
Another Example
M0 = (1, 0, 0, 0, 0)
p1
M1 = (0, 1, 1, 0, 0)
M2 = (0, 0, 0, 1, 1)
t1
M3 = (1, 1, 0, 0, 0)
p2
p3
t2
t3
p4
p5
t4
(C) Copyright
M4 = (0, 2, 1, 0, 0)
Analysis Methods
Reachability Analysis:
Reachability or coverability tree.
State explosion problem.
Incidence Matrix and State Equations.
Structural Analysis
Based on net structures.
(C) Copyright
Consumer
accepted
ready
produce
send
Storage
accept
consume
ready
Producer
data: ITEM
ITEM produce( )
void send(ITEM)
(C) Copyright
Consumer
data: ITEM
ITEM accept( )
void consume(ITEM)
(C) Copyright