You are on page 1of 8

Lecture 41

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

Dynamic behavior of a Petri net A simple Petri net


▪ The dynamic behavior of a Petri net is described by ▪ The marking of a Petri net place by the placement of a
the sequence of transition firings. token can be viewed as the statement of the condition
▪ The firing rules are as follows: of the place.
o Let t be a transition with
▪ For example, Fig 2 illustrates a simple Petri net with
o incoming arcs from places ip1 ,…,ipK and
only one place and one transition.
o outgoing arcs to places op1,…,opL for some K, L > 1.

Fig 2: Example perpetual


motion Petri net

• Then t can fire if and only if each of the K input places


contains at least one token. ▪ The former arc is input arc, while the later is an output
• As a result of firing, one token will be removed from arc.
each of the K input places, and one token will be ▪ The Petri net shown in Fig 2 represents a net that will
added to each one of L output places. 7 continue to cycle forever. 8

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

Representation of Petri nets


Representation of Petri nets
▪ I represents a bag of sets of input functions for all
transitions, Fig 3: PN Example
o I = {It1, It2, …, Itm}, mapping places to transitions;,
▪ O represents a bag of sets of output functions for all
▪ For example, the PN graph of Fig 3 can be described using
transitions, the previous notation as:
o O = {Ot1, Ot2, ... ,Otm}, mapping transitions to places; M = (P, T, I, O, MP)
▪ P = {p1, p2, p3, p4, p5}
▪ MP represents the marking of places with tokens. ▪ T = {t1, t2, t3, t4}
o The initial marking is referred to as MPo or o. ▪ I(t1) = {p1}
o MPo is represented as an ordered tuple of magnitude ▪ I(t2) = {p2, p3, p5}
▪ I(t3) = {p3}
n, where n represents the number of places in a PN. ▪ I(t4) = {p4}
▪ O(t1) = {p2, p3, p5}
▪ Each place will have either no tokens or some integer ▪ O(t2) = {p5}
number of tokens. ▪ O(t3) = {p4}
11 ▪ O(t4) = {p2, p3} 12

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

▪ µ0 = (3, 0, 0, 0) ▪ Property where, given some initial state, µ, we can


return back to this state, in finite time.
▪ In Fig 9, µo, is not reversible, since we cannot get back
to this state in a finite number of steps.
▪ µ1 = (2, 1, 0, 0)

▪ µ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

Modeling logical conditions Petri net modeling conflict and concurrency


▪ To test for the condition of equal to some value but not ▪ An initial marking, μ = (1,1,0,0,0), results in
greater than the value, transitions t1 and t2 being enabled, the condition of
o we can use an inhibitor of arity n + 1 to block a transition
o if there are more than n tokens in place p0. concurrent transitions.

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.

Fig 13 ▪ If t1 fires first, then we have two transitions


enabled, t2 and t3.
▪ This then depicts a conflict.

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).

▪ Transition t3 is enabled when at least one buffer


position is filled, and firing of t3 moves one token
from p2 to p3.

You might also like