dep+plain.litmus 628 B

12345678910111213141516171819202122232425262728293031
  1. C dep+plain
  2. (*
  3. * Result: Never
  4. *
  5. * This litmus test demonstrates that in LKMM, plain accesses
  6. * carry dependencies much like accesses to registers:
  7. * The data stored to *z1 and *z2 by P0() originates from P0()'s
  8. * READ_ONCE(), and therefore using that data to compute the
  9. * conditional of P0()'s if-statement creates a control dependency
  10. * from that READ_ONCE() to P0()'s WRITE_ONCE().
  11. *)
  12. {}
  13. P0(int *x, int *y, int *z1, int *z2)
  14. {
  15. int a = READ_ONCE(*x);
  16. *z1 = a;
  17. *z2 = *z1;
  18. if (*z2 == 1)
  19. WRITE_ONCE(*y, 1);
  20. }
  21. P1(int *x, int *y)
  22. {
  23. int r = smp_load_acquire(y);
  24. smp_store_release(x, r);
  25. }
  26. exists (x=1 /\ y=1)