Professional Documents
Culture Documents
BE (CS) Introduction
▪ Petri nets (PNs) provide a graphical tool as well as a
Spring 2022 Semester
notational method for the formal specification of
systems.
CS-438: Computer Systems Modeling ▪ PNs have a place in computer systems performance
assessment, ranging somewhere between
o Analytical Queuing Theory and
o Computer Simulation.
Lecture #41-42
▪ The systems they model tend to include more than
Petri Net-based Performance Modeling
simply an arrival rate and a service rate.
Dr Syed Zaffar Qasim ▪ Two important aspects in modeling the performance of
Assistant Professor (CIS) computer systems
1. contention for resources and
1 2. synchronization between various concurrent activities.
2
Introduction Introduction
▪ The former aspect can be adequately represented by ▪ PNs were first introduced in 1966 by C. A. Petri in his
Queuing Network Modeling, but the later cannot. doctoral thesis to describe concurrent systems.
▪ Petri nets (PNs) have long been used for modeling ▪ This initial introduction was followed by continual
synchronization behavior of concurrent systems but improvements for example,
not as completely as simulations. o the addition of timing to transitions,
▪ They act more like simulations in that o priority to transitions,
o they allow the modeler to examine single entities o types to tokens,
within the system, o and colors depicting conditions on places and
o as well as their movement and effect on the state of tokens.
entire system. ▪ These have been followed by the development of
software tools to aid in the modeling and analysis of
systems using PN concepts.
3 4
1
Fundamental components of a Petri net Fundamental components of a Petri net
▪ PNs provide abstract representation of ▪ A marking defines the number of tokens in each of the
o basic elements of computer systems and their places of the Petri net.
informational flow
Fig 1: Basic Petri net
o using only four fundamental components. components
▪ Petri nets are usually represented graphically
according to the following conventions:- ▪ Places are used to represent possible system
o Places are represented by circles, components and their state.
o transitions by bars, o e.g., a disk drive could be represented using a place,
o input function by arcs directed from places to as could a program or other resource.
transitions, ▪ Transitions are used to describe events that may result
o output function by arcs directed from transitions to in different system states.
places,
o markings by small filled circles called tokens. ▪ For example, the action of reading an item from a disk
drive or the action of writing an item to a disk drive
5 could be modeled as separate transitions. 6
2
State of a Petri net Representation of Petri nets
▪ PNs have a state defined by
o the cardinality of tokens and ▪ PNs are described both graphically and using set
o their distribution throughout the places in the PN. notation.
▪ Marking represented as a function, (or MP), as follows: ▪ Using set notation, we can describe a PN as a 5-tuple,
: p → Z+ M= (P, T, I, O, MP)
▪ The marking, , can also be defined as an n vector.
where
▪ e.g. the marking for the PN shown in Fig 9 would be
▪ P is the set of places, P = {P1, P2, … ,Pn}
t= (1, 2, 0, 0, 1).
▪ T is the set of transitions, T= {t1, t2, ... ,tm}
▪ I P x T is the input function,
▪ O T x P is the output function, and
▪ MP P x Z+ is a marking of the net.
o Here, Z+ denotes the set of all nonnegative integers.
▪ The number of tokens that may be assigned to a place is
unbounded. 9 10
3
The dual of a Petri net The inverse of a Petri net
▪ Transitions changed to places and places changed ▪ Keeps all places and transitions the same and
to transitions. switches input functions with output functions.
Fig 4(a): Petri net PN1 Fig 4(b): Dual of PN1 Fig 5(a): Petri net PN1 Fig 5(b): Inverse of PN1
13 14
Lecture 42
Petri nets as multi-graphs
Classical Petri nets
▪ The classical PNs do not convey any notion of time.
▪ PNs are defined also as multi-graphs,
▪ The exact moment of firing can be pictured as
o since a place can represent
occurring as a clock signal in a computer system.
o multiple inputs to a transition
o and/or multiple outputs from a transition.
Fig 6(a): Multipath Fig 7: Enabled transition Fig 8: New Petri net state
arc
Marking µo = (1,2,0) Marking µ1 = (0,0,3)
▪ Input function I(t1) = {P1, P2, P2} and
▪ Output function O(t1) = {P3,P3,P3}
Fig 6(b): Multipath arc as bold line 15
2
4
Classical Petri nets Reachability
▪ State-space: The collection of all possible states of a
▪ A Petri net state, µ, reachable from another state,
Petri net.
µ', if there is an integer number of intermediate
▪ Next-state function, applied to a Petri net state as steps from µ' to µ.
follows:- ▪ e.g., µ0 = (3, 0, 0, 0), and a target state µ' = (1,0,0,1).
(µi{t}) = µi+1
▪ The set {t} represents the set of all enabled
Fig 9
transitions within this Petri net.
▪ If a transition not enabled, then this function is
undefined. ▪ We can reach this target state in three firings of our
net.
t1 → t2 → t3
3 4
Reachability Reversibility
▪ µ2 = (1, 1, 1, 0)
▪ µ3 = (1, 0, 0, 1)
6
5
5
Modeling logical conditions Modeling logical conditions
▪ It is often desirable to model logical conditions. ▪ Inhibitor Arcs
▪ e.g., to only fire a transition when there are more ▪ The inhibition function usually represented by
than n tokens in a place. circle-headed arcs.
▪ Modifies the enabling rules so that the transition
fires only if pj does not contain tokens.
Fig 10
Fig 11
7 8
Fig 12
Fig 14
▪ If we wish to test for less than n items and remove the items,
we could use the Petri net shown in Fig below.
6
Properties of Petri Nets
Properties of Petri Nets
▪ BOUNDEDNESS
▪ LIVENESS o A Petri net defined to be k-place bounded if for all places,
there are k or less tokens in each place for all possible
o A transition is live if it is potentially firable in any
states of the network.
marking of R(M1).
o For example, Fig below is a three-bounded net.
o A transition is dead in M1 if it is not potentially
firable.
▪ SAFENESS
o A place is safe if the token count does not exceed 1
in any marking of R(M1). o A simple generalization of safeness.
o A PN is safe if each place is safe. o A PN is k-bounded if each place is k-bounded.
▪ CONSERVATION
o A PN is strictly conservative if the total number of tokens
is constant in each marking of R(M1).
Petri Nets and the Modeling of Computer Systems Concurrency (OR Parallelism)
▪ In reliability modeling, the PN of Fig 15 below can
▪ PN used for modeling real systems sometimes
represent two components C1 and C2 in parallel
referred to as Condition/Events nets.
redundancy.
▪ Places identify conditions of parts (working, idle,
queuing, failed), and
▪ Transitions describe the passage from one condition
to another (end of a task, failure, repair ...).
▪ An event occurs (a transition fires) when all
conditions satisfied.
Fig 15: PN modeling two parallel activities
▪ The number of tokens in a place used to identify the
number of resources lying in the condition denoted ▪ p1 & p3 represent working condition, p2 & p4 the failed
by that place. condition and t1 & t2 the event of failure of C1 & C2
respectively.
7
Limited Resources
Synchronization
▪ Both the routines of a parallel program should be ▪ A typical factor influencing the performance of
terminated before the program execution can proceed. computer systems.
▪ The synchronization activity modeled in fig 16 below by ▪ A PN representation of a buffer with limited size.
means of t3 whose firing requires a token both in p2 and p4.
Fig 17
Fig 16
▪ Place p3 models the number of free buffer positions
whereas p2 the number of filled positions.
Limited Resources
▪ Transition t2 models the filling of one buffer position
and can fire if a position free (at least one token in p3)
exists and a data is available to be stored (a token in
p1).