parametric verification of concurrent programs under the
play

Parametric Verification of Concurrent Programs under the TSO Weak - PowerPoint PPT Presentation

Parametric Verification of Concurrent Programs under the TSO Weak Memory Model Ahmed Bouajjani Paris Diderot University Based on joint work with Parosh A. Abdulla Mohamed Faouzi Atig T. Phong Ngo Uppsala University Sebastian


  1. Parametric Verification of Concurrent Programs under the TSO Weak Memory Model Ahmed Bouajjani Paris Diderot University Based on joint work with Parosh A. Abdulla Mohamed Faouzi Atig T. Phong Ngo Uppsala University Sebastian Burckhardt Madan Musuvathi Microsoft Research SynCoP+PV’17, Uppsala, April 22, 2017

  2. Sequential Consistency • Concurrent processes with Shared Memory • Operations: Writes and Reads • Computation of different processes are shuffled • Program order is preserved for each process • => Strong consistency: Operations are immediately visible to all processes • Simple and Intuitive model • Disallows many hardware/compiler optimisations

  3. Sequential Consistency • Concurrent processes with Shared Memory • Operations: Writes and Reads • Computation of different processes are shuffled • Program order is preserved for each process • => Strong consistency: • => Strong consistency: Operations are immediately visible to all processes • Simple and Intuitive model • Simple and Intuitive model • Disallows many hardware/compiler optimisations

  4. Sequential Consistency • Concurrent processes with Shared Memory • Operations: Writes and Reads • Computation of different processes are shuffled • Program order is preserved for each process • => Strong consistency: Operations are immediately visible to all processes • Simple and Intuitive model • Disallows many hardware/compiler optimisations

  5. Weak Memory Models x=y=0 write(x,1) read(x,0) po hb read(y,0) read(x,0) write (x,1) read(y,0) SC

  6. Weak Memory Models Relax the Program Order Constraints x=y=0 write(x,1) read(x,0) po hb read(y,0) read(x,0) write (x,1) read(y,0) SC Swap operations TSO read(x,0) read(y,0) write (x,1)

  7. Weak Memory Models Relax the Program Order Constraints x=y=0 write(x,1) read(x,0) po hb read(y,0) read(x,0) write (x,1) read(y,0) SC Swap operations TSO read(x,0) read(y,0) write (x,1) Execute in parallel

  8. Total Store Ordering Store Buffers Memory P1 w(x,2) w(y,1) w(x,1) … … Pn w(y,2) • writes are sent to store buffers (one per process) • writes are committed to memory at any time • reads are from - own store buffer if a value exists (last write to the variable) - otherwise from the memory • fences executed when own buffer is empty

  9. Non SC Behaviours x=y=0 write(x,1) write(y,1) read(y,0) read(x,0) CS1 CS2 CS1 and CS2 ?

  10. Non SC Behaviours x=y=0 write(x,1) write(y,1) po po read(y,0) read(x,0) hb hb CS1 CS2 CS1 and CS2 ? - Impossible under SC

  11. Non SC Behaviours x=y=0 write(x,1) write(y,1) po po read(y,0) read(x,0) hb hb CS1 CS2 CS1 and CS2 ? - Impossible under SC - Possible under TSO! • writes are delayed : pending in store buffers • reads get old values in the memory (0’s)

  12. Non SC Behaviours x=y=0 write(x,1) write(y,1) po po read(y,0) read(x,0) hb hb CS1 CS2 CS1 and CS2 ? - Impossible under SC - Possible under TSO! • writes are delayed : pending in store buffers • reads get old values in the memory (0’s) • => po constraints are relaxed • => reads can overtake writes

  13. TSO: Semantics P1 P2 > > w(x,1) w(y,1) r(x,0) r(y,0) P1 x=0 y=0 P2

  14. TSO: Semantics P1 P2 w(x,1) w(y,1) > > r(x,0) r(y,0) P1 w(x,1) x=0 y=0 P2 w(y,1)

  15. TSO: Semantics P1 P2 w(x,1) w(y,1) r(x,0) r(y,0) > > P1 w(x,1) x=0 y=0 P2 w(y,1)

  16. Avoiding Reordering: Fences x=y=0 hb hb write(x,1) write(y,1) hb fence fence read(y,0) read(x,0) hb hb hb CS1 CS2 CS1 and CS2 ? • A fence forces flushing the store buffer • => CS1 and CS2 becomes impossible

  17. Avoiding Reordering: Fences x=y=0 hb hb write(x,1) write(y,1) hb fence fence read(y,0) read(x,0) hb hb hb CS1 CS2 CS1 and CS2 ? • A fence forces flushing the store buffer • => CS1 and CS2 becomes impossible SC can be enforced: fence after each write

  18. Safety/Reachability Verification Problems P1 … m 1 . . . . . . P n … m 1 for every n , for every m , [ P1 || … || P n ] TSO(m) satisfies Always (Safe) there is n , there is m , [ P1 || … || P n ] TSO(m) satisfies Reachable (Not Safe)

  19. First step: Let us fix the number of processes P1 … m 1 . . . . . . P n … m 1 for every m , [ P1 || … || P n ] TSO(m) satisfies Always (Safe) there is m , [ P1 || … || P n ] TSO(m) satisfies Reachable (Not Safe)

  20. First step: Let us fix the number of processes P1 … m 1 . . . . . . Consider Unbounded Store Buffers P n … m 1 there is m , [ P1 || … || P n ] TSO(m) satisfies Reachable (Not Safe) <=> [ P1 || … || P n ] TSO( ∞ ) satisfies Reachable (Not Safe)

  21. Reachability Problem for a given number of processes: Decidability, Complexity Assume that processes are finite state Under SC , the control state reachability problem is • PSPACE-complete, for a fixed number of processes • EXPSPACE-complete, for the parametric case

  22. Reachability Problem for a given number of processes: Decidability, Complexity Assume that processes are finite state Under SC , the control state reachability problem is • PSPACE-complete, for a fixed number of processes • EXPSPACE-complete, for the parametric case What about the TSO( ∞ ) reachability? store buffers are unbounded perfect FIFO queues !!

  23. Reachability Problem for a given number of processes: Decidability, Complexity Assume that processes are finite state Under SC , the control state reachability problem is • PSPACE-complete, for a fixed number of processes • EXPSPACE-complete, for the parametric case What about the TSO( ∞ ) reachability? store buffers are unbounded perfect FIFO queues !! What about the parametric TSO( ∞ ) reachability?

  24. Reachability Problem for TSO programs: Results - The TSO reachability problem is decidable

  25. Reachability Problem for TSO programs: Results - The TSO reachability problem is decidable - … but it is highly complex (non primitive recursive) Reduction to/from reachability in lossy channel systems [Atig, B., Burckhardt, Musuvathi, POPL’10]

  26. Reachability Problem for TSO programs: Results - The TSO reachability problem is decidable - … but it is highly complex (non primitive recursive) Reduction to/from reachability in lossy channel systems [Atig, B., Burckhardt, Musuvathi, POPL’10] - The parametric TSO reachability problem is decidable - A dual semantics for TSO - Monotonic system w.r.t. WQO - Simpler and more efficient reduction [Abdulla, Atig, B.,Ngo, CONCUR’16]

  27. Reachability Problem for TSO programs: Results - The TSO reachability problem is decidable - … but it is highly complex (non primitive recursive) Reduction to/from reachability in lossy channel systems [Atig, B., Burckhardt, Musuvathi, POPL’10] - The parametric TSO reachability problem is decidable - A dual semantics for TSO - Monotonic system w.r.t. WQO - Simpler and more efficient reduction [Abdulla, Atig, B.,Ngo, CONCUR’16]

  28. An example of TSO program x=y=0 P1 P2 > > w(x,1) r(x,2) w(y,1) r(y,0) w(x,2) x=0 P1 y=0 TSO store buffer of P1

  29. An example of TSO program x=y=0 P1 P2 > w(x,1) r(x,2) w(y,1) r(y,0) w(x,2) > x=0 P1 w(x,2) w(y,1) w(x,1) y=0 TSO store buffer of P1

  30. An example of TSO program x=y=0 P1 P2 > w(x,1) r(x,2) w(y,1) r(y,0) w(x,2) > x=1 P1 w(x,2) w(y,1) w(x,1) y=0 TSO store buffer of P1

  31. An example of TSO program x=y=0 P1 P2 > w(x,1) r(x,2) w(y,1) r(y,0) w(x,2) > x=1 P1 w(x,2) w(y,1) w(x,1) y=1 TSO store buffer of P1

  32. An example of TSO program x=y=0 P1 P2 > w(x,1) r(x,2) w(y,1) r(y,0) w(x,2) > x=2 P1 w(x,2) w(y,1) w(x,1) y=1 TSO store buffer of P1

  33. An example of TSO program x=y=0 P1 P2 w(x,1) r(x,2) > w(y,1) r(y,0) w(x,2) > x=2 P1 w(x,2) w(y,1) w(x,1) y=1 TSO store buffer of P1

  34. An example of TSO program x=y=0 P1 P2 w(x,1) r(x,2) > w(y,1) r(y,0) X w(x,2) > x=2 P1 w(x,2) w(y,1) w(x,1) y=1 TSO store buffer of P1 Deadlock under the TSO semantics

  35. TSO Store Buffers —> Lossy Channels ? x=y=0 P1 P2 > w(x,1) r(x,2) w(y,1) r(y,0) w(x,2) > x=0 P1 w(x,2) w(y,1) w(x,1) y=0 Lossy Fifo Channel

  36. TSO Store Buffers —> Lossy Channels ? x=y=0 P1 P2 > w(x,1) r(x,2) w(y,1) r(y,0) w(x,2) > x=1 P1 w(x,2) w(y,1) w(x,1) y=0 Lossy Fifo Channel

  37. TSO Store Buffers —> Lossy Channels ? x=y=0 P1 P2 > w(x,1) r(x,2) w(y,1) r(y,0) w(x,2) > x=1 P1 w(x,2) w(y,1) w(x,1) y=0 Lossy Fifo Channel

  38. TSO Store Buffers —> Lossy Channels ? x=y=0 P1 P2 > w(x,1) r(x,2) w(y,1) r(y,0) w(x,2) > x=2 P1 w(x,2) w(y,1) w(x,1) y=0 Lossy Fifo Channel

  39. TSO Store Buffers —> Lossy Channels ? x=y=0 P1 P2 w(x,1) r(x,2) > w(y,1) r(y,0) w(x,2) > x=2 P1 w(x,2) w(y,1) w(x,1) y=0 Lossy Fifo Channel

  40. TSO Store Buffers —> Lossy Channels ? x=y=0 P1 P2 w(x,1) r(x,2) w(y,1) r(y,0) > w(x,2) > x=2 P1 w(x,2) w(y,1) w(x,1) y=0 Lossy Fifo Channel Unsound simulation of TSO!

  41. Store Memory Snapshots x=y=0 P1 P2 > > w(x,1) r(x,2) w(y,1) r(y,0) w(x,2) x=0 P1 y=0 Future Snapshots of the Memory

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