180 likes | 420 Views
Talen & Correctheid - 2004-2005 Inleiding tot Reeks 6. Petri Nets. Pieter Van Gorp Formal Techniques in Software Engineering Pieter.VanGorp@ua.ac.be. Animations from http://www.csse.monash.edu.au/courseware/cse5510/Lectures/lecture2b.ppt by Chris Ling, CSSE. Static Structure.
E N D
Talen & Correctheid - 2004-2005 Inleiding tot Reeks 6 Petri Nets Pieter Van Gorp Formal Techniques in Software Engineering Pieter.VanGorp@ua.ac.be Animations from http://www.csse.monash.edu.au/courseware/cse5510/Lectures/lecture2b.pptby Chris Ling, CSSE.
Static Structure • Places (circles) possible states of the system • Tokens (bullets) e.g. active state • Transitions (rectangles) events or actions which cause the change of state • Arcs (arrows) connects a place with a transition or a transition with a place
e2 e3 e1 e3 e2 e1 e5 e4 Dynamic Behavior • “Firing of State Transitions” • Condition: Availability of Tokens • State is Enabled • Effect: Tokens move from Input to Output Places • Meaning: Event occurs (+ Actions)
e1 e2 e3 e4 Concurrency Issues • Non-deterministic Concurrency
e1 Concurrency Issues • Synchronization
2 Fast 2 Petri Nets http://402streetrace.com/ Starter Car A Car B Conditions P1: Car A, preparing for start P10: Car B, preparing for start --- P2: Car A, Waiting for start P11: Car B, Waiting for start --- P4: Car A, Ready Sign P8: Car B, Ready Sign --- P6: Starter, waiting for Ready Signs --- P7: Starter, Start Sign given --- P5: Car A, See Start Sign P9: Car B, See Start Sign --- P3: Car A, Racing P12: Car B, Racing Actions T1: Car A, Send Ready Sign T4: Car B, Send Ready Sign --- T3: Starter, Give Start Sign --- T2: Car A, Start Racing T5: Car B, Start Racing
Nondeterministic Concurrency “Stap”, cursus p. 103
Sharing Resources: MUTEX • Junction of 2 roads into 1: • First come, first serve… who decides? 1. Golf, from Road A 2. Focus, from Road B 3. Golf, gets Road C first
A safe Racing Circuit MUTEX RETRIEVE MUTEX RELEASE
Waiter free Customer 1 Customer 2 Take order Take order wait Order taken wait eating eating Tell kitchen Serve food Serve food Example: Restaurant (scenario 1)
Waiter free Customer 1 Customer 2 Take order Take order wait Order taken wait eating eating Tell kitchen Serve food Serve food Example: Restaurant (scenario 2)
t1 t3 t5 t8 t2 t6 M0 M1 M2 M3 M0 M2 M4 A marking is a concrete state ... t8 p4 M0 = (1,0,0,0,0) t4 M1 = (0,1,0,0,0) p2 t1 M2 = (0,0,1,0,0) M3 = (0,0,0,1,0) p1 M4 = (0,0,0,0,1) t3 t7 t5 Initial marking:M0 t6 p5 t2 “Firing Sequence” p3 t9
t1 t3 t5 t8 t2 t6 M0 M1 M2 M3 M0 M2 M4 Reachability & Liveness • “M2 is reachable from M1 • M4 is reachable from M0.” • … • In this example, all markings are reachable from every marking • A Petri net with initial marking M0 is live if, no matter what marking has been reached from M0, it is possible to ultimately fire any transition by progressing through some further firing sequence. • A transition is dead if it can never be fired in any firing sequence.
An non-live Petri Net example t1 p3 t3 t4 p2 p1 p4 t2 M0 = (1,0,0,1) M1 = (0,1,0,1) M2 = (0,0,1,0) M3 = (0,0,0,1)
Boundedness • A Petri net is said to be k-bounded or simply bounded if the number of tokens in each place does not exceed a finite number kfor any marking reachable from M0. • C/E systems are 1-bounded.
M0 = (1, 0, 0, 0, 0) M1 = (0, 1, 1, 0, 0) M2 = (0, 0, 0, 1, 1) M3 = (1, 1, 0, 0, 0) M4 = (0, 2, 1, 0, 0) Boundedness Example p1 t1 p2 p3 t2 t3 p4 p5 t4 An unbounded but live Petri net