This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
**Unformatted text preview: **CS256/Winter 2007 — Lecture #09 Zohar Manna Chapter 2 Invariance: Applications 9-1 Parameterized Programs S : : ‘ : loop forever do ‘ 1 : noncritical ‘ 2 : request y ‘ 3 : critical ‘ 4 : release y P 3 : : [ local y : integer where y = 1; [ S || S || S ] ] (with some renaming of labels of the S ’s.) P 4 : : [ local y : integer where y = 1; [ S || S || S || S ] ] . . . P n : : ? 9-2 Mutual exclusion: P 3 : ( ¬ ( at- ‘ 3 ∧ at- m 3 ) ∧ ¬ ( at- ‘ 3 ∧ at k 3 ) ∧ ¬ ( at- m 3 ∧ at k 3 )) P 4 : ( ¬ ( . . . ) ∧ . . . ∧ ¬ ( . . . )) P n : ? We want to deal with these programs, i.e., programs with an arbitrary number of identical components , in a more uniform way. Solution: parametrization 9-3 Syntax Compound statements of variable size cooperation: M j =1 S [ j ] : [ S [1] || . . . || S [ M ] ] Selection: M OR j =1 S [ j ] : [ S [1] or . . . or S [ M ] ] S [ j ] is a parameterized statement . In what ways can j appear in S ? • explicit variable in expression . . . := j + . . . • explicit subscript in array x . . . := x [ j ] + . . . or x [ j ] := . . . • implicit subscript of all local variables in S [ j ] z stands for z [ j ] • implicit subscript of all labels in S [ j ] ‘ 3 stands for ‘ 3 [ j ] 9-4 Example: Program par-sum (Fig. 2.1) (parallel sum of squares) M ≥ 1 z = x [1] 2 + x [2] 2 + . . . + x [ M ] 2 9-5 Program par-sum-e (Fig. 2.2) (Explicit subscripted parameterized statements of par-sum ) We write the short version, but we reason about this one. 9-6 Parameterized transition systems The number M of processes is not fixed, so there is an unbounded number of transitions. To finitely represent these, we use parameterization of transition relations. Example: par-sum The unbounded number of transitions associated with ‘ are represented by a single transition relation using parameter j : ρ ‘ [ j ]: move ( ‘ [ j ] , ‘ 1 [ j ]) ∧ y [ j ] = x [ j ] ∧ pres ( { x, z } ) where j = 1 . . . M. 9-7 Array Operations Arrays (explicit or implicit) are treated as variables that range over functions: [1 . . . M ] 7→ integers Representation of array operations in transition relations: • Retrieval: y [ k ] to retrieve the value of the k th element of array y • Modification: update ( y, k, e ) the resulting array agrees with y on all i , i 6 = k , and y [ k ] = e 9-8 Properties of update update ( y, k, e )[ k ] = e update ( y, k, e )[ j ] = y [ j ] for j 6 = k Example: par-sum The proper representation of the transition relation for ‘ [ j ] is ρ [ j ]: move ( ‘ [ j ] , ‘ 1 [ j ]) ∧ y = update ( y, j, x [ j ]) ∧ pres ( { x, z } ) 9-9 Parameterized Programs: Specification Notation: • L i = { j | ‘ i [ j ] ∈ π } ⊆ { 1 , . . . , M } The set of indices of processes that currently reside at ‘ i • N i = | L i | The number of processes currently residing...

View
Full
Document