xref: /linux/tools/memory-model/litmus-tests/SB+fencembonceonces.litmus (revision de5d1b39ea0b38a9f4dfb08966042b7b91e2df30)
1C SB+fencembonceonces
2
3(*
4 * Result: Never
5 *
6 * This litmus test demonstrates that full memory barriers suffice to
7 * order the store-buffering pattern, where each process writes to the
8 * variable that the preceding process reads.  (Locking and RCU can also
9 * suffice, but not much else.)
10 *)
11
12{}
13
14P0(int *x, int *y)
15{
16	int r0;
17
18	WRITE_ONCE(*x, 1);
19	smp_mb();
20	r0 = READ_ONCE(*y);
21}
22
23P1(int *x, int *y)
24{
25	int r0;
26
27	WRITE_ONCE(*y, 1);
28	smp_mb();
29	r0 = READ_ONCE(*x);
30}
31
32exists (0:r0=0 /\ 1:r0=0)
33