Professional Documents
Culture Documents
Petri Nets PDF
Petri Nets PDF
2006/2007
History
● Petri nets were introduced by C.A. Petri in his
Ph.D. Dissertation: ”Kommunikation mit
Automaten.” , Institut für Instrumentelle
Mathematik, Bonn, 1962.
● They are particularly useful form modeling
systems with concurrent and asynchronous
processing
Why concurrency is a problem?
● Concurrency and asynchronous processing is
typical in real world
● It can pose a problem when many entities
(people, machines, processing threads) use
(share) the same resource (or a limited number
of resources)
● A trivial example is that of an elevator – the
cabin is single resource that many people want
to use. The problem is how to control the
elevator to minimise waiting time?
Why concurrency is a problem?
● The elevator '”scheduling” control is not crucial,
at worst improper algorithm may result in long
waiting times
● There are situations where handling
concurrency is crucial for correct behaviour of
the system
Why concurrency is a problem?
● Unwanted results of concurrency include:
– Race conditions
– Resource starvation
– Deadlocks
Race conditions
● When race conditions occur, the result of the
system behaviour may be unexpected and is
dependent on the sequence of other events
● Race conditions were first described in
electronics (logic circuits), when parallelism is
typical
● An example of race conditions may be poorly
implemented ATM
ATM case
● Lets imagine the ATM operation is following
– Authorise client
– Get account balance
– Get client request
– Update account
– Dispense cash
ATM case
● This can translate to following situation:
– Time = t0 Authorisation OK
– Time = t0+2s Balance is 1000
– Time = t0+10s Client requested 800, 800<1000
– Time = t0+12s Account updated by -800, 200 left
– Time = t0+14s Cash dispensed
● Everything worked fine
ATM case
● Now, lets imagine that there are two cards
attached to the same account (wife and
husband, corporate account etc.)
● Two persons at nearly the same time want to
withdraw money. What may happen?
ATM case
Client 1 Client 2
Time = t0 Authorisation OK
Tokens in place
Arc expression
Coloured version of dining
philosophers
Coloured version of dining
philosophers
Coloured version of dining
philosophers
Coloured version of dining
philosophers
Software for Petri nets – CPN Tools
● http://wiki.daimi.au.dk/cpntools/_home.wiki
● Now (May 2007) in version 2.2.0
● Created by CPN Group, University of Aarhus,
Denmark
● Runs on Win2K, Win XP, Linux Fedora Core 2,
probably other Linux distributions
● Requires hardware OpenGL acceleration, may
not work with older graphics cards
CPN Tools interface
● CPN Tools uses a clever and intuitive UI,
however, it is quite different from typical GUI –
this may pose problems during first contact
● The screen is divided into “Index” (left side) and
“Workspace” (the rest)
● Although the Index can be used for some
operations, typical user interaction is different
CPN Tools interface
● Many functions are accessible by clicking and
holding right mouse button – this brings up a
circular context menu
● Some items can be dragged from the Index into
Workspace – they expand into toolboxes
CPN Tools interface