SlideShare a Scribd company logo
CS-438
COMPUTER SYSTEMS MODELING
Spring Semester 2024
Batch: 2020
(LECTURE # 25-30)
FAKHRA AFTAB
LECTURER
DEPARTMENT OF COMPUTER & INFORMATION SYSTEMS ENGINEERING
NED UNIVERSITY OF ENGINEERING & TECHNOLOGY
PETRI NET-BASED
PERFORMANCE MODELING
Chapter # 6
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
INTRODUCTION
• Petri nets (PNs) provide a graphical tool as well as a notational method
for the formal specification of systems.
• The systems PNs model tend to include more than simply an arrival
rate and a service rate.
• Two important aspects in modeling the performance of computer
systems (1) contention for resources and (2) synchronization between
various concurrent activities.
• The former aspect can be adequately represented by Queuing
Network Modeling, but the later cannot.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
• Petri nets have long been used for modeling synchronization
behavior of concurrent systems but not as completely as
simulations.
• They act more like simulations in that they allow the modeler to
examine single entities within the system, as well as their movement
and effect on the state of entire system.
• Petri nets were first introduced in 1966 to describe concurrent
systems.
• This initial introduction was followed by continual improvements
for example,
• the addition of timing to transitions,
• priority to transitions,
• types to tokens,
• and colors depicting conditions on places and tokens.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
GRAPHICAL REPRESENTATION
• Petri nets are usually represented graphically according to the
following conventions:
• Places are represented by circles,
• transitions by bars,
• input function by arcs directed from places to transitions,
• output function by arcs directed from transitions to places, and
• markings by small filled circles called tokens.
Fig 1: Basic Petri net components
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Example
Fig 2 illustrates a simple Petri net with only one place and one transition.
• The former arc is input arc, while the later is an output arc.
• The placement of a token represents the active marking of the Petri net state.
• The Petri net shown in Fig 2 represents a net that will continue to cycle
forever.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 2: Example perpetual motion Petri net
REPRESENTATION USING SET NOTATION
Using this notation, we can describe a PN as a 5-tuple, M= (P, T, I, O,
MP)
• where P is the set of places, P = {P1, P2, … ,Pn}
• 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,
• Here, Z+ denotes the set of all nonnegative integers,
• I represents a bag of sets of input functions for all transitions,
• I = {It1, It2, …, Itm}, mapping places to transitions,
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
• O represents a bag of sets of output functions for all transitions,
• O = {Ot1, Ot2, ... ,Otm}, mapping transitions to places; and
• MP represents the marking of places with tokens.
• The initial marking is referred to as MPo.
• MPo is represented as an ordered tuple of magnitude n, where n
represents the number of places in our Petri net.
• Each place will have either no tokens or some integer number of
tokens.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
For example, the Petri net graph depicted in Fig 3 can be described
using the previous notation as:
• M = (P, T, I, O, MP)
• P = {p1, p2, p3, p4, p5}
• T = {t1, t2, t3, t4}
• I(t1) = {p1}
• I(t2) = {p2, p3, p5}
• I(t3) = {p3}
• I(t4) = {p4}
• O(t1) = {p2, p3, p5}
• O(t2) = {p5}
• O(t3) = {p4}
• O(t4) = {p2, p3}
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 3: Petri net example
Dynamic Behaviour of Petri-Nets
• The dynamic behavior of a Petri net is described by the sequence of
transition firings.
• The firing rules are as follows: Let t be a transition with incoming
arcs from places ip1 ,...,ipK and outgoing arcs to places op1,...:opL
for some K,L > 1.
• Then t can fire if and only if each of the K input places contains at
least one token.
• As a result of firing, one token will be removed from each of the K
input places, and one token will be added to each one of L output
places.
Fig 4: A Petri net (a) before firing and (b) after firing
DUAL OF A PETRI-NET
• The dual of a Petri net: transitions changed to places and places
changed to transitions.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 5: Dual of Petri Net from Fig 3
Fig 3: Petri Net Example
Inverse of Petri Net
The inverse of a Petri net keeps all places and transitions the same and
switches input functions with output functions.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 6: Inverse of Petri Net from Fig 3
Fig 3: Petri net example
Petri Nets as Multi-graph
Petri nets are defined also as multi-graphs, since a place can represent
multiple inputs and/or outputs from or to a transition.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 7: Multipath arc Fig 8: Multipath arc as bold line
State of a Petri Net
• Petri nets have a state defined by the cardinality of tokens and their
distribution throughout the places in the Petri net.
• Marking represented as a function,  (or MP), as follows:
: p → Z+
• The marking, , can also be defined as an n vector.
 = (1 , 2 , 3, …, n)
Where n = |P| and each i  Z+ , i = 0, …, n and (pi) = i.
• Therefore, the true representation of a marked Petri net is:
M= (P, T, I, O, t)
where t represents state of Petri net at time t, where t Z+.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
• The number of tokens that may be assigned to a place is unbounded.
• The marking for the Petri net shown in Fig 9 represented as a vector
would be t= (1, 2, 0, 0, 1).
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 9: Marked Petri net
Classical Petri Net
• The classical PNs do not convey any notion of time.
• The exact moment of firing can be pictured as occurring as a clock
signal in a computer system.
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}
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 10: Enabled transition Fig 11: New Petri net state
State Space
• The collection of all possible states of a Petri net.
• Next-state function,  applied to a Petri net state as follows:
 (µi{t}) = µi+1
