MP+fencewmbonceonce+fencermbonceonce.litmus 482 B

123456789101112131415161718192021222324252627282930
  1. C MP+fencewmbonceonce+fencermbonceonce
  2. (*
  3. * Result: Never
  4. *
  5. * This litmus test demonstrates that smp_wmb() and smp_rmb() provide
  6. * sufficient ordering for the message-passing pattern. However, it
  7. * is usually better to use smp_store_release() and smp_load_acquire().
  8. *)
  9. {}
  10. P0(int *x, int *y)
  11. {
  12. WRITE_ONCE(*x, 1);
  13. smp_wmb();
  14. WRITE_ONCE(*y, 1);
  15. }
  16. P1(int *x, int *y)
  17. {
  18. int r0;
  19. int r1;
  20. r0 = READ_ONCE(*y);
  21. smp_rmb();
  22. r1 = READ_ONCE(*x);
  23. }
  24. exists (1:r0=1 /\ 1:r1=0)