Z6.0+pooncelock+pooncelock+pombonce.litmus 658 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. C Z6.0+pooncelock+pooncelock+pombonce
  2. (*
  3. * Result: Sometimes
  4. *
  5. * This example demonstrates that a pair of accesses made by different
  6. * processes each while holding a given lock will not necessarily be
  7. * seen as ordered by a third process not holding that lock.
  8. *)
  9. {}
  10. P0(int *x, int *y, spinlock_t *mylock)
  11. {
  12. spin_lock(mylock);
  13. WRITE_ONCE(*x, 1);
  14. WRITE_ONCE(*y, 1);
  15. spin_unlock(mylock);
  16. }
  17. P1(int *y, int *z, spinlock_t *mylock)
  18. {
  19. int r0;
  20. spin_lock(mylock);
  21. r0 = READ_ONCE(*y);
  22. WRITE_ONCE(*z, 1);
  23. spin_unlock(mylock);
  24. }
  25. P2(int *x, int *z)
  26. {
  27. int r1;
  28. WRITE_ONCE(*z, 2);
  29. smp_mb();
  30. r1 = READ_ONCE(*x);
  31. }
  32. exists (1:r0=1 /\ z=2 /\ 2:r1=0)