Petri
Petri
Petri
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.
OK
OK OK
OK
OK OK
pressed
approve
Rejected Reject
Initial state
Approved
Final state
(C) Copyright 2001, Chris Ling
Example: EFTPOS System (A Petri net)
Initial d1 d2 d3
OK
OK OK OK
OK
OK
pressed
Rejected!
approve
Reject
approved
Scenario 1: Normal
– Enters all 4 digits and press OK.
Scenario 2: Exceptional
– Enters only 3 digits and press OK.
Initial d1 d2 d3
OK
OK OK OK
OK
OK
pressed
Rejected!
approve
Reject
approved
Deposit 5c
Deposit 5c
i t
pos
0 cent
De De
po
sit
10
c
Deposit 10c 20 cents
10 cents
Deposit Deposit
0c 5c Deposit 5c
5c
Deposit 10c
10c 20c
Deposit 10c
Take 20c bar
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.
Deposit Deposit
0c 5c Deposit 5c
5c
Deposit 10c
10c 20c
Deposit 10c
Take 20c bar
Take Take
order order
eating eating
Tell
kitchen Serve food
Serve food
Scenario 1:
– Waiter takes order from customer 1; serves
customer 1; takes order from customer 2; serves
customer 2.
Scenario 2:
– Waiter takes order from customer 1; takes order
from customer 2; serves customer 2; serves
customer 1.
Take Take
order order
eating eating
Tell
kitchen Serve food
Serve food
Take Take
order order
eating eating
Tell
kitchen Serve food
Serve food
e1 e2 e3
Concurrent executions:
e2 e3
e1
e4 e5
(C) Copyright 2001, Chris Ling
Net Structures
Non-deterministic events - conflict, choice or
decision: A choice of either e1, e2 … or e3, e4 ...
e1 e2
e3 e4
e1
e1
ready accepted
p1 p4
Storage p3
produce accept
t1 t2 3 2 t3 t4 consume
send
k=5
p2 p5
idle ready
k=1 k=2
Producer Consumers
Deposit Deposit
0c 5c Deposit 5c
5c
Deposit 10c
10c 20c
Deposit 10c
Take 20c bar
Initial marking:M0
t6 p5
t2
p3
p3
t6 p5 Initial marking:M0
t2
t9
t1 t3 t5 t8 t2 t6
M0 M1 M2 M3 M0 M2 M4
p1 p2 t3 t4
p4
t2
M0 = (1,0,0,1)
M1 = (0,1,0,1)
M2 = (0,0,1,0)
M3 = (0,0,0,1)
A bounded but non-live Petri net
(C) Copyright 2001, Chris Ling
Another Example
p1 M0 = (1, 0, 0, 0, 0)
M1 = (0, 1, 1, 0, 0)
t1 M2 = (0, 0, 0, 1, 1)
M3 = (1, 1, 0, 0, 0)
p2 p3 M4 = (0, 2, 1, 0, 0)
t2 t3
p4 p5
t4
An unbounded but live Petri net
(C) Copyright 2001, Chris Ling
Analysis Methods
• Reachability Analysis:
• Reachability or coverability tree.
• State explosion problem.
• Incidence Matrix and State Equations.
• Structural Analysis
• Based on net structures.
Storage accept
produce send
consume
ready
Producer
Consumer
data: ITEM
data: ITEM
ITEM produce( )
ITEM accept( )
void send(ITEM)
void consume(ITEM)
(C) Copyright 2001, Chris Ling
Petri Net References
Murata, T. (1989, April). Petri nets: properties, analysis
and applications. Proceedings of the IEEE, 77(4), 541-80.
Peterson, J.L. (1981). Petri Net Theory and the Modeling
of Systems. Prentice-Hall.
Reisig, W and G. Rozenberg (eds) (1998). Lectures on
Petri Nets 1: Basic Models. Springer-Verlag.
The World of Petri nets:
http://www.daimi.au.dk/PetriNets/