• The set {t} represents the set of all enabled transitions within this
Petri net.
• If a transition not enabled, then this function is undefined.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Petri Nets and the Modeling of Computer Systems
• PN used for modeling real systems sometimes referred to as
Condition/Events nets.
• 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.
• The number of tokens in a place used to identify the number of
resources lying in the condition denoted by that place.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Concurrency (Parallelism)
• In reliability modeling, the PN of Fig 12 can represent two
components C1 and C2 in parallel redundancy.
• p1 & p3 represent working condition, p2 & p4 the failed condition and
t1 & t2 the event of failure of C1 & C2 respectively.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 12: PN modeling two parallel activities
Synchronization
• Both the routines of a parallel program should be terminated before
the program execution can proceed.
• The synchronization activity modeled in Fig 13 by means of t3
whose firing requires a token both in p2 and p4.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 13: PN modeling two parallel activities with synchronization
Limited Resources
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 14: Block diagram and PN of a buffer with finite size.
➢ This is a typical factor influencing the performance of computer systems.
➢ A PN representation of a buffer with limited size.
The Bounded Buffer Producer/Consumer Problem
• A realistic situation is obtained by considering a buffer of limited
capacity (Fig 15).
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 15: The producer/consumer problem with finite buffer
Mutual Exclusion (Conflict)
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 16: The Mutual Exclusion Problem
Logical Conditions
• It is often desirable to model logical conditions.
• e.g., to only fire a transition when there are more than n tokens in a
place.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 17: Petri net component to test condition greater than M
Inhibitor Arcs
• The inhibition function usually represented by circle-headed arcs.
• Modifies the enabling rules so that the transition fires only if pj does
not contain tokens.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 18: Inhibitor Arc
• To test for the condition of equal
to some value but not greater
than the value, we can use an
inhibitor of arity n + 1 to block a
transition if there are more than
n tokens in place 0.
• If we wish to test for less than n
items and remove the items, we
could use the Petri net shown in
Fig 21.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 19: Petri net component to test condition
equal but not greater than M
Fig 20
Modeling conflict and concurrency
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 21: Petri net modeling conflict and concurrency
➢ An initial marking, μ = (1,1,0,0,0), results in transitions t1 and t2
being enabled, the condition of concurrent transitions.
➢ If t1 fires first, then we have two transitions enabled, t2 and t3. This
then depicts a conflict.
Reachability in Petri-Nets
• A Petri net state, µ, reachable from another state, µ', if there is an
integer number of intermediate steps from µ' to µ.
• e.g., µ0 = (3, 0, 0, 0), and a target state µ' = (1,0,0,1).
• We can reach this target state in three firings of our net.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 22: Petri net indicating reachability
Reversibility in Petri-Nets
• It is the property where, given some initial state, we can return back
to this state, µ, in finite time.
• In Fig 23, µo, is not reversible, since we cannot get back to this state
in a finite number of steps.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 23: Petri net
K-bounded Petri-Net:
• 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 states of the network.
• For example, Fig 23 is a three-
bounded net.
Example Problem
Consider the Petri-Net in Fig 23 with the initial state as µ’ = (0,1,0,2).
Is it possible to return to this state after every few transitions ?
If is that so, provide the number of transitions. Is the state reversible ?
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 23: Petri net
Deadlocked Petri-net
• A Petri net is deadlocked if there are no transitions in the net that
are enabled.
• Initial marking, µ0 = (0,0,2,0).
• This marking results in no transitions being enabled.
• Conversely, a Petri net is considered live if there are any
transitions enabled.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 24: Deadlocked Petri-Net
Properties of Petri Nets
LIVENESS
• A transition is live if it is potentially firable in any marking of
R(M1).
• A transition is dead in M if it is not potentially firable; if the PN
enters marking M the dead transition cannot fire any more.
SAFENESS
• A place is safe if the token count does not exceed 1 in any marking
of R(M1).
• A PN is safe if each place is safe.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Properties of Petri Nets (Cont’d)
BOUNDEDNESS
• A simple generalization of safeness.
• A PN is k-bounded if each place is k-bounded.
CONSERVATION
• A PN is strictly conservative if the total number of tokens is
constant in each marking of R(M1).
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Example Problem 1
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 25
Consider the Petri-Network in Fig 25.
a)Provide the sets of places, transitions &
initial marking.
b)Provide the sets of all the input and output
functions w.r.t the transitions given in the
figure.
c) Suppose at time T1, transition t1 is able to
fire. What would be the marking M1?
d) Identify M2, M3, M4 and M5 at times T2, T3
and T4.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Example Problem 2
t1 t2
P1
P4
P3
P2
t1 t2
P1
P4
P3
P2
t1 t2
P1
P4
P3
P2
t1 t2
P1
P4
P3
P2
MATRIX ANALYSIS
• The input and output functions of a PN can be equivalently
defined using a matrix notation.
• Let D- denotes the input matrix. D- is a (nt x np) matrix, whose
generic element dij
- is equal to the number of arcs connecting place
pj with transition ti.
• Similarly the output matrix D+ is a (nt x np) matrix, whose generic
element dij
+ is equal to the number of arcs connecting transition ti
with place pj.
• The incidence matrix D is defined by the following relation:
D = D+ - D-
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Example
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Following are the matrices D-, D+ and D for the PN of Fig 26:
Fig 26
• Introducing the vector ej which is a nt-dimensional row vector with
all the entries equal to 0 except entry j equal to 1.
• With this notation the execution rules of a PN becomes:
• a transition tj is enabled in marking M iff M ≥ ej D- (note that ej D- is the j-th
row of D-);
• firing of tj in M produces a marking M’ given by:
M’ = M – ej D- + ej D+ = M + ej D
• Given a PN with initial marking M1 and a firing sequence ti → tj →
tk → tj → ti, the marking obtained at the end of the sequence is
given by the following matrix equation:
Mfin = M1 + (ei + ej + ek + ej + ei )D
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Example Problem 3
Q) Consider the figure, find M’ if t3 is enabled to fire.
Input or Pre-Incidence Matrix:
D- =
1 1 1 0
0 0 0 1
0 0 1 0
Output or Post-Incidence Matrix:
D- =
1 0 0 0
0 2 1 0
0 0 0 1
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig
P1
P3
P4
P2
t1
t3
t2
2
Incidence Matrix:
D =
0 −1 −1 0
0 2 1 −1
0 0 −1 1
Initial Marking:
M0 = [1 0 1 0]
From the Fig, t3 is enabled:
ej = (0, 0, 1)
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
P1
P3
P4
P2
t1
t3
t2
Fig
M’ = M + ej D
M’ = 1 0 1 0 + 0 0 1
0 −1 −1 0
0 2 1 −1
0 0 −1 1
M’ = 1 0 0 1
Q) Let the firing sequence be: t3t2t3t2t1
⟹ 𝑒𝑗 = 1 2 2
If M = 1 0 1 0 ,
M’ = 1 0 1 0 + 1 2 2
0 −1 −1 0
0 2 1 −1
0 0 −1 1
M’ = 1 3 0 0
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Timed Petri Nets
• An activity in a real system takes finite time to perform its operation.
• e.g., to read a file from a disk, to execute a program, or to communicate
with some other machine.
• Adding time provides Petri net modeler with another powerful tool to
study the performance of computer systems.
• Time can be associated with transitions, selection of paths, waiting in
places, inhibitors, and with any other component of the Petri net.
• The most typical way that time used in Petri nets is with transitions.
• the firing of a transition can be viewed as the execution of an event
being modeled – e.g., a CPU execution cycle.
• These timed transitions are represented graphically as a rectangle or thick
bars.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
The Semantics of the Firing
• When a transition becomes enabled,
its clock timer is set and begins to
count down.
• Once the timer reaches 0, the
transition fires.
• In Fig 27, when token arrives at pl,
the timer for t1 set to 1 and begins to
count down.
• The decrement of the timer must be
at a constant fixed speed for all
transitions in the Petri net model.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 27: Timed Petri net
• A consideration to think about
• what occurs when a transition becomes non-
enabled due to the initial enabling token being
used to ultimately fire a competing transition.
• This condition shown in Fig 28.
• If we assume the time for t1 is less than that
for t2, then, when p1 receives a token, the two
timers would begin counting down.
• At some time (1) in the future, the timer for t1
would reach its zero value, resulting in the
firing of t1.
• Since the token enabling t2 is now gone, t2 is
no longer enabled and, therefore, its timer (2)
would stop ticking down.
• The question now is what to do with
transition t2's timer.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
Fig 28: Timed Petri net with conflict
Two possibilities
1) The first is to simply reset the timer on the next cycle.
• In this case, unless place p0 has a state where it has more than one
token present, transition t2 will never fire.
2) Allow transition t2's timer to maintain the present clock timer value
(2 - 1).
• When the next token is received at pl, if the remaining time in t2's
timer is less than t1's timer, then t2 will fire, leaving t1 with the
remaining time (1 - (2- l)).
The choice of which protocol to use will depend on the system one
wishes to model.
Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)

