Presentation is loading. Please wait.

Presentation is loading. Please wait.

© SERG Software Design (Behavioral) Behavioral Design Topics in Behavioral Design Based on Material in [Rosenblum94][Budgen94] [Ghezzi91] [Harel88]

Similar presentations


Presentation on theme: "© SERG Software Design (Behavioral) Behavioral Design Topics in Behavioral Design Based on Material in [Rosenblum94][Budgen94] [Ghezzi91] [Harel88]"— Presentation transcript:

1 © SERG Software Design (Behavioral) Behavioral Design Topics in Behavioral Design Based on Material in [Rosenblum94][Budgen94] [Ghezzi91] [Harel88]

2 © SERG Software Design (Behavioral) Behavioral Design Topics State Transition Diagrams Petri Nets Higraphs and Statecharts

3 © SERG Software Design (Behavioral) State Transition Diagrams

4 © SERG Software Design (Behavioral) State Transition Diagrams (STD) Systems exist in a finite set of possible states. External events are triggers that lead to transitions between the states. Since most systems have many states, a partial model of the system may be a good compromise. STDs are the cornerstone of more powerful diagrams for specifying system behavior, such as Petri Nets and State Charts.

5 © SERG Software Design (Behavioral) Partial Unix vi STD o Line Command ZZ Text Insertion Mode Command Mode / : return ESC i l

6 © SERG Software Design (Behavioral) Formal Definition of an STD

7 © SERG Software Design (Behavioral) Combination Safe STD Safe Locked1/3 Unlocked Safe Unlocked 2/3 Unlocked 1L2L3R Sound Alarm any other dial movement any other dial movement any other dial movement

8 © SERG Software Design (Behavioral) IDE STD Compiling events no events hiccup Running Start resume pause stop finished success Compiled error stop run Executing Pausing

9 © SERG Software Design (Behavioral) Petri Nets

10 © SERG Software Design (Behavioral) A Simple Petri Net P1P2t1t2 t3P3 P4

11 © SERG Software Design (Behavioral) A Marked Petri Net P1P2t1t2 t3P3 P4

12 © SERG Software Design (Behavioral) A Marked Petri Net After Firing t1 P1P2t1t2 t3P3 P4

13 © SERG Software Design (Behavioral) Definition of a Petri Net PNet = (P, T, A, M0) –P is a finite set of places (labeled circles), where a place holds tokens. –T is a finite set of transitions (bars), where a transition represents an activity. –A is a finite set of directed arcs, where an arc connects a place and a transition. –M0 is the initial marking of PNet, where a marking is an arrangement of tokens in places representing state.

14 © SERG Software Design (Behavioral) Petri Net Execution Model Input Place: Place P is an input place for transition T if there is an arc from P to T. Output Place: Place P is an output place for transition T if there is an arc from T to P. Enabled Transition: A transition is enabled if there is at least one token at each of its input places.

15 © SERG Software Design (Behavioral) Petri Net Execution Model (Cont’d) Firing a Transition: An enabled transition is non deterministically selected and fired by removing one token from each of its input places and depositing one token at each of its output places. Firing Sequence: A firing sequence such that t0 is enabled and fired in M0, t1 is enabled and fired in M1,...

16 © SERG Software Design (Behavioral) Petri Net Firing

17 © SERG Software Design (Behavioral) A Petri Net Describing an ATM Machine Ready Valid Card Correct Pin Card Accepted Valid Request Sufficient Funds Sufficient ATM Cash Card in Slot Notes in Dispenser

18 © SERG Software Design (Behavioral) A Marked Petri Net Semaphore IN1IN2 CR1CR2 SEM OUT1OUT2 IN = Input of Process OUT = Output of Process CR = Critical Region SEM = Semaphore

19 © SERG Software Design (Behavioral) Enabled Transitions IN1 IN2 CR1 CR2 SEM OUT1OUT2

20 © SERG Software Design (Behavioral) After Non-Deterministic Firing IN1IN2 CR1 CR2 SEM OUT1OUT2

21 © SERG Software Design (Behavioral) Enabled Transition IN1 IN2 CR1CR2 SEM OUT1OUT2

