ISA2+pooncerelease+poacquirerelease+poacquireonce.litmus 784 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. C ISA2+pooncerelease+poacquirerelease+poacquireonce
  2. (*
  3. * Result: Never
  4. *
  5. * This litmus test demonstrates that a release-acquire chain suffices
  6. * to order P0()'s initial write against P2()'s final read. The reason
  7. * that the release-acquire chain suffices is because in all but one
  8. * case (P2() to P0()), each process reads from the preceding process's
  9. * write. In memory-model-speak, there is only one non-reads-from
  10. * (AKA non-rf) link, so release-acquire is all that is needed.
  11. *)
  12. {}
  13. P0(int *x, int *y)
  14. {
  15. WRITE_ONCE(*x, 1);
  16. smp_store_release(y, 1);
  17. }
  18. P1(int *y, int *z)
  19. {
  20. int r0;
  21. r0 = smp_load_acquire(y);
  22. smp_store_release(z, 1);
  23. }
  24. P2(int *x, int *z)
  25. {
  26. int r0;
  27. int r1;
  28. r0 = smp_load_acquire(z);
  29. r1 = READ_ONCE(*x);
  30. }
  31. exists (1:r0=1 /\ 2:r0=1 /\ 2:r1=0)