200 likes | 400 Views
Bandera Intermediate Representation (BIR). Raivo Piirat LAP M. Bogor Modeling Language − BIR. Used to r epresent models of concurrent object-oriented systems Guarded command language when <condition> do <command> N ative support for a variety of object - oriented language features
E N D
Bandera Intermediate Representation (BIR) Raivo Piirat LAP M
Bogor Modeling Language − BIR • Used to representmodels of concurrent object-oriented systems • Guarded command language when <condition> do <command> • Native support for a variety of object-oriented language features dynamically created objects andthreads, exceptions, methods, inheritance, etc.
A BIR system: modeling 2-dining-philosophers system TwoDiningPhilosophers { boolean fork1;boolean fork2 ; activethread Philosopher1( ) { locloc0 : // take first fork when !fork1 do { fork1 := true ; } goto loc1; loc loc1: //takesecond fork when !fork2 do { fork2 := true ; } goto loc2; loc loc2 : / / put second fork do {fork2 := false ; }goto loc3; loc loc3 : // put first fork do { fork1 := false ; } goto loc0 ; } active thread Philosopher2( ) { loc loc0 : // takesecond fork when !fork2 do { fork2 := true ; } goto loc1 ; loc loc1 : // take first fork when !fork1 do { fork1 := true ; } goto loc2 ; loc loc2 : // put first fork do { fork1 := false ; } goto loc3 ; loc loc3 : // put second fork do {fork2 := false; } goto loc0 ; } }
BIR Execution • A BIR execution can be viewed assequence of atomic steps or transitionsbetween system states. • State holds allinformation that is necessary to carry oncomputation starting from a particularpoint in the system's execution • State consists of values of system variables and current control location (program counter) of each thread
Notation for BIR State • System State [pc1 -> 0, pc2 -> 2, fork1 -> false, fork2 -> true] pc for Philospher1 is loc0 pc for Philosopher2 is loc2 value of fork1 is ‘false’ value of fork2 is ‘true’ • sometimes we will abbreviate as… [0, 1, false, true] ...if the ordering of variable values is clearfrom the context
BIR Transition Notation • The notation represents the fact that thread t has executed a transition outof location l.
State Transition System • A state transition systemis a mathematical structurethat will allow us to reasonprecisely about the behaviorof simple concurrent systems. • Σ = (S,T,S0,L) …describes the behavior of a particular system S is a set of system states T is a set of transitions each transition δ is a relation between states S0 is a set of initial states L maps a state s to a set of primitive properties that are true of s.
Transitions as Relations/Functions • Formally, α is a subset of S x S, i.e., α is a relation between statesgiven an input state s, α (s)yields the statesoutput by the transition. • A transition is deterministicif for every state s there is at most one state s’ such that α(s, s’). When α is non-deterministic (i.e., when α can be viewed as a function from states tostates), we write s’ = α (s). • Example: loc loc1: // take second fork when !fork2 do { fork2 := true; }goto loc2;
Intra-Thread Non-determinism • Sometimes there can be more than one enabled transitionfor a particular thread loc loc0: when A do { x := x + 1 } goto loc1; when B do { y := y + 1 } goto loc2; when both A and B are true, one of thetransitionsleading out of loc0 is chosen non-deterministically
Enabled/Disabled Transitions • a transition α is enabledfor a state sif thereexists a state s’such that α( s) = s’ (i.e., α isdefinedon s) • a transition α is disabledfor a state sif α isundefined on s. • Notation for enabled/diabled enabled(s) - the set of transitions enabled at s enabled(s,t) - the set of transitions from thread t that are enabledat s disabled(s), disabled(s,t) - …similar to above pc(s,t) - the value in s of the program counter for t current(s), current(s,t) - the set of all transitions (whether enabled or disabled) associated with the current programcounters of s.