Modeling producer-consumer example using Petri Nets Neelam Gupta The University of Arizona Producer-consumer example write consume P 1 P 2 C C1 produce read separate nets for the subsystems read 0 read 1 write 2 write 2 Producer-consumer example consume C1 C2 read read one net for the entire system 0 1 2 write P1 produce write P2 Petri nets with priorities and Timed Petri nets Neelam Gupta The University of Arizona Extension 1 specifying priorities • A priority function pri from transitions to natural numbers: • pri: T ‡ N • When several transitions are enabled, only the ones with maximum priority are allowed to fire • Among those transitions that are allowed to fire at the same time, the one to fire is chosen non-deterministically Extension 2 Timed Petri nets • A pair of constants <tmin, tmax> is associated with each transition • Once a transition is enabled, it must wait for at least tmin to elapse before it can fire • If enabled, it must fire before tmax has elapsed, unless it is disabled by the firing of another transition before tmax Example: combining priorities and time P 1 P 2 T1 tmin = 1 tmax = 4 priority = 1 P 4 P 3 T2 tmin = 2 tmax = 3 priority = 3 T3 tmin = 0 tmax = 5 priority = 2 At t=0, i.e, when the above system begins to execute, all the transitions above are enabled. However, only T3 can fire at t=0. At t=1, transition T1 is also ready to fire. If T3 has not fired before t=1, then T1 cannot fire until T3 has fired, since T3 has higher priority than T1. If T3 does not fire till t=4, then T1 can never fire since T1 must fire before t=4. Example: combining priorities and time (cont.) P 1 P 2 T1 tmin = 1 tmax = 4 priority = 1 P 4 P 3 T2 tmin = 2 tmax = 3 priority = 3 T3 tmin = 0 tmax = 5 priority = 2 If T3 fires before t=1, T1 can fire at t=1 or anytime after t=1 but before t=2. This is because at t=2, T2 can fire and T2 has higher priority than T1, therefore it will prevent T1 from firing. If T1 fires before t=2, then T2 gets disabled and can never fire. Example: combining priorities and time (cont.) P 1 P 2 T1 tmin = 1 tmax = 4 priority = 1 P 4 P 3 T2 tmin = 2 tmax = 3 priority = 3 T3 tmin = 0 tmax = 5 priority = 2 If T2 fires before T1 fires, it disables T1. Therefore, T1 can never fire after T2 fires. If T3 does not fire before t=2, then it cannot fire till t=3 since T2 can fire at t=2 and T2 has higher priority than T3. If T2 fires before t=3, then T1 is disabled, but now T3 can fire anytime before t=5. After t=3, if T3 has not fired yet, it can fire anytime before t=5 irrespective of whether T2 has fired or not. Example: combining priorities and time (cont.) P 1 T1 tmin = 1 tmax = 4 priority = 1 P 4 P 3 P 2 T2 tmin = 2 tmax = 3 priority = 3 T3 tmin = 0 tmax = 5 priority = 2 In the example given in the textbook, P4 does not contain any token at t=0. The discussion in the book considers the case “if at time t=1, a token is produced into P4”. This assumes that P4 may be a part of a subsystem which can produce tokes into P4. This assumption results in discussion of many different situations, such as what if token in P4 appears at t=2, or at t=3 or at any other time? Therefore, in the example I have discussed in these slides, I have assumed the initial marking of the system in which T3 is enabled t=0.