Overview MSCS " in menon " o P ✓ interpretation their that complicates 1 Lecture 2: Races \ definition \ formal - hating ' - algor . than \ output ' race ? has Msc a Joost-Pieter Katoen Theoretical Foundations of the UML 1/23
Theoretical Foundations of the UML Lecture 2: Races Joost-Pieter Katoen Lehrstuhl für Informatik 2 Software Modeling and Verification Group moves.rwth-aachen.de/teaching/ss-20/fuml/ April 21, 2020 Joost-Pieter Katoen Theoretical Foundations of the UML 2/23
Summary of Lecture # 1 Joost-Pieter Katoen Theoretical Foundations of the UML 3/23
Summary of Lecture # 1 1 A Message Sequence Chart is a partial order between send and receive events totally ordered per process vertical ordering receive events happen after their send events message ordering respecting the first-in first out (FIFO) property I p 4¥ > ez e , - ± : ez non Fito S 9 5 . < e p ez g , Joost-Pieter Katoen Theoretical Foundations of the UML 3/23
Summary of Lecture # 1 1 A Message Sequence Chart is a partial order between send and receive events totally ordered per process vertical ordering receive events happen after their send events message ordering respecting the first-in first out (FIFO) property 2 Linearizations are totally ordered extensions of partial orders all linearizations of an MSC are well-formed { every receive is preceded by a corresponding send 1 respects the FIFO ordering 2 no send events without corresponding receive 3 Joost-Pieter Katoen Theoretical Foundations of the UML 3/23
Summary of Lecture # 1 1 A Message Sequence Chart is a partial order between send and receive events totally ordered per process vertical ordering receive events happen after their send events message ordering respecting the first-in first out (FIFO) property 2 Linearizations are totally ordered extensions of partial orders all linearizations of an MSC are well-formed every receive is preceded by a corresponding send 1 respects the FIFO ordering 2 no send events without corresponding receive 3 Liners MIM → I 3 Every well-formed word can be transformed into an MSC two linearizations of the same MSC yield isomorphic MSCs Joost-Pieter Katoen Theoretical Foundations of the UML 3/23
Summary of Lecture # 1 1 A Message Sequence Chart is a partial order between send and receive events totally ordered per process vertical ordering receive events happen after their send events message ordering respecting the first-in first out (FIFO) property 2 Linearizations are totally ordered extensions of partial orders all linearizations of an MSC are well-formed every receive is preceded by a corresponding send 1 respects the FIFO ordering 2 no send events without corresponding receive 3 3 Every well-formed word can be transformed into an MSC two linearizations of the same MSC yield isomorphic MSCs C M ) kin - 4 So: there is a 1-to-1 relation between an MSC and its linearizations Joost-Pieter Katoen Theoretical Foundations of the UML 3/23
Example msc p 1 p 2 p 3 ele ) ! Cp , Be , a) a ' = , e e co • b , a) ? ( Pap Ice )= ' c , d e Joost-Pieter Katoen Theoretical Foundations of the UML 4/23
Example msc p 1 p 2 p 3 a b c d e These pictures are formalized using partial orders. Joost-Pieter Katoen Theoretical Foundations of the UML 4/23
Message Sequence Chart (MSC) (1) Definition An MSC M = ( P , E, C , l, m, � ) with: Joost-Pieter Katoen Theoretical Foundations of the UML 5/23
Message Sequence Chart (MSC) (1) Definition O An MSC M = ( P , E, C , l, m, � ) with: P , a finite set of processes { p 1 , p 2 , . . . , p n } Pi Pz Pn G T u Joost-Pieter Katoen Theoretical Foundations of the UML 5/23
Message Sequence Chart (MSC) (1) Definition An MSC M = ( P , E, C , l, m, � ) with: P , a finite set of processes { p 1 , p 2 , . . . , p n } E , a finite set of events � E p = E ? · E = ∪ E ! p ∈ P - - horizontally vertically Joost-Pieter Katoen Theoretical Foundations of the UML 5/23
Message Sequence Chart (MSC) (1) Definition An MSC M = ( P , E, C , l, m, � ) with: P , a finite set of processes { p 1 , p 2 , . . . , p n } E , a finite set of events � E p = E ? · E = ∪ E ! p ∈ P , b c a , ← - C , a finite set of message contents I . Joost-Pieter Katoen Theoretical Foundations of the UML 5/23
Message Sequence Chart (MSC) (1) Definition An MSC M = ( P , E, C , l, m, � ) with: P , a finite set of processes { p 1 , p 2 , . . . , p n } E , a finite set of events � E p = E ? · E = ∪ E ! p ∈ P C , a finite set of message contents l : E → Act , a labelling function defined by: � !( p, q, a ) if e ∈ E p ∩ E ! l ( e ) = , for p � = q ∈ P , a ∈ C ?( p, q, a ) if e ∈ E p ∩ E ? Joost-Pieter Katoen Theoretical Foundations of the UML 5/23
Message Sequence Chart (MSC) (2) Joost-Pieter Katoen Theoretical Foundations of the UML 6/23
Message Sequence Chart (MSC) (2) Definition m : E ! → E ? a bijection (“matching function”), satisfying: - - m ( e ) = e ′ ∧ l ( e ) = !( p, q, a ) implies l ( e ′ ) = ?( q, p, a ) ( p � = q, a ∈ C ) - - - µ.e meet ' e - , e Joost-Pieter Katoen Theoretical Foundations of the UML 6/23
Message Sequence Chart (MSC) (2) Definition m : E ! → E ? a bijection (“matching function”), satisfying: m ( e ) = e ′ ∧ l ( e ) = !( p, q, a ) implies l ( e ′ ) = ?( q, p, a ) ( p � = q, a ∈ C ) � ⊆ E × E is a partial order (“visual order”) defined by: * � � � ∗ ± � = C { ( e, m ( e )) | e ∈ E ! } < p ∪ p ∈ P - � �� � � �� � < p is a total order = “top-to- communication order < c bottom” order on process p where for relation R , R ∗ denotes its reflexive and transitive closure. Joost-Pieter Katoen Theoretical Foundations of the UML 6/23
es # Example a- r p → e , Eo • S m ( ez )=e ez , C es )=eg ea m . Hasse diagram < Cp es eco i p ← → to ④ eo → as Cs e , ez i t eg Crea Sr ez e i -3 , ! . - . Joost-Pieter Katoen Theoretical Foundations of the UML 7/23
Visual order can be misleading msc p 1 p 2 p 3 a b c Joost-Pieter Katoen Theoretical Foundations of the UML 8/23
Visual order can be misleading ez @ msc p 1 p 2 p 3 a e⑨ Eo - ⑨ ⑨ ⑨ e , o - f b S c a ) eh ! Cpa , p , , , b) ! C pups , b) ? ( pg , Pz If message b takes much shorter than message a , ! ( pg , c) then c might arrive at p 1 before a . , P , ! ( p , , C) 7 , Pz G a ) ! Cp , ,Pz , Joost-Pieter Katoen Theoretical Foundations of the UML 8/23
Visual order can be misleading msc p 1 p 2 p 3 a ez - E eb ez b I c possible EGO Ef occurs before e , If message b takes much shorter than message a , then c might arrive at p 1 before a . - In practice, e 6 might occur before e 2 , but e 2 < p 1 e 6 and thus e 2 � e 6 . - - - This is misleading and called a race. Joost-Pieter Katoen Theoretical Foundations of the UML 8/23
What is a race? A race condition asserts a particular order of events will occur because of the visual ordering (i.e., the partial order � ) when, in practice, this order cannot be guaranteed to hold. Joost-Pieter Katoen Theoretical Foundations of the UML 9/23
What is a race? A race condition asserts a particular order of events will occur because of the visual ordering (i.e., the partial order � ) when, in practice, this order cannot be guaranteed to hold. Q: When are race conditions possible and how to detect them? - input i what algorithm define - formally Msc m I ? is race a output : M or has race a not . Joost-Pieter Katoen Theoretical Foundations of the UML 9/23
Causal order - than different defined way in a MSC of the pot £ visual order → : definition . Joost-Pieter Katoen Theoretical Foundations of the UML 10/23
Causal order similar Main principles: y as ⑦ Send events should happen before their matching receive events ① The ordering of events wrt. sends on same process is una ff ected ③ Receive events on a process sent from the same process are ordered as their sends visual order ✓ Definition O For MSC M = ( P , E, C , l, m, � ) , relation � ⊆ E × E is defined by: - - - e ′ = m ( e ) ⑦ e � e ′ i ff ② e I - . ③ e og o ' e tea • e' • C o ' ease " e Joost-Pieter Katoen Theoretical Foundations of the UML 10/23
Causal order Main principles: Send events should happen before their matching receive events ② The ordering of events wrt. sends on same process is una ff ected Receive events on a process sent from the same process are ordered as their sends Definition For MSC M = ( P , E, C , l, m, � ) , relation � ⊆ E × E is defined by: e ′ = m ( e ) e � e ′ i ff - ② :* e < p e ′ and E ! ∩ { e, e ′ } � = ∅ or - - a . Joost-Pieter Katoen Theoretical Foundations of the UML 10/23
9- p r ' Ce ) a E- hi e a c- • b ' ( ' ) ' ' e e m • e ¢ ° thee because is e no that such process u ' ( " ) ' e ) - Ce su - m m ' ) ' ( at ' le ) and - as - occur m rn e different processes
Recommend
More recommend