aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/memory-model/litmus-tests/dep+plain.litmus
blob: ebf84daa9a590ea2e92a233c5266adecda43e7ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
C dep+plain

(*
 * Result: Never
 *
 * This litmus test demonstrates that in LKMM, plain accesses
 * carry dependencies much like accesses to registers:
 * The data stored to *z1 and *z2 by P0() originates from P0()'s
 * READ_ONCE(), and therefore using that data to compute the
 * conditional of P0()'s if-statement creates a control dependency
 * from that READ_ONCE() to P0()'s WRITE_ONCE().
 *)

{}

P0(int *x, int *y, int *z1, int *z2)
{
	int a = READ_ONCE(*x);
	*z1 = a;
	*z2 = *z1;
	if (*z2 == 1)
		WRITE_ONCE(*y, 1);
}

P1(int *x, int *y)
{
	int r = smp_load_acquire(y);
	smp_store_release(x, r);
}

exists (x=1 /\ y=1)