slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Erich Laube Presentation based on A Language with Distributed Scope by Luca Cardelli PowerPoint Presentation
Download Presentation
Erich Laube Presentation based on A Language with Distributed Scope by Luca Cardelli

Loading in 2 Seconds...

play fullscreen
1 / 19

Erich Laube Presentation based on A Language with Distributed Scope by Luca Cardelli

108 Vues Download Presentation
Télécharger la présentation

Erich Laube Presentation based on A Language with Distributed Scope by Luca Cardelli

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Erich Laube Presentation based on A Language with Distributed Scope by Luca Cardelli

  2. Problems with Passing References • losing contexts • losing structure of data • for example: what is 0xa500 at Site 2? Site 1 Site 2 C.f(Obj B) Obj A Obj C 0xa500 0xa500 ??? Obj B

  3. 4 Lexical vs. Dynamic Scoping • Lexical: free variables bound at compile time. • Dynamic: free variables bound at run time. int y = 3; int f(int x) { return x+y; } int g(int y) { return f(2); } main(){ print(g(4)); } output: g(4) = (y=4 && f(2)) lexical scoping: f(2) = 2+y = 2+y = 2+3 = 5 dynamic scoping: f(2) = 2+y = 2+y = 2+4 = 6

  4. Site 1 Site 2 C.f(Obj B) Obj A Obj C Obj B Distributed Lexical Scoping • Lexical Scoping in Distributed Context: • identifiers are bound to their original site • transmitted objects keep their bindings

  5. Obliq: Overview • Distributed Lexical Scoping • Interpreted • Untyped • Built on top of Modula3 Network Objects • Object Oriented • Garbage Collection

  6. Obliq Objects • “Prototypical Approach” • have a state • are local to a site • example: o => { x => 3, foo => meth(a,b) b end, z => alias y of o2 end }

  7. Encoding Inheritance • Inheritance: o1 => { var i; ... } o2 => { clone(o1); var j; ... } Class A{ int i; ... } Class B extends A{ int j; ... }

  8. Aliasing / References • operations on a.x are redirected to b.y • a.x now acts as a local stub • like „remote pointers“ • alias for all fields of a a.x := alias y of b end; redirect a to b;

  9. Special Field Attributes • protected: • prohibits external updates, cloning and aliasing • serialized: • like synchronized in Java • at most one thread operating on a field at a time

  10. Example 1: Serialized Queue (1) • standard example for concurrent programming • two methods: • read – reads and removes an item from the queue • write – puts an item on the queue • a condition: • nonEmpty – guard to prevent read from empty queue

  11. let queue = (let nonEmpty = condition(); var q = []; { protected, serialized, write => meth(s, elem) q := q @ [elem]; signal(nonEmpty); end; read => meth(s) watch nonEmpty until #(q)>0 end; let q0 = q[0] q := q[1 for #(q)-1] q0; end; }); Example 1: Serialized Queue (2)

  12. (1) export (ObjA,”myObj”) (2) import “myObj” (3) Method Calls Network Objects Namer “myObj” Site 1 Site 2 ObjA ObjRemote

  13. Example 2: Agent Migration (1) • Idea: • write a program (agent) • put it into a network • disconnect • agent travels around in the network and collects information • come back online • collect agent

  14. Example 2: Agent Migration (2) • Problem: • to collect information, an agent needs some kind of storage • Obliq Solution: • one object can be attached to another • active computations transmitted together with an evaluation stack (=> strong mobility)

  15. Example 2: Agent Migration (3) let state = { ... }; let agent = proc(state, arg) ... end; // migrate using a computation engine: let atSite1 = net_importEngine(“E1@Site1”) atSite1( proc(arg) agent(copy(state), arg) end)

  16. ExEngine state state SiteData agent agent Site 0 Site 1 ExEngine SiteData Site 1 Example 2: Agent Migration (4) • Before Migration: • After Migration:

  17. Conclusion • consistent way of dealing with distribution • at the cost of high traffic volume on network • Obliq as ‘testing suite’ for network-object libraries

  18. Network Objects • Server: • Client: net_export(„obj“, Namer, site1Obj) • let site1Obj = net_import(„obj“, Namer); • site1Obj.opA(args); • site3Obj.opB(site1Obj);

  19. Network Objects (2) • Execution Engines: • Server: • Client: net_exportEngine(„E1@Site1“, Namer, arg); • let atSite1 = • net_importEngine(„E1@Site1“, Namer); • atSite1(proc(arg) 3+2 end);