Z6.0+pooncerelease+poacquirerelease+fencembonceonce.litmus 980 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. C Z6.0+pooncerelease+poacquirerelease+fencembonceonce
  2. (*
  3. * Result: Sometimes
  4. *
  5. * This litmus test shows that a release-acquire chain, while sufficient
  6. * when there is but one non-reads-from (AKA non-rf) link, does not suffice
  7. * if there is more than one. Of the three processes, only P1() reads from
  8. * P0's write, which means that there are two non-rf links: P1() to P2()
  9. * is a write-to-write link (AKA a "coherence" or just "co" link) and P2()
  10. * to P0() is a read-to-write link (AKA a "from-reads" or just "fr" link).
  11. * When there are two or more non-rf links, you typically will need one
  12. * full barrier for each non-rf link. (Exceptions include some cases
  13. * involving locking.)
  14. *)
  15. {}
  16. P0(int *x, int *y)
  17. {
  18. WRITE_ONCE(*x, 1);
  19. smp_store_release(y, 1);
  20. }
  21. P1(int *y, int *z)
  22. {
  23. int r0;
  24. r0 = smp_load_acquire(y);
  25. smp_store_release(z, 1);
  26. }
  27. P2(int *x, int *z)
  28. {
  29. int r1;
  30. WRITE_ONCE(*z, 2);
  31. smp_mb();
  32. r1 = READ_ONCE(*x);
  33. }
  34. exists (1:r0=1 /\ z=2 /\ 2:r1=0)