matt b pedersen matthew sowders university of nevada las
play

Matt B. Pedersen & Matthew Sowders University of Nevada, Las - PowerPoint PPT Presentation

Matt B. Pedersen & Matthew Sowders University of Nevada, Las Vegas 1 Added mobile processes to ProcessJ With polymorphic interfaces Multiple interfaces to the same process Different set of formal parameters per interface


  1. Matt B. Pedersen & Matthew Sowders University of Nevada, Las Vegas 1

  2.  Added mobile processes to ProcessJ ◦ With polymorphic interfaces  Multiple interfaces to the same process  Different set of formal parameters per interface mobile void foo ( int x, int y) { � ... � while (...) { � ... � suspend resume with ( int z) � ... � } � } � 2

  3. mobile void foo ( int x, int y) { � ... � while (...) { � ... � suspend resume with ( int z) � ... � } � } �  foo has 2 interfaces ◦ ( int x, int y) � ◦ ( int z) �  When foo is started ( int x, int y) is used; subsequently ( int z) is used. 3

  4. MOBILE PROC reindelf (CHAN AGENT.INITIALIZE initialize?, � SHARED CHAN AGENT.MESSAGE report!, � SHARED CHAN INT santa.a!, santa.b!) � IMPLEMENTS AGENT � ... local state declarations � SEQ � ... in station compound (initialise local state) � WHILE TRUE � SEQ � ... in station compound � SUSPEND -- move to gathering place � ... in the gathering place � SUSPEND -- move to santa’s grotto � ... in santa’s grotto � SUSPEND -- move to compound � : � From: Santa Claus – with mobile reindeer and elves, CPA Fringe presentation 2008 � 4

  5. MOBILE PROC reindelf (CHAN AGENT.INITIALIZE initialize?, � SHARED CHAN AGENT.MESSAGE report!, � SHARED CHAN INT santa.a!, santa.b!) � IMPLEMENTS AGENT � ... local state declarations � These are all the same interface: SEQ � ... in station compound (initialise local state) � (CHAN AGENT.INITIALIZE initialize?, � WHILE TRUE � SHARED CHAN AGENT.MESSAGE report!, � SHARED CHAN INT santa.a!, santa.b!) � SEQ � ... in station compound � SUSPEND -- move to gathering place � ... in the gathering place � SUSPEND -- move to santa’s grotto � ... in santa’s grotto � SUSPEND -- move to compound � : � 5

  6. MOBILE PROC reindelf (CHAN AGENT.INITIALIZE initialize?, � SHARED CHAN AGENT.MESSAGE report!, � SHARED CHAN INT santa.a!, santa.b!) � IMPLEMENTS AGENT � ... local state declarations � SEQ � The Initialize channel is only used in ... in station compound (initialise local state) � WHILE TRUE � ... local state declaration � SEQ � ... in station compound � SUSPEND -- move to gathering place � Subsequent re-animations of reindelf must thus ... in the gathering place � provide ‘dummy’ values for this channel. � SUSPEND -- move to santa’s grotto � ... in santa’s grotto � SUSPEND -- move to compound � : � 6

  7.  Channel ends (or other parameters) not used in code following a resumption must still be passed ◦ A dummy reading end passed could cause deadlock if ever read. ◦ Made up actual parameter values must be passed to satisfy the compiler. Advertisement: Eric and Peter’s Call Channels (Fringe Talk) 7

  8.  What is the semantics of this? ◦ Parameters do not retain their values between invocations. mobile void foo ( int x, int y) { � B 1 � while (B 2 ) { � B 3 � suspend resume with ( int z) � B 4 � } � B 5 � } � x & y can be referenced in B 1 (first invocation); z in B 4 (subsequent invocations) 8

  9. mobile void foo ( int x, int y) { � B 1 � while (B 2 ) { � B 3 � suspend resume with ( int z) � B 4 � } � B 5 � } �  Example of execution of foo: foo(4,5); foo(4), foo(5), foo(7), ….  Only the first time (when foo is started) is the procedure interface used.  All other resumptions use the suspend/ resume interface. 9

  10. mobile void foo ( int x, int y) { � B 1 � while (B 2 ) { � B 3 � suspend resume with ( int z) � B 4 � } � B 5 � } � foo(x,y): B 1 , B 2 , B 5, done! foo(x,y): B 1 , B 2 , B 3 , suspend/foo(z): B 4 , B 2 , B 5 We see that e.g. B 2 (& B 5 ) can be executed ‘with’ both x & y as well as z . 10

  11. mobile void foo ( int x, int y) { � B 1 � while (B 2 ) { � B 3 � suspend resume with ( int z) � B 4 � } � B 5 � } � The first time B 2 is executed x seems to be ‘a valid parameter’, but the second time it does not; only z does. 11

  12.  Determine witch parameters can be referenced in all program blocks ◦ Create a control flow graph (CFG) based on the source ◦ Massage it a little ◦ Perform an analysis using In and Out sets (to be defines shortly) 12

  13. 13

  14. 14

  15. mobile void foo ( int x, int y) { � B 1 � while (B 2 ) { � I 0 B 1 B 3 � suspend resume with ( int z) � B 4 � } � B 5 � I 0 represents the original } � interface: B 2 foo ( int x, int y) � I 1 represents the resume B 3 I 1 B 4 B 5 interface: foo ( int z) � 15

  16. B 3 I 1 B 4 B 3 I 1 B 4 Interfaces are separated out and given their own nodes 16

  17. mobile void foo ( int x, int y) { � I 0 B 1 � while (B 2 ) { � B 3 � suspend resume with ( int z) � B 4 � B 1 } � B 5 � } � B 4 B 2 I 1 B 3 B 5 17

  18. I 0 {(x int I 0 ) (y int I 0 )} B 1 B 4 B 2 I 1 B 3 B 5 {(z int I 1 )} 18

  19. I 0 {(x int I 0 ) (y int I 0 )} B 1 B 4 B 2 I 1 B 3 B 5 {(z int I 1 )} 19

  20. I 0 {(x int I 0 ) (y int I 0 )} B 1 B 4 B 2 I 1 B 3 B 5 {(z int I 1 )} 20

  21.  Let us define In and Out sets (loosely): ◦ For interface nodes:  In Set: Not interesting as an interface defines a new set of parameters  Out Set: The set of parameters defined by the interface ◦ For Code nodes:  In Set: The set of parameters that can be referenced in the node (at least for the final generation of In set)  Out Set: a copy of the In set 21

  22.  Interface Nodes ◦ In 0 (I i ) = { } ◦ Out 0 (I i ) = {(n i,1 t i,1 I i ) … (n i,ki t i,ki I i )}  The Outset of an interface is the set of triples (name type interface) defined by it  Code Nodes ◦ In 0 (B j ) = { } ◦ Out 0 (B j ) = { } 22

  23. I 0 mobile void foo ( int x, int y) { � B 1 � while (B 2 ) { � B 3 � I 1 suspend resume with ( int z) � B 4 � } � B 5 � }  For Example ◦ Out 0 (I 0 ) = { ( x int I 0 ) ( y int I 0 ) } ◦ Out 0 (I 1 ) = { ( z int I 1 ) } 23

  24.  We generate generations of these sets until no sets change, after which we have the set of parameters that can be referenced for a node in its In set ◦ We start out with empty sets except for Out sets of interface nodes 24

  25. In(I 0 ) = { } I 0 Out(I 0 ) = {(x int I 0 ) (y int I 0 )} In(B 1 ) = { } B 1 Out(B 1 ) = { } In(B 4 ) = { } Out(B 4 ) = { } In(B 2 ) = { } B 4 B 2 Out(B 2 ) = { } In(B 5 ) = { } I 1 B 3 B 5 Out(B 5 ) = { } In(I 1 ) = { } In(B 3 ) = { } Out(I 1 ) = {(z int I 1 )} Out(B 3 ) = { } 25

  26.  In k+1 (I i ) = { } ◦ Interface nodes define a new interface, In sets can be ignored.  Out k+1 (I i ) = Out k (I i ) = {(n i,1 t i,1 I i ) … (n i,ki t i,ki I i )} ◦ Interface nodes always define the same interface. 26

  27.  In k+1 (B j ) = (N,B i ) ∈ E CFG Out k (N) ◦ New In set is the intersection of all the Out sets of the code node’s predecessors in the CFG  Out k+1 (B j ) = In k+1 (B j ) ◦ The Out set of a code node is the same as its In set, as it cannot define a new interface (Technically not needed but nice to have) 27

  28.  In k+1 (B j ) = (N,B i ) ∈ E CFG Out k (N) ◦ New In set is the intersection of all the Out sets of the code nodes predecessors in the CFG (n i t i I i ) == (n j t j I i ) <=> �  Out k+1 (B j ) = In k+1 (B j ) (n i == n j ) ∧ (t i == t j ) ◦ The Out set of a code node is the same as its In set, as it cannot define a new interface 28

  29. In(I 0 ) = { } I 0 Out(I 0 ) = {(x int I 0 ) (y int I 0 )} In(B 1 ) = {(x int I 0 ) (y int I 0 )} B 1 Out(B 1 ) = {(x int I 0 ) (y int I 0 )} In(B 4 ) = { } Out(B 4 ) = { } In(B 2 ) = { } B 4 B 2 Out(B 2 ) = { } In(B 5 ) = { } I 1 B 3 B 5 Out(B 5 ) = { } In(I 1 ) = { } In(B 3 ) = { } Out(I 1 ) = {(z int I 1 )} Out(B 3 ) = { } 29

  30. No Changes in B 2 since In(I 0 ) = { } I 0 In(B 2 ) = Out(B 1 ) Out(B 4 ) Out(I 0 ) = {(x int I 0 ) (y int I 0 )} = { } {(x int I 0 ) (y int I 0 )} In(B 1 ) = {(x int I 0 ) (y int I 0 )} B 1 Out(B 1 ) = {(x int I 0 ) (y int I 0 )} In(B 4 ) = { } Out(B 4 ) = { } In(B 2 ) = { } B 4 B 2 Out(B 2 ) = { } In(B 5 ) = { } I 1 B 3 B 5 Out(B 5 ) = { } In(I 1 ) = { } In(B 3 ) = { } Out(I 1 ) = {(z int I 1 )} Out(B 3 ) = { } 30

  31. In(I 0 ) = { } I 0 Out(I 0 ) = {(x int I 0 ) (y int I 0 )} In(B 1 ) = {(x int I 0 ) (y int I 0 )} B 1 Out(B 1 ) = {(x int I 0 ) (y int I 0 )} In(B 4 ) = { } Out(B 4 ) = { } In(B 2 ) = { } B 4 B 2 Out(B 2 ) = { } In(B 5 ) = { } I 1 B 3 B 5 Out(B 5 ) = { } In(I 1 ) = { } In(B 3 ) = { } Out(I 1 ) = {(z int I 1 )} Out(B 3 ) = { } 31

  32. In(I 0 ) = { } I 0 Out(I 0 ) = {(x int I 0 ) (y int I 0 )} In(B 1 ) = {(x int I 0 ) (y int I 0 )} B 1 Out(B 1 ) = {(x int I 0 ) (y int I 0 )} In(B 4 ) = {(z int I 1 )} Out(B 4 ) = {(z int I 1 )} In(B 2 ) = { } B 4 B 2 Out(B 2 ) = { } In(B 5 ) = { } I 1 B 3 B 5 Out(B 5 ) = { } In(I 1 ) = { } In(B 3 ) = { } Out(I 1 ) = {(z int I 1 )} Out(B 3 ) = { } 32

  33. In(I 0 ) = { } I 0 Out(I 0 ) = {(x int I 0 ) (y int I 0 )} In(B 1 ) = {(x int I 0 ) (y int I 0 )} B 1 In(B 4 ) = {(z int I 1 )} Out(B 1 ) = {(x int I 0 ) (y int I 0 )} Out(B 4 ) = {(z int I 1 )} In(B 2 ) = { } B 4 B 2 Out(B 2 ) = { } In(B 5 ) = { } I 1 B 3 B 5 Out(B 5 ) = { } In(I 1 ) = { } In(B 3 ) = { } Out(I 1 ) = {(z int I 1 )} Out(B 3 ) = { } 33

Recommend


More recommend