More Related Content

PDF
Cb32492496
PDF
An Efficient Construction of Online Testable Circuits using Reversible Logic ...
PPTX
all about petri netis model and simulation
PDF
The Fast Fourier Transform (FFT)
PPT
Continuous Systems To Discrete Event Systems
PDF
Simulating Turing Machines Using Colored Petri Nets with Priority Transitions
PPT
Lecture 1
PDF
5. CNTFET-based design of ternary.pdf
Cb32492496
An Efficient Construction of Online Testable Circuits using Reversible Logic ...
all about petri netis model and simulation
The Fast Fourier Transform (FFT)
Continuous Systems To Discrete Event Systems
Simulating Turing Machines Using Colored Petri Nets with Priority Transitions
Lecture 1
5. CNTFET-based design of ternary.pdf

Similar to CS-438 WK13-15LEC25-30 Computer System Modeling.pdf (20)

PPT
petri-nets: definition and its application
DOCX
Ecet 345 Enthusiastic Study / snaptutorial.com
DOCX
Ecet 345 Success Begins / snaptutorial.com
DOCX
Ecet 345 Massive Success / snaptutorial.com
PDF
All Pair Shortest Path Algorithm – Parallel Implementation and Analysis
PDF
505 260-266
PDF
Research Inventy: International Journal of Engineering and Science
PDF
Research Inventy : International Journal of Engineering and Science is publis...
PDF
A Redundant Adder Architecture in Ternary Quantum-Dot Cellular Automata
PDF
Multivariable Control System Design for Quadruple Tank Process using Quantita...
PPT
13486500-FFT.ppt
PPTX
Ternary Logic Based Halfadder and full adder
PDF
QUANTUM COMPUTING FOR VLSI : VERILOG IMPLEMENTATION OF REVERSIBLE LOGIC GATES
PPTX
Time and Space Complexity Analysis.pptx
PDF
International Journal of Engineering and Science Invention (IJESI)
PDF
Automated Information Retrieval Model Using FP Growth Based Fuzzy Particle Sw...
PDF
Improving initial generations in pso algorithm for transportation network des...
PDF
CS-438 COMPUTER SYSTEM MODELING WK5LEC9-10.pdf
PDF
Design of Digital Adder Using Reversible Logic
PDF
Design of Digital Adder Using Reversible Logic
petri-nets: definition and its application
Ecet 345 Enthusiastic Study / snaptutorial.com
Ecet 345 Success Begins / snaptutorial.com
Ecet 345 Massive Success / snaptutorial.com
All Pair Shortest Path Algorithm – Parallel Implementation and Analysis
505 260-266
Research Inventy: International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and Science is publis...
A Redundant Adder Architecture in Ternary Quantum-Dot Cellular Automata
Multivariable Control System Design for Quadruple Tank Process using Quantita...
13486500-FFT.ppt
Ternary Logic Based Halfadder and full adder
QUANTUM COMPUTING FOR VLSI : VERILOG IMPLEMENTATION OF REVERSIBLE LOGIC GATES
Time and Space Complexity Analysis.pptx
International Journal of Engineering and Science Invention (IJESI)
Automated Information Retrieval Model Using FP Growth Based Fuzzy Particle Sw...
Improving initial generations in pso algorithm for transportation network des...
CS-438 COMPUTER SYSTEM MODELING WK5LEC9-10.pdf
Design of Digital Adder Using Reversible Logic
Design of Digital Adder Using Reversible Logic
Ad