22 © SERG Software Design (Behavioral) After Firing IN1 IN2 CR1 CR2 SEM OUT1OUT2

23 © SERG Software Design (Behavioral) Petri Net Static Analysis Invariants are properties of a Petri net that hold (are true) in all markings. For example, the sum of all tokens in CR1, CR2, and SEM are equal to 1 in all reachable markings. That is, |CR1| + |CR2| + |SEM| = 1

24 © SERG Software Design (Behavioral) Deadlock and Starvation A Petri Net with a given marking is in deadlock iff no transition is enabled in that marking. A Petri Net with a given marking is in starvation iff one or more transitions have been permanently disabled. A Petri Net is live if every transition can eventually be fired.

25 © SERG Software Design (Behavioral) A Deadlocked Petri Net

26 © SERG Software Design (Behavioral) A Petri Net that can Enter a Deadlocked State

27 © SERG Software Design (Behavioral) A Deadlocked Petri Net

28 © SERG Software Design (Behavioral) Modification into a Live Petri Net

29 © SERG Software Design (Behavioral) A Petri Net that can go into Starvation t1t2 t3 t4

30 © SERG Software Design (Behavioral) Starving Transitions t2 and t4 t1t2 t3 t4

31 © SERG Software Design (Behavioral) Shortcoming of Basic Petri Nets The Simplicity of building blocks leads to complexity in nets. For example, a semaphore of N processes requires 2N transitions and 3N+1 places. Would like: –Enable and fire as computations. –Tokens as data, not just control. –Ability to reduce high-level Petri nets to basic Petri nets for analysis.

32 © SERG Software Design (Behavioral) Higher-Level Net Semaphore 19 71 transition predicate true 3 token value s > 0 arc expression s+1 p p p s-1 s s p

33 © SERG Software Design (Behavioral) Enabled Transition 19 71 transition predicate true 3 token value s > 0 arc expression s+1 p p p s-1 s s p

34 © SERG Software Design (Behavioral) After Firing 19 71 transition predicate true 2 token value s > 0 arc expression s+1 p p p s-1 s s p

35 © SERG Software Design (Behavioral) Enabled Transitions 19 71 transition predicate true 2 token value s > 0 arc expression s+1 p p p s-1 s s p

36 © SERG Software Design (Behavioral) After Firing 19 71 transition predicate true 1 token value s > 0 arc expression s+1 p p p s-1 s s p

37 © SERG Software Design (Behavioral) Enabled Transition 19 71 transition predicate true 1 token value s > 0 arc expression s+1 p p p s-1 s s p

38 © SERG Software Design (Behavioral) After Firing 19 71 transition predicate true 2 token value s > 0 arc expression s+1 p p p s-1 s s p

39 © SERG Software Design (Behavioral) A Software Change Process 19 7 33 8 11 New MRs (MR) true Tom Maria Tony Olga Approved MRs Assigned MRsCompleted MRs (MR) (MR, Developer) (MR, Developer) (MR, Developer) (Developer) (MR, Developer)

40 © SERG Software Design (Behavioral) After Firing (New Assigned MR) 1933 8 11 New MRs (MR) true 7,Tom Maria Tony Olga Approved MRs Assigned MRsCompleted MRs (MR) (MR, Developer) (MR, Developer) (MR, Developer) (Developer) (MR, Developer)

41 © SERG Software Design (Behavioral) After Firing (New Assigned MR) 1933 11 New MRs (MR) true 7,Tom Maria Tony 8,Olga Approved MRs Assigned MRsCompleted MRs (MR) (MR, Developer) (MR, Developer) (MR, Developer) (Developer) (MR, Developer)

42 © SERG Software Design (Behavioral) After Firing (New Completed MR) 1933 11 New MRs (MR) true 7,Tom Maria Tony 8,Olga Approved MRs Assigned MRsCompleted MRs (MR) (MR, Developer) (MR, Developer) (MR, Developer) (Developer) (MR, Developer)

43 © SERG Software Design (Behavioral) After Firing (New Assigned MR) 1933 New MRs (MR) true 7,Tom Maria 11,Tony 8,Olga Approved MRs Assigned MRsCompleted MRs (MR) (MR, Developer) (MR, Developer) (MR, Developer) (Developer) (MR, Developer)

