lecture 4 verification of weak memory models
play

Lecture 4: Verification of Weak Memory Models Part 2: Robustness - PowerPoint PPT Presentation

Lecture 4: Verification of Weak Memory Models Part 2: Robustness against TSO Ahmed Bouajjani LIAFA, University Paris Diderot Paris 7 Joint work with Roland Meyer, Egor Derevenetc (Univ. Kaiserslautern) and Eike M ohlmann (Univ.


  1. Lecture 4: Verification of Weak Memory Models Part 2: Robustness against TSO Ahmed Bouajjani LIAFA, University Paris Diderot – Paris 7 Joint work with Roland Meyer, Egor Derevenetc (Univ. Kaiserslautern) and Eike M¨ ohlmann (Univ. Oldenburg) VTSA, MPI-Saarbr¨ ucken, September 2012

  2. Dekker’s Protocol Synchronise access of two threads to their critical sections Dekker’s mutual exclusion protocol t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs

  3. Dekker’s Protocol Synchronise access of two threads to their critical sections Dekker’s mutual exclusion protocol ◮ Indicate wish to enter Write own variable x to 1 ( w , x , 1) t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs

  4. Dekker’s Protocol Synchronise access of two threads to their critical sections Dekker’s mutual exclusion protocol ◮ Indicate wish to enter Write own variable x to 1 ◮ Check no wish from partner Check partner variable ( w , x , 1) ( r , y , 0) t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs

  5. Dekker’s Protocol Synchronise access of two threads to their critical sections Dekker’s mutual exclusion protocol ◮ Indicate wish to enter Write own variable x to 1 ◮ Check no wish from partner Check partner variable ◮ Symmetry Second thread behaves similarly ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs

  6. Dekker’s Protocol Synchronise access of two threads to their critical sections Dekker’s mutual exclusion protocol ◮ Indicate wish to enter Write own variable x to 1 ◮ Check no wish from partner Check partner variable ◮ Symmetry Second thread behaves similarly ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs ◮ What is the semantics of this program?

  7. Dekker’s Protocol Synchronise access of two threads to their critical sections Dekker’s mutual exclusion protocol ◮ Indicate wish to enter Write own variable x to 1 ◮ Check no wish from partner Check partner variable ◮ Symmetry Second thread behaves similarly ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs ◮ What is the semantics of this program? ◮ Depends on the hardware architecture!

  8. Sequential Consistency Semantics Sequential Consistency memory model [Lamport 1979] ◮ Threads directly write to and read from memory ◮ Programmers often rely on this intuitive behaviour

  9. Sequential Consistency Semantics Sequential Consistency memory model [Lamport 1979] ◮ Take view from memory Sequential Consistency semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs Next: t 1 writes x to 1 M t 1 : q 0 x = 0 t 2 : q 0 y = 0

  10. Sequential Consistency Semantics Sequential Consistency memory model [Lamport 1979] ◮ Take view from memory ( w , x , 1) Sequential Consistency semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs Next: t 1 reads 0 from y M t 1 : q 1 x = 1 y = 0 t 2 : q 0

  11. Sequential Consistency Semantics Sequential Consistency memory model [Lamport 1979] ◮ Take view from memory ( w , x , 1) . ( r , y , 0) Sequential Consistency semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs Next: t 2 writes y to 1 M t 1 : cs x = 1 y = 0 t 2 : q 0

  12. Sequential Consistency Semantics Sequential Consistency memory model [Lamport 1979] ◮ Take view from memory ( w , x , 1) . ( r , y , 0) . ( w , y , 1 ) Sequential Consistency semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs Next: t 2 executes fence f M t 1 : cs x = 1 t 2 : q 1 y = 1

  13. Sequential Consistency Semantics Sequential Consistency memory model [Lamport 1979] ◮ Take view from memory ( w , x , 1) . ( r , y , 0) . ( w , y , 1 ) . f Sequential Consistency semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs Next: t 2 cannot read 0 from x M t 1 : cs x = 1 t 2 : q 2 y = 1

  14. Sequential Consistency Semantics Sequential Consistency memory model [Lamport 1979] ◮ Take view from memory ( w , x , 1) . ( r , y , 0) . ( w , y , 1 ) . f Sequential Consistency semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs M t 1 : cs x = 1 Mutual exclusion holds! y = 1 t 2 : q 2

  15. Total Store Ordering Semantics ◮ Buffers reduce latency of memory accesses Total Store Ordering semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs t 1 : M x = 0 y = 0 t 2 :

  16. Total Store Ordering Semantics ◮ Buffers reduce latency of memory accesses ◮ Total Store Ordering architectures have write buffers Total Store Ordering semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs t 1 : M x = 0 y = 0 t 2 :

  17. Total Store Ordering Semantics Total Store Ordering semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs Next: t 1 writes ( w , x , 1) to its buffer t 1 : q 0 M x = 0 y = 0 t 2 : q 0

  18. Total Store Ordering Semantics Total Store Ordering semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs Next: t 2 writes ( w , y , 1 ) to its buffer t 1 : q 1 ( w , x , 1) M x = 0 y = 0 t 2 : q 0

  19. Total Store Ordering Semantics ◮ Reads prefetch last value written to x from buffer Total Store Ordering semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs Next: t 1 fails to read ( r , y , 0) from its buffer t 1 : q 1 ( w , x , 1) M x = 0 y = 0 t 2 : q 1 ( w , y , 1 ) ×

  20. Total Store Ordering Semantics ◮ Reads prefetch last value written to x from buffer, if exists ( r , y , 0) Total Store Ordering semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs Next: t 1 reads ( r , y , 0) from memory t 1 : q 1 ( w , x , 1) M x = 0 y = 0 t 2 : q 1 ( w , y , 1 )

  21. Total Store Ordering Semantics ◮ Reads prefetch last value written to x from buffer, if exists ◮ Fences forbid prefetches ( r , y , 0) Total Store Ordering semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs Next: t 2 cannot execute fence f while buffer not empty t 1 : cs ( w , x , 1) M x = 0 y = 0 t 2 : q 1 ( w , y , 1 )

  22. Total Store Ordering Semantics ◮ Reads prefetch last value written to x from buffer, if exists ◮ Fences forbid prefetches ( r , y , 0) Total Store Ordering semantics of Dekker’s protocol ( w , x , 1) ( r , y , 0) ( w , y , 1 ) ( r , x , 0 ) f t 1 : q 0 − − − − → q 1 − − − − → cs t 2 : q 0 − − − − → q 1 − → q 2 − − − − → cs Next: memory updates ( w , y , 1 ) from buffer of t 2 t 1 : cs ( w , x , 1) M x = 0 y = 0 t 2 : q 1 ( w , y , 1 )

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