3
0
mirror of https://github.com/Qortal/Brooklyn.git synced 2025-02-14 11:15:54 +00:00
Brooklyn/tools/memory-model/litmus-tests/MP+onceassign+derefonce.litmus

35 lines
555 B
Plaintext
Raw Normal View History

2021-05-27 00:09:36 +05:00
C MP+onceassign+derefonce
(*
* Result: Never
*
* This litmus test demonstrates that rcu_assign_pointer() and
* rcu_dereference() suffice to ensure that an RCU reader will not see
* pre-initialization garbage when it traverses an RCU-protected data
* structure containing a newly inserted element.
*)
{
2021-09-23 21:59:15 +05:00
y=z;
z=0;
2021-05-27 00:09:36 +05:00
}
2021-09-23 21:59:15 +05:00
P0(int *x, int **y)
2021-05-27 00:09:36 +05:00
{
WRITE_ONCE(*x, 1);
2021-09-23 21:59:15 +05:00
rcu_assign_pointer(*y, x);
2021-05-27 00:09:36 +05:00
}
2021-09-23 21:59:15 +05:00
P1(int *x, int **y)
2021-05-27 00:09:36 +05:00
{
int *r0;
int r1;
rcu_read_lock();
2021-09-23 21:59:15 +05:00
r0 = rcu_dereference(*y);
2021-05-27 00:09:36 +05:00
r1 = READ_ONCE(*r0);
rcu_read_unlock();
}
2021-09-23 21:59:15 +05:00
exists (1:r0=x /\ 1:r1=0)