44 © SERG Software Design (Behavioral) After Firing (New Approved MR) 1933 New MRs (MR) true 7,Tom Maria 11,Tony Olga Approved MRs Assigned MRsCompleted MRs (MR) (MR, Developer) (MR, Developer) (MR, Developer) (Developer) (MR, Developer) 8

45 © SERG Software Design (Behavioral) Higraphs and Statecharts

46 © SERG Software Design (Behavioral) Higraphs Higraphs are based on: –Euler graphs –hypergraphs –Venn diagrams Graph Hypergraph QR P Q^R P^Q^R P^QP^R

47 © SERG Software Design (Behavioral) E Higraphs Supports Cartesian Products. B A O P T S R D J H I G F L M N K Q C

48 © SERG Software Design (Behavioral) Formal Definition of a Higraph

49 © SERG Software Design (Behavioral) Specialized Higraphs: State Charts State Charts are a higraph-based extension of standard state-transition diagrams, where blobs represent states and arrows represent transitions. State Charts = state diagrams + depth + orthogonality + broadcast communication

50 © SERG Software Design (Behavioral) Depth of State Charts e, f, g, h: events that trigger the transitions g(c): is the transition by event g when condition c is true. Being in state D means being in one of states A or C. The f arrow leaving D applies to both A and C. A is the default state. C is the default state when in D. g(c) A B C f f e h A C f B e h D

51 © SERG Software Design (Behavioral) F Orthogonality of State Charts Y B C H E G I AD e f [in{G}] n e g h k em p C,G B,E C,F C,E B,G B,F HI k h e n k p m or p ef e p g g e h e

52 © SERG Software Design (Behavioral) Broadcasting of State Charts Y A H D B C E G F k e n f/g g e IJ n/f m/e

53 © SERG Software Design (Behavioral) in flight State Chart Describing ATC cruising stacked landing approach on ground touch down take off taxiing parked

54 © SERG Software Design (Behavioral) CPU Main Memory State Chart Describing a Computer Computer Fetching Instruction Execution Instruction Waiting for Request Memory Write Cycle Memory Read Cycle getAddrputAddr instr. cmpl. instr. avail. Put Addr. Get Addr. Data Written Data Read

55 © SERG Software Design (Behavioral) Display State of Digital Watch displays update hour min date sec c c c c time date alarm stopwatch c b d d a a a up-alarm c hoursec min b c 2-min [not in(stopwatch)]

56 © SERG Software Design (Behavioral) Stopwatch State of Digital Watch time a disp run zero reg lapoff on d [in(off)] b b d [in(on)] dbb stopwatch

57 © SERG Software Design (Behavioral) High-Level Description of Digital Watch dead alive main power displays beep beep-rt t-hits-tm [in(enable)] weakstrong bt-weak onoff b b-up enable disable alarm-state d[in(alarm)] light

58 © SERG Software Design (Behavioral) State Chart of Digital Watch alarm-state dead alive hour min date sec c c c c time date alarm c b d d a a up-alarm c hour sec min b c disp run zero reg lapoff on d b b d dbb stopwatch beep beep-rt t-hits-tm [in(enable)] update displays main 2-min [not in(stopwatch)] bat-in bat-rn weak strong power bt-weak onoff b b-up light disable enable d[in(alarm)]

59 © SERG Software Design (Behavioral) References [Rosenblum94] D. Rosenblum, A. L. Wolf, Formal Software Engineering, Tutorial SIGSOFT’94 FSE, New Orleans, Dec., 1994. [Budgen94] D. Budgen, Software Design, Addison- Wesley, 1994. [Ghezzi91] C. Ghezzi, M. Jazayeri, D. Mandrioli, Fundamentals of Software Engineering, Prentice-Hall, 1991. [Harel88] D. Harel, On Visual Formalisms, CACM, Vol. 31, No. 5, 1988.


Download ppt "© SERG Software Design (Behavioral) Behavioral Design Topics in Behavioral Design Based on Material in [Rosenblum94][Budgen94] [Ghezzi91] [Harel88]"

Similar presentations


Ads by Google