Modeling Concurrent Systems Hao Zheng Department of Computer Science and Engineering University of South Florida Tampa, FL 33620 Email: haozheng@usf.edu Phone: (813)974-4757 Fax: (813)974-5456 Hao Zheng (CSE, USF) Comp Sys Verification 1 / 57
Overview Modeling Formalisms 1 Transition Systems Modeling HW Modeling SW Parallel Composition 2 Composing Independent Processes Composing Concurrent Processes: Shared Variables Composing Concurrent Processes: Handshaking Synchronous Composition Understanding State Space Explosion 3 Hao Zheng (CSE, USF) Comp Sys Verification 2 / 57
Reading Principle of Model Checking, Chapter 2 Hao Zheng (CSE, USF) Comp Sys Verification 3 / 57
Contents Modeling Formalisms 1 Transition Systems Modeling HW Modeling SW Parallel Composition 2 Composing Independent Processes Composing Concurrent Processes: Shared Variables Composing Concurrent Processes: Handshaking Synchronous Composition Understanding State Space Explosion 3 Hao Zheng (CSE, USF) Comp Sys Verification 4 / 57
2.1 Transition Systems Transition system is a common semantic model to describe computation/communcation in HW/SW systems. Definition 2.1 Transition Systems A transition system TS is a tuple � S , Act , − → , I , AP , L � where: • S is a set of states. • Act is a set of actions. α → s ′ ). • − →⊆ S × Act × S is a transition relation (denoted s − • I ⊆ S is a set of initial states. • AP is a set of atomic propositions. • L : S → 2 AP is a labeling function. • Note that S and Act can be finite or countably infinite. Hao Zheng (CSE, USF) Comp Sys Verification 5 / 57
Example 2.2 Beverage Vending Machine pay get_soda get_beer insert_coin τ soda select beer τ • S = { pay , select , soda , beer } • Act = { insert_coin , get_soda , get_beer , τ } • I = { pay } • AP = S • L ( s ) = { s } Hao Zheng (CSE, USF) Comp Sys Verification 6 / 57
Example 2.2 Beverage Vending Machine pay get_soda get_beer insert_coin τ soda select beer τ • S = { pay , select , soda , beer } • Act = { insert_coin , get_soda , get_beer , τ } • I = { pay } • AP = { paid , drink } • L ( pay ) = / 0 , L ( select ) = { paid } , L ( soda ) = L ( beer ) = { paid, drink } Hao Zheng (CSE, USF) Comp Sys Verification 6 / 57
The Role of Nondeterminism • Used to model concurrency by interleaving. • No assumption about the relative speed of processes. • Used to model implementation freedom. • Only describes what a system should do, not how. • Used to model under-specified systems, or abstractions of real systems. • Use incomplete information. Hao Zheng (CSE, USF) Comp Sys Verification 7 / 57
Definition 2.3 Direct Successors and Predecessors � → s ′ � s ′ ∈ S | s α � Post ( s , α ) = − Post ( s ) = Post ( s , α ) , α ∈ Act � � s ′ ∈ S | s ′ α � Pre ( s , α ) = → s − Pre ( s ) = Pre ( s , α ) . , α ∈ Act � � Post ( C , α ) = Post ( s , α ) , Post ( C ) = Post ( s ) for C ⊆ S . s ∈ C s ∈ C � � Pre ( C , α ) = Pre ( s , α ) , Pre ( C ) = Pre ( s ) for C ⊆ S . s ∈ C s ∈ C Definition 2.4 Terminal State State s is called terminal if and only if Post ( s ) = / 0 . Hao Zheng (CSE, USF) Comp Sys Verification 8 / 57
Successors and Predecessors: Example pay get_soda get_beer insert_coin τ soda select beer τ • Post ( pay , insert_coin ) = { select } • Pre ( pay , get_soda ) = { soda } • Pre ( pay ) = { soda , beer } Hao Zheng (CSE, USF) Comp Sys Verification 9 / 57
Definition 2.5 Deterministic Transition Systems • Transition system TS = ( S , Act , → , I , AP , L ) is action-deterministic iff: | I | ≤ 1 | Post ( s , α ) | ≤ 1 for all s , α and • No more than 2 successor states due to the same action • Transition system TS = ( S , Act , → , I , AP , L ) is AP-deterministic iff: | I | ≤ 1 and | Post ( s ) ∩ { s ′ ∈ S | L ( s ′ ) = A } for all s , A ∈ 2 AP | ≤ 1 � �� � equally labeled successors of s • No more than 2 successor states of same labeling Hao Zheng (CSE, USF) Comp Sys Verification 10 / 57
Deterministic Transition Systems: Example pay get_soda get_beer insert_coin τ soda select beer τ • Is this TS action-deterministic? Hao Zheng (CSE, USF) Comp Sys Verification 11 / 57
2.1.1 Executions • An execution (run) is a linear sequence of state transitions. • Used to describe dynamic behavior of transition systems. Definition 2.6 Execution Fragments • A finite execution fragment ρ of TS is an alternating sequence of states and actions ending with a state: α i + 1 ρ = s 0 α 1 s 1 α 2 ... α n s n such that s i − − → s i + 1 for all 0 ≤ i < n . • An infinite execution fragment ρ of TS is an infinite, alternating sequence of states and actions: α i + 1 ρ = s 0 α 1 s 1 α 2 s 2 α 3 ... such that s i − − → s i + 1 for all 0 ≤ i . Hao Zheng (CSE, USF) Comp Sys Verification 12 / 57
2.1.1 Executions Definition 2.7 Maximal and Initial Execution An execution of TS is an initial , maximal execution fragment • An execution fragment is initial if s 0 ∈ I . • A maximal execution fragment can be finite, ending in a terminal state, or infinite. Definition 2.9 Executions An execution of transition system TS is an initial, maximal execution fragment. Hao Zheng (CSE, USF) Comp Sys Verification 13 / 57
Example 2.8 Executions of the Vending Machine → select τ sget → select τ sget pay coin → pay coin ρ 1 = − − → soda − − − − − − → soda − − → ... sget bget select τ → pay coin → select τ ρ 2 = − → soda − − − − → beer − − − → ... → select τ sget → select τ pay coin → pay coin ρ 3 = − − → soda − − − − − − → soda • Which execution fragments are initial? Hao Zheng (CSE, USF) Comp Sys Verification 14 / 57
Example 2.8 Executions of the Vending Machine pay coin → select τ sget → pay coin → select τ sget ρ 1 = − − − → soda − − − − − → soda − − → ... select τ sget → select τ bget → pay coin ρ 2 = − → soda − − − − → beer − − − → ... pay coin → select τ sget → pay coin → select τ ρ 3 = − − → soda − − − − − − → soda • Which execution fragments are initial? ρ 1 and ρ 3 Hao Zheng (CSE, USF) Comp Sys Verification 14 / 57
Example 2.8 Executions of the Vending Machine → select τ sget → select τ sget pay coin → pay coin ρ 1 = − − − → soda − − − − − → soda − − → ... sget bget select τ → pay coin → select τ ρ 2 = → soda − − − − − − → beer − − → ... → select τ sget → select τ pay coin → pay coin ρ 3 = − − → soda − − − − − − → soda • Which execution fragments are initial? ρ 1 and ρ 3 • Which execution fragments are maximal? Hao Zheng (CSE, USF) Comp Sys Verification 14 / 57
Example 2.8 Executions of the Vending Machine pay coin → select τ sget → pay coin → select τ sget ρ 1 = − − → soda − − − − − − → soda − − → ... select τ sget → select τ bget → pay coin ρ 2 = → soda − − − − − − → beer − − → ... → select τ sget → select τ pay coin → pay coin ρ 3 = − − → soda − − − − − − → soda • Which execution fragments are initial? ρ 1 and ρ 3 • Which execution fragments are maximal? ρ 1 and ρ 2 Hao Zheng (CSE, USF) Comp Sys Verification 14 / 57
Example 2.8 Executions of the Vending Machine → select τ sget → select τ sget pay coin → pay coin ρ 1 = − − − → soda − − − − − → soda − − → ... sget bget select τ → pay coin → select τ ρ 2 = → soda − − − − − − → beer − − → ... → select τ sget → select τ pay coin → pay coin ρ 3 = − − → soda − − − − − − → soda • Which execution fragments are initial? ρ 1 and ρ 3 • Which execution fragments are maximal? ρ 1 and ρ 2 • Which execution fragments are “executions”? Hao Zheng (CSE, USF) Comp Sys Verification 14 / 57
Example 2.8 Executions of the Vending Machine pay coin → select τ sget → pay coin → select τ sget ρ 1 = − − → soda − − − − − − → soda − − → ... select τ sget → select τ bget → pay coin ρ 2 = → soda − − − − − − → beer − − → ... → select τ sget → select τ pay coin → pay coin ρ 3 = − − − → soda − − − − − → soda • Which execution fragments are initial? ρ 1 and ρ 3 • Which execution fragments are maximal? ρ 1 and ρ 2 • Which execution fragments are “executions”? ρ 1 Hao Zheng (CSE, USF) Comp Sys Verification 14 / 57
Executions: Another Example pay get_soda get_beer insert_coin τ soda select beer τ open open open error • An execution ρ 4 = pay insert_coin open − − − − − − − → select − − → error Hao Zheng (CSE, USF) Comp Sys Verification 15 / 57
Recommend
More recommend