Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ch5: Software Specification. 1 Petri Nets  Introduced by C. Adams Petri in 1960.  Widely used in the modeling and analysis of computer systems.  Basic.

Similar presentations


Presentation on theme: "Ch5: Software Specification. 1 Petri Nets  Introduced by C. Adams Petri in 1960.  Widely used in the modeling and analysis of computer systems.  Basic."— Presentation transcript:

1 Ch5: Software Specification

2 1 Petri Nets  Introduced by C. Adams Petri in 1960.  Widely used in the modeling and analysis of computer systems.  Basic elements:  Places  Transitions  Directed arcs  Tokens

3 2 Petri Nets Legend: Place Transition Directed arc P1 P2 P3 t1 Token

4 3 Petri Nets (contd..) P1 P2 P3 t1 Input place: Output place:

5 4 Petri Nets (contd..) P1 P2 P3 t1 2 Weighted connection: Default weight is 1.

6 5 Petri Nets (contd..)  Net structure:  Marking: Overall state.  Marked vs. Unmarked places: Places with zero or more tokens.  Local state vs. Global state: Number of tokens in a place, number of tokens in all places.

7 6 Petri Nets (contd..) P1 P2 P3 t1 Local State: P1 – 1 P2 – 0 P3 – 0 Overall State:

8 7 Petri Nets (contd..)  Dynamic behavior:  Firing of transitions  Transition firing:  Tokens from input place are moved to output place  Evolution of the net  Steps involved in firing of a transition

9 8 Petri Nets (contd..) Step #1 P1 P2 P3 t1 2

10 9 Petri Nets (contd..) P1 P2 P3 t1 2 Step 2

11 10 Petri Nets (contd..) P1 P2 P3 t1 2 Step 3:

12 11 Petri Nets (contd..)  Enabled transitions not forced to fire  Can be subject to external conditions  Ordinary Petri net, firing of transitions occurs instantly

13 12 Petri Nets (contd..) Machine Idle Loading Part Operation in Progress Unloading Part Robot Idle Petri Nets: Manufacturing Example Place represents availability of a resource.

14 13 Petri Nets (contd..) User & Candy User has coin Machine ready User has candy Machine busy eat reset Dispense candy

15 14 Petri nets (contd..)  Petri nets may be used to model concurrent systems  Concurrent transitions:  Petri nets are non-deterministic

16 15 Petri nets (contd..) P P P t t P t 1 3 1 3 4 6 5 P P P 2 5 7 t t t 2 4 6 Transitions t1 and t2 are both enabled. Any one of t1 and t2 can fire.

17 16 Petri nets (contd..) P P P t t P t 1 3 1 3 4 6 5 P P P 2 5 7 t t t 2 4 6 Before t1 firesAfter t1 fires Which transitions are enabled? P P P t t P t 1 3 1 3 4 6 5 P P P 2 5 7 t t t 2 4 6

18 17 Petri nets (contd..) Before t2 firesAfter t2 fires Which transitions are enabled? P P P t t P t 1 3 1 3 4 6 5 P P P 2 5 7 t t t 2 4 6 P P P t t P t 1 3 1 3 4 6 5 P P P 2 5 7 t t t 2 4 6

19 18 Petri nets (contd..) Before t1 & t2 fireFiring sequence t1,t2 t2,t1 P P P t t P t 1 3 1 3 4 6 5 P P P 2 5 7 t t t 2 4 6 P P P t t P t 1 3 1 3 4 6 5 P P P 2 5 7 t t t 2 4 6

20 19 Petri nets (contd..) Before t3 fires After t3 fires P P P t t P t 1 3 1 3 4 6 5 P P P 2 5 7 t t t 2 4 6 P P P t t P t 1 3 1 3 4 6 5 P P P 2 5 7 t t t 2 4 6

21 20 Petri nets (contd..) Before t4 fires After t4 fires P P P t t P t 1 3 1 3 4 6 5 P P P 2 5 7 t t t 2 4 6 P P P t t P t 1 3 1 3 4 6 5 P P P 2 5 7 t t t 2 4 6

22 21 Petri nets (contd..)  Transitions t3 and t4 were both enabled:  Conflict  A process may never get a resource (starvation)

23 22 Petri nets (contd..) How to avoid starvation

24 23 Petri nets (contd..) How to avoid starvation Transition t1 fires. Which transitions are enabled?

25 24 Petri nets (contd..) How to avoid starvation Transition t3 fires. Which transitions are enabled? P P P P P t t t t P P t t 1 1 2 3 4 5 6 7 4 2 3 6 5

26 25 Petri nets (contd..) How to avoid starvation Transition t5 fires. Which transitions are enabled?

27 26 Petri nets (contd..) How to avoid starvation Transition t2 fires. Which transitions are enabled? P P P P P t t t t P P t t 1 1 2 3 4 5 6 7 4 2 3 6 5

28 27 Petri nets (contd..)  Firing sequence: t1, t3, t5  Firing sequence: t2, t4, t6  The shared resource alternates between the two processes

29 28 Petri nets (contd..)  Deadlock:  Live:

30 29 Petri nets (contd..) Initial state of the net

31 30 Petri nets (contd..) Transition t1 fires

32 31 Petri nets (contd..) Transition t3’ fires R P P t t t' t" t t' t" t 1 1 3 3 2 2 4 4 5 6 22

33 32 Petri nets (contd..) Transition t2 fires

34 33 Petri nets (contd..) Transition t4’ fires No transition is enabled. The net is deadlocked. R P P t t t' t" t t' t" t 1 1 3 3 2 2 4 4 5 6 22

35 34 Petri nets (contd..) R P P t t t' t" t t' t" t 1 1 3 3 2 2 4 4 5 6 22 22 A deadlock free net

36 35 Petri nets: Limitations  Tokens are anonymous:  Cannot compute the value of a token  No selection policy to decide between different enabled transitions  Lack exact timing constraints

37 36 Petri nets: Limitations and extensions P channel1channel2 Token represents a message. Delivery channel depends on the contents. Correct message goes Through one channel, incorrect through the other one.

38 37 Petri nets: Limitations and extensions  Assign values to tokens  Predicates and functions can be associated with transitions   Firing of a transition implies:  Ready tokens consumed from input places  h new tokens produced by the function associated with the transition go to output places.

39 38 Petri nets: Limitations and extensions P P P P P 3 4 7 14 tt 1 2 4 5 1 2 3 Assigning values to tokens

40 39 Petri Net: Case Study Consider the process of producing a document in an organization. Each document is written by two technical writers, one technical writer is responsible for writing the text, while the other writer is responsible for drawing and inserting figures. When the technical writers complete their respective pieces, these pieces are merged into a single draft. This draft is then forwarded to the manager for review. Upon review the manager prints this draft using a printer. The printer is usually available except when it is offline for either maintenance or repair. Draw a Petri net model to represent the document production process.

41 40 Petri Nets: Case Study WrtTxt DrwFg DrwFgCmp WrtTxtCmp MrgDoc RvDoc PrDoc PrOn PrOff


Download ppt "Ch5: Software Specification. 1 Petri Nets  Introduced by C. Adams Petri in 1960.  Widely used in the modeling and analysis of computer systems.  Basic."

Similar presentations


Ads by Google