11c27b644SPaul E. McKenneyC Z6.0+pooncelock+pooncelock+pombonce
21c27b644SPaul E. McKenney
38f32543bSPaul E. McKenney(*
48f32543bSPaul E. McKenney * Result: Sometimes
58f32543bSPaul E. McKenney *
68f32543bSPaul E. McKenney * This example demonstrates that a pair of accesses made by different
78f32543bSPaul E. McKenney * processes each while holding a given lock will not necessarily be
88f32543bSPaul E. McKenney * seen as ordered by a third process not holding that lock.
98f32543bSPaul E. McKenney *)
108f32543bSPaul E. McKenney
11*5c587f9bSAkira Yokosawa{}
121c27b644SPaul E. McKenney
131c27b644SPaul E. McKenneyP0(int *x, int *y, spinlock_t *mylock)
141c27b644SPaul E. McKenney{
151c27b644SPaul E. McKenney	spin_lock(mylock);
161c27b644SPaul E. McKenney	WRITE_ONCE(*x, 1);
171c27b644SPaul E. McKenney	WRITE_ONCE(*y, 1);
181c27b644SPaul E. McKenney	spin_unlock(mylock);
191c27b644SPaul E. McKenney}
201c27b644SPaul E. McKenney
211c27b644SPaul E. McKenneyP1(int *y, int *z, spinlock_t *mylock)
221c27b644SPaul E. McKenney{
231c27b644SPaul E. McKenney	int r0;
241c27b644SPaul E. McKenney
251c27b644SPaul E. McKenney	spin_lock(mylock);
261c27b644SPaul E. McKenney	r0 = READ_ONCE(*y);
271c27b644SPaul E. McKenney	WRITE_ONCE(*z, 1);
281c27b644SPaul E. McKenney	spin_unlock(mylock);
291c27b644SPaul E. McKenney}
301c27b644SPaul E. McKenney
311c27b644SPaul E. McKenneyP2(int *x, int *z)
321c27b644SPaul E. McKenney{
331c27b644SPaul E. McKenney	int r1;
341c27b644SPaul E. McKenney
351c27b644SPaul E. McKenney	WRITE_ONCE(*z, 2);
361c27b644SPaul E. McKenney	smp_mb();
371c27b644SPaul E. McKenney	r1 = READ_ONCE(*x);
381c27b644SPaul E. McKenney}
391c27b644SPaul E. McKenney
401c27b644SPaul E. McKenneyexists (1:r0=1 /\ z=2 /\ 2:r1=0)
41