Recently uploaded (20)

PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Sustainable Sites - Green Building Construction
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
Digital Logic Computer Design lecture notes
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Geodesy 1.pptx...............................................
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Sustainable Sites - Green Building Construction
Foundation to blockchain - A guide to Blockchain Tech
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Digital Logic Computer Design lecture notes
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Internet of Things (IOT) - A guide to understanding
Lecture Notes Electrical Wiring System Components
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Model Code of Practice - Construction Work - 21102022 .pdf
UNIT 4 Total Quality Management .pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
CH1 Production IntroductoryConcepts.pptx
Geodesy 1.pptx...............................................
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Ad

CS-438 WK13-15LEC25-30 Computer System Modeling.pdf

  • 1. CS-438 COMPUTER SYSTEMS MODELING Spring Semester 2024 Batch: 2020 (LECTURE # 25-30) FAKHRA AFTAB LECTURER DEPARTMENT OF COMPUTER & INFORMATION SYSTEMS ENGINEERING NED UNIVERSITY OF ENGINEERING & TECHNOLOGY
  • 2. PETRI NET-BASED PERFORMANCE MODELING Chapter # 6 Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 3. INTRODUCTION • Petri nets (PNs) provide a graphical tool as well as a notational method for the formal specification of systems. • The systems PNs model tend to include more than simply an arrival rate and a service rate. • Two important aspects in modeling the performance of computer systems (1) contention for resources and (2) synchronization between various concurrent activities. • The former aspect can be adequately represented by Queuing Network Modeling, but the later cannot. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 4. • Petri nets have long been used for modeling synchronization behavior of concurrent systems but not as completely as simulations. • They act more like simulations in that they allow the modeler to examine single entities within the system, as well as their movement and effect on the state of entire system. • Petri nets were first introduced in 1966 to describe concurrent systems. • This initial introduction was followed by continual improvements for example, • the addition of timing to transitions, • priority to transitions, • types to tokens, • and colors depicting conditions on places and tokens. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 5. GRAPHICAL REPRESENTATION • Petri nets are usually represented graphically according to the following conventions: • Places are represented by circles, • transitions by bars, • input function by arcs directed from places to transitions, • output function by arcs directed from transitions to places, and • markings by small filled circles called tokens. Fig 1: Basic Petri net components Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 6. Example Fig 2 illustrates a simple Petri net with only one place and one transition. • The former arc is input arc, while the later is an output arc. • The placement of a token represents the active marking of the Petri net state. • The Petri net shown in Fig 2 represents a net that will continue to cycle forever. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 2: Example perpetual motion Petri net
  • 7. REPRESENTATION USING SET NOTATION Using this notation, we can describe a PN as a 5-tuple, M= (P, T, I, O, MP) • where P is the set of places, P = {P1, P2, … ,Pn} • 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, • Here, Z+ denotes the set of all nonnegative integers, • I represents a bag of sets of input functions for all transitions, • I = {It1, It2, …, Itm}, mapping places to transitions, Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 8. • O represents a bag of sets of output functions for all transitions, • O = {Ot1, Ot2, ... ,Otm}, mapping transitions to places; and • MP represents the marking of places with tokens. • The initial marking is referred to as MPo. • MPo is represented as an ordered tuple of magnitude n, where n represents the number of places in our Petri net. • Each place will have either no tokens or some integer number of tokens. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 9. For example, the Petri net graph depicted in Fig 3 can be described using the previous notation as: • M = (P, T, I, O, MP) • P = {p1, p2, p3, p4, p5} • T = {t1, t2, t3, t4} • I(t1) = {p1} • I(t2) = {p2, p3, p5} • I(t3) = {p3} • I(t4) = {p4} • O(t1) = {p2, p3, p5} • O(t2) = {p5} • O(t3) = {p4} • O(t4) = {p2, p3} Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 3: Petri net example
  • 10. Dynamic Behaviour of Petri-Nets • The dynamic behavior of a Petri net is described by the sequence of transition firings. • The firing rules are as follows: Let t be a transition with incoming arcs from places ip1 ,...,ipK and outgoing arcs to places op1,...:opL for some K,L > 1. • Then t can fire if and only if each of the K input places contains at least one token. • As a result of firing, one token will be removed from each of the K input places, and one token will be added to each one of L output places. Fig 4: A Petri net (a) before firing and (b) after firing
  • 11. DUAL OF A PETRI-NET • The dual of a Petri net: transitions changed to places and places changed to transitions. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 5: Dual of Petri Net from Fig 3 Fig 3: Petri Net Example
  • 12. Inverse of Petri Net The inverse of a Petri net keeps all places and transitions the same and switches input functions with output functions. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 6: Inverse of Petri Net from Fig 3 Fig 3: Petri net example
  • 13. Petri Nets as Multi-graph Petri nets are defined also as multi-graphs, since a place can represent multiple inputs and/or outputs from or to a transition. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 7: Multipath arc Fig 8: Multipath arc as bold line
  • 14. State of a Petri Net • Petri nets have a state defined by the cardinality of tokens and their distribution throughout the places in the Petri net. • Marking represented as a function,  (or MP), as follows: : p → Z+ • The marking, , can also be defined as an n vector.  = (1 , 2 , 3, …, n) Where n = |P| and each i  Z+ , i = 0, …, n and (pi) = i. • Therefore, the true representation of a marked Petri net is: M= (P, T, I, O, t) where t represents state of Petri net at time t, where t Z+. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 15. • The number of tokens that may be assigned to a place is unbounded. • The marking for the Petri net shown in Fig 9 represented as a vector would be t= (1, 2, 0, 0, 1). Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 9: Marked Petri net
  • 16. Classical Petri Net • The classical PNs do not convey any notion of time. • The exact moment of firing can be pictured as occurring as a clock signal in a computer system. 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} Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 10: Enabled transition Fig 11: New Petri net state
  • 17. State Space • The collection of all possible states of a Petri net. • Next-state function,  applied to a Petri net state as follows:  (µi{t}) = µi+1 • The set {t} represents the set of all enabled transitions within this Petri net. • If a transition not enabled, then this function is undefined. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 18. Petri Nets and the Modeling of Computer Systems • PN used for modeling real systems sometimes referred to as Condition/Events nets. • 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. • The number of tokens in a place used to identify the number of resources lying in the condition denoted by that place. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 19. Concurrency (Parallelism) • In reliability modeling, the PN of Fig 12 can represent two components C1 and C2 in parallel redundancy. • p1 & p3 represent working condition, p2 & p4 the failed condition and t1 & t2 the event of failure of C1 & C2 respectively. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 12: PN modeling two parallel activities
  • 20. Synchronization • Both the routines of a parallel program should be terminated before the program execution can proceed. • The synchronization activity modeled in Fig 13 by means of t3 whose firing requires a token both in p2 and p4. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 13: PN modeling two parallel activities with synchronization
  • 21. Limited Resources Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 14: Block diagram and PN of a buffer with finite size. ➢ This is a typical factor influencing the performance of computer systems. ➢ A PN representation of a buffer with limited size.
  • 22. The Bounded Buffer Producer/Consumer Problem • A realistic situation is obtained by considering a buffer of limited capacity (Fig 15). Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 15: The producer/consumer problem with finite buffer
  • 23. Mutual Exclusion (Conflict) Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 16: The Mutual Exclusion Problem
  • 24. Logical Conditions • It is often desirable to model logical conditions. • e.g., to only fire a transition when there are more than n tokens in a place. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 17: Petri net component to test condition greater than M
  • 25. Inhibitor Arcs • The inhibition function usually represented by circle-headed arcs. • Modifies the enabling rules so that the transition fires only if pj does not contain tokens. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 18: Inhibitor Arc
  • 26. • To test for the condition of equal to some value but not greater than the value, we can use an inhibitor of arity n + 1 to block a transition if there are more than n tokens in place 0. • If we wish to test for less than n items and remove the items, we could use the Petri net shown in Fig 21. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 19: Petri net component to test condition equal but not greater than M Fig 20
  • 27. Modeling conflict and concurrency Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 21: Petri net modeling conflict and concurrency ➢ An initial marking, μ = (1,1,0,0,0), results in transitions t1 and t2 being enabled, the condition of concurrent transitions. ➢ If t1 fires first, then we have two transitions enabled, t2 and t3. This then depicts a conflict.
  • 28. Reachability in Petri-Nets • A Petri net state, µ, reachable from another state, µ', if there is an integer number of intermediate steps from µ' to µ. • e.g., µ0 = (3, 0, 0, 0), and a target state µ' = (1,0,0,1). • We can reach this target state in three firings of our net. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 22: Petri net indicating reachability
  • 29. Reversibility in Petri-Nets • It is the property where, given some initial state, we can return back to this state, µ, in finite time. • In Fig 23, µo, is not reversible, since we cannot get back to this state in a finite number of steps. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 23: Petri net K-bounded Petri-Net: • 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 states of the network. • For example, Fig 23 is a three- bounded net.
  • 30. Example Problem Consider the Petri-Net in Fig 23 with the initial state as µ’ = (0,1,0,2). Is it possible to return to this state after every few transitions ? If is that so, provide the number of transitions. Is the state reversible ? Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 23: Petri net
  • 31. Deadlocked Petri-net • A Petri net is deadlocked if there are no transitions in the net that are enabled. • Initial marking, µ0 = (0,0,2,0). • This marking results in no transitions being enabled. • Conversely, a Petri net is considered live if there are any transitions enabled. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 24: Deadlocked Petri-Net
  • 32. Properties of Petri Nets LIVENESS • A transition is live if it is potentially firable in any marking of R(M1). • A transition is dead in M if it is not potentially firable; if the PN enters marking M the dead transition cannot fire any more. SAFENESS • A place is safe if the token count does not exceed 1 in any marking of R(M1). • A PN is safe if each place is safe. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 33. Properties of Petri Nets (Cont’d) BOUNDEDNESS • A simple generalization of safeness. • A PN is k-bounded if each place is k-bounded. CONSERVATION • A PN is strictly conservative if the total number of tokens is constant in each marking of R(M1). Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 34. Example Problem 1 Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 25 Consider the Petri-Network in Fig 25. a)Provide the sets of places, transitions & initial marking. b)Provide the sets of all the input and output functions w.r.t the transitions given in the figure. c) Suppose at time T1, transition t1 is able to fire. What would be the marking M1? d) Identify M2, M3, M4 and M5 at times T2, T3 and T4.
  • 35. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Example Problem 2 t1 t2 P1 P4 P3 P2 t1 t2 P1 P4 P3 P2 t1 t2 P1 P4 P3 P2 t1 t2 P1 P4 P3 P2
  • 36. MATRIX ANALYSIS • The input and output functions of a PN can be equivalently defined using a matrix notation. • Let D- denotes the input matrix. D- is a (nt x np) matrix, whose generic element dij - is equal to the number of arcs connecting place pj with transition ti. • Similarly the output matrix D+ is a (nt x np) matrix, whose generic element dij + is equal to the number of arcs connecting transition ti with place pj. • The incidence matrix D is defined by the following relation: D = D+ - D- Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 37. Example Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Following are the matrices D-, D+ and D for the PN of Fig 26: Fig 26
  • 38. • Introducing the vector ej which is a nt-dimensional row vector with all the entries equal to 0 except entry j equal to 1. • With this notation the execution rules of a PN becomes: • a transition tj is enabled in marking M iff M ≥ ej D- (note that ej D- is the j-th row of D-); • firing of tj in M produces a marking M’ given by: M’ = M – ej D- + ej D+ = M + ej D • Given a PN with initial marking M1 and a firing sequence ti → tj → tk → tj → ti, the marking obtained at the end of the sequence is given by the following matrix equation: Mfin = M1 + (ei + ej + ek + ej + ei )D Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 39. Example Problem 3 Q) Consider the figure, find M’ if t3 is enabled to fire. Input or Pre-Incidence Matrix: D- = 1 1 1 0 0 0 0 1 0 0 1 0 Output or Post-Incidence Matrix: D- = 1 0 0 0 0 2 1 0 0 0 0 1 Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig P1 P3 P4 P2 t1 t3 t2 2
  • 40. Incidence Matrix: D = 0 −1 −1 0 0 2 1 −1 0 0 −1 1 Initial Marking: M0 = [1 0 1 0] From the Fig, t3 is enabled: ej = (0, 0, 1) Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) P1 P3 P4 P2 t1 t3 t2 Fig
  • 41. M’ = M + ej D M’ = 1 0 1 0 + 0 0 1 0 −1 −1 0 0 2 1 −1 0 0 −1 1 M’ = 1 0 0 1 Q) Let the firing sequence be: t3t2t3t2t1 ⟹ 𝑒𝑗 = 1 2 2 If M = 1 0 1 0 , M’ = 1 0 1 0 + 1 2 2 0 −1 −1 0 0 2 1 −1 0 0 −1 1 M’ = 1 3 0 0 Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 42. Timed Petri Nets • An activity in a real system takes finite time to perform its operation. • e.g., to read a file from a disk, to execute a program, or to communicate with some other machine. • Adding time provides Petri net modeler with another powerful tool to study the performance of computer systems. • Time can be associated with transitions, selection of paths, waiting in places, inhibitors, and with any other component of the Petri net. • The most typical way that time used in Petri nets is with transitions. • the firing of a transition can be viewed as the execution of an event being modeled – e.g., a CPU execution cycle. • These timed transitions are represented graphically as a rectangle or thick bars. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)
  • 43. The Semantics of the Firing • When a transition becomes enabled, its clock timer is set and begins to count down. • Once the timer reaches 0, the transition fires. • In Fig 27, when token arrives at pl, the timer for t1 set to 1 and begins to count down. • The decrement of the timer must be at a constant fixed speed for all transitions in the Petri net model. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 27: Timed Petri net
  • 44. • A consideration to think about • what occurs when a transition becomes non- enabled due to the initial enabling token being used to ultimately fire a competing transition. • This condition shown in Fig 28. • If we assume the time for t1 is less than that for t2, then, when p1 receives a token, the two timers would begin counting down. • At some time (1) in the future, the timer for t1 would reach its zero value, resulting in the firing of t1. • Since the token enabling t2 is now gone, t2 is no longer enabled and, therefore, its timer (2) would stop ticking down. • The question now is what to do with transition t2's timer. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET) Fig 28: Timed Petri net with conflict
  • 45. Two possibilities 1) The first is to simply reset the timer on the next cycle. • In this case, unless place p0 has a state where it has more than one token present, transition t2 will never fire. 2) Allow transition t2's timer to maintain the present clock timer value (2 - 1). • When the next token is received at pl, if the remaining time in t2's timer is less than t1's timer, then t2 will fire, leaving t1 with the remaining time (1 - (2- l)). The choice of which protocol to use will depend on the system one wishes to model. Prepared by: Ms. Fakhra Aftab (Lecturer, CISD, NEDUET)