implementing atomicity with locks
play

Implementing Atomicity with Locks Dave Cunningham April 4, 2006 - PowerPoint PPT Presentation

Outline Motivation Analysis Of Accessed Objects Conclusion Implementing Atomicity with Locks Dave Cunningham April 4, 2006 Dave Cunningham Implementing Atomicity with Locks 1/16 Outline Motivation Analysis Of Accessed Objects Conclusion


  1. Outline Motivation Analysis Of Accessed Objects Conclusion Implementing Atomicity with Locks Dave Cunningham April 4, 2006 Dave Cunningham Implementing Atomicity with Locks 1/16

  2. Outline Motivation Analysis Of Accessed Objects Conclusion Motivation The Problem A New Solution Example Analysis Of Accessed Objects Examples Formalism Correctness Termination Conclusion Conclusion Future work Dave Cunningham Implementing Atomicity with Locks 2/16

  3. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Atomic Section Future concurrent programming languages may include the atomic section. atomic { account.balance := account.balance - amount; log.append("withdrew ..."); } Dave Cunningham Implementing Atomicity with Locks 3/16

  4. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Atomic Section Future concurrent programming languages may include the atomic section. atomic { account.balance := account.balance - amount; log.append("withdrew ..."); } ◮ Efficient implementations must understand interference . Dave Cunningham Implementing Atomicity with Locks 3/16

  5. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Atomic Section Future concurrent programming languages may include the atomic section. atomic { account.balance := account.balance - amount; log.append("withdrew ..."); } ◮ Efficient implementations must understand interference . ◮ What objects are accessed by atomic code? Dave Cunningham Implementing Atomicity with Locks 3/16

  6. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Two Approaches Transactions : Log object accesses at runtime. ◮ Concurrent logs with non-empty intersection ⇒ interference. ◮ Interference avoided by undoing (or not committing) code. ◮ Atomic code re-executed. Dave Cunningham Implementing Atomicity with Locks 4/16

  7. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Two Approaches Transactions : Log object accesses at runtime. ◮ Concurrent logs with non-empty intersection ⇒ interference. ◮ Interference avoided by undoing (or not committing) code. ◮ Atomic code re-executed. Alternative : Statically infer what objects may be accessed ◮ Prevent interference using synchronisation. ◮ Dataflow analysis may be inaccurate (arbitrary pointers). ◮ But programmers already do this in their heads. . . Dave Cunningham Implementing Atomicity with Locks 4/16

  8. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Two Approaches Transactions : Log object accesses at runtime. ◮ Concurrent logs with non-empty intersection ⇒ interference. ◮ Interference avoided by undoing (or not committing) code. ◮ Atomic code re-executed. Alternative : Statically infer what objects may be accessed ◮ Prevent interference using synchronisation. ◮ Dataflow analysis may be inaccurate (arbitrary pointers). ◮ But programmers already do this in their heads. . . (Like Ethernet vs Token Ring) Dave Cunningham Implementing Atomicity with Locks 4/16

  9. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Interference Prevention account.balance := account.balance - amount; log.append("withdrew ..."); Dave Cunningham Implementing Atomicity with Locks 5/16

  10. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Interference Prevention synchronized (account,log) { account.balance := account.balance - amount; log.append("withdrew ..."); } Dave Cunningham Implementing Atomicity with Locks 5/16

  11. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Interference Prevention synchronized (account,log) { account.balance := account.balance - amount; log.append("withdrew ..."); } Static Inference returns { account , log } Dynamic Evaluate { account , log } to find out what to lock. Dave Cunningham Implementing Atomicity with Locks 5/16

  12. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Interference Prevention synchronized (account,log) { account.balance := account.balance - amount; log.append("withdrew ..."); } Static Inference returns { account , log } Dynamic Evaluate { account , log } to find out what to lock. What should the analysis return in general? Dave Cunningham Implementing Atomicity with Locks 5/16

  13. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Interference Prevention synchronized (account,log) { account.balance := account.balance - amount; log.append("withdrew ..."); } Static Inference returns { account , log } Dynamic Evaluate { account , log } to find out what to lock. What should the analysis return in general? ◮ Variables? Dave Cunningham Implementing Atomicity with Locks 5/16

  14. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Interference Prevention synchronized (account,log) { account.balance := account.balance - amount; log.append("withdrew ..."); } Static Inference returns { account , log } Dynamic Evaluate { account , log } to find out what to lock. What should the analysis return in general? ◮ Variables? ◮ Arbitrary expressions? Dave Cunningham Implementing Atomicity with Locks 5/16

  15. Outline The Problem Motivation A New Solution Analysis Of Accessed Objects Example Conclusion Interference Prevention synchronized (account,log) { account.balance := account.balance - amount; log.append("withdrew ..."); } Static Inference returns { account , log } Dynamic Evaluate { account , log } to find out what to lock. What should the analysis return in general? ◮ Variables? ◮ Arbitrary expressions? Paths : sequences of field lookups: ◮ me.brother.girlfriend.car ◮ list.first.next.next.next Dave Cunningham Implementing Atomicity with Locks 5/16

  16. Outline Examples Motivation Formalism Analysis Of Accessed Objects Correctness Conclusion Termination Examples (1) L ( e ) e { me , me.brother.car.fuel := 100; me.brother , me.brother.car } if (goodWeather) { this.clothing := drawer.hat; { this , } else { drawer , this.clothing := cloakroom.umbrella; cloakroom } } Dave Cunningham Implementing Atomicity with Locks 6/16

  17. Outline Examples Motivation Formalism Analysis Of Accessed Objects Correctness Conclusion Termination Examples (2) L ( e ) e { me , me.car := you.car; you , me.car.fuel := 100; you.car } { me , you , me.car := you.car; you.car , dave.car.fuel := 100; dave , dave.car } Dave Cunningham Implementing Atomicity with Locks 7/16

  18. Outline Examples Motivation Formalism Analysis Of Accessed Objects Correctness Conclusion Termination Definition of L Intuition: L ( e ) ≈ “objects that may be accessed by e ” Dave Cunningham Implementing Atomicity with Locks 8/16

  19. Outline Examples Motivation Formalism Analysis Of Accessed Objects Correctness Conclusion Termination Definition of L Intuition: L ( e ) ≈ “objects that may be accessed by e ” (in terms of paths through the initial heap ) Dave Cunningham Implementing Atomicity with Locks 8/16

  20. Outline Examples Motivation Formalism Analysis Of Accessed Objects Correctness Conclusion Termination Definition of L Intuition: L ( e ) ≈ “objects that may be accessed by e ” (in terms of paths through the initial heap ) Definition: L ( x ) = ∅ Dave Cunningham Implementing Atomicity with Locks 8/16

  21. Outline Examples Motivation Formalism Analysis Of Accessed Objects Correctness Conclusion Termination Definition of L Intuition: L ( e ) ≈ “objects that may be accessed by e ” (in terms of paths through the initial heap ) Definition: L ( x ) = ∅ L ( if q e 1 e 2 ) = L ( q ) ∪ ( L ( e 1 ) ∪ L ( e 2 )) Dave Cunningham Implementing Atomicity with Locks 8/16

  22. Outline Examples Motivation Formalism Analysis Of Accessed Objects Correctness Conclusion Termination Definition of L Intuition: L ( e ) ≈ “objects that may be accessed by e ” (in terms of paths through the initial heap ) Definition: L ( x ) = ∅ L ( if q e 1 e 2 ) = L ( q ) ∪ ( L ( e 1 ) ∪ L ( e 2 )) L ( q . f ) = L ( q ) ∪ { q } L ( q . f := r ) = L ( q ) ∪ L ( r ) ∪ { q } Dave Cunningham Implementing Atomicity with Locks 8/16

  23. Outline Examples Motivation Formalism Analysis Of Accessed Objects Correctness Conclusion Termination Definition of L Intuition: L ( e ) ≈ “objects that may be accessed by e ” (in terms of paths through the initial heap ) Definition: L ( x ) = ∅ L ( if q e 1 e 2 ) = L ( q ) ∪ ( L ( e 1 ) ∪ L ( e 2 )) L ( q . f ) = L ( q ) ∪ { q } L ( q . f := r ) = L ( q ) ∪ L ( r ) ∪ { q } L ( e 1 ; e 2 ) = L ( e 1 ) ∪ T e 1 ( L ( e 2 )) Dave Cunningham Implementing Atomicity with Locks 8/16

  24. Outline Examples Motivation Formalism Analysis Of Accessed Objects Correctness Conclusion Termination Definition of T Intuition: T e ( P ′ ) ≈ “ P ′ translated with respect to the side-effects of e ” Dave Cunningham Implementing Atomicity with Locks 9/16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend