MP+pooncerelease+poacquireonce.litmus 464 B

12345678910111213141516171819202122232425262728
  1. C MP+pooncerelease+poacquireonce
  2. (*
  3. * Result: Never
  4. *
  5. * This litmus test demonstrates that smp_store_release() and
  6. * smp_load_acquire() provide sufficient ordering for the message-passing
  7. * pattern.
  8. *)
  9. {}
  10. P0(int *buf, int *flag) // Producer
  11. {
  12. WRITE_ONCE(*buf, 1);
  13. smp_store_release(flag, 1);
  14. }
  15. P1(int *buf, int *flag) // Consumer
  16. {
  17. int r0;
  18. int r1;
  19. r0 = smp_load_acquire(flag);
  20. r1 = READ_ONCE(*buf);
  21. }
  22. exists (1:r0=1 /\ 1:r1=0) (* Bad outcome. *)