LB+ctrlonceonce+mbonceonce.litmus 689 B

12345678910111213141516171819202122232425262728293031323334
  1. C LB+ctrlonceonce+mbonceonce
  2. (*
  3. * Result: Never
  4. *
  5. * This litmus test demonstrates that lightweight ordering suffices for
  6. * the load-buffering pattern, in other words, preventing all processes
  7. * reading from the preceding process's write. In this example, the
  8. * combination of a control dependency and a full memory barrier are enough
  9. * to do the trick. (But the full memory barrier could be replaced with
  10. * another control dependency and order would still be maintained.)
  11. *)
  12. {}
  13. P0(int *x, int *y)
  14. {
  15. int r0;
  16. r0 = READ_ONCE(*x);
  17. if (r0)
  18. WRITE_ONCE(*y, 1);
  19. }
  20. P1(int *x, int *y)
  21. {
  22. int r0;
  23. r0 = READ_ONCE(*y);
  24. smp_mb();
  25. WRITE_ONCE(*x, 1);
  26. }
  27. exists (0:r0=1 /\ 1:r0=1)