MP+poonceonces.litmus 386 B

123456789101112131415161718192021222324252627
  1. C MP+poonceonces
  2. (*
  3. * Result: Sometimes
  4. *
  5. * Can the counter-intuitive message-passing outcome be prevented with
  6. * no ordering at all?
  7. *)
  8. {}
  9. P0(int *buf, int *flag) // Producer
  10. {
  11. WRITE_ONCE(*buf, 1);
  12. WRITE_ONCE(*flag, 1);
  13. }
  14. P1(int *buf, int *flag) // Consumer
  15. {
  16. int r0;
  17. int r1;
  18. r0 = READ_ONCE(*flag);
  19. r1 = READ_ONCE(*buf);
  20. }
  21. exists (1:r0=1 /\ 1:r1=0) (* Bad outcome. *)