Back to home page

OSCL-LXR

 
 

    


0001 C MP+onceassign+derefonce
0002 
0003 (*
0004  * Result: Never
0005  *
0006  * This litmus test demonstrates that rcu_assign_pointer() and
0007  * rcu_dereference() suffice to ensure that an RCU reader will not see
0008  * pre-initialization garbage when it traverses an RCU-protected data
0009  * structure containing a newly inserted element.
0010  *)
0011 
0012 {
0013 p=y;
0014 }
0015 
0016 P0(int *x, int **p) // Producer
0017 {
0018         WRITE_ONCE(*x, 1);
0019         rcu_assign_pointer(*p, x);
0020 }
0021 
0022 P1(int *x, int **p) // Consumer
0023 {
0024         int *r0;
0025         int r1;
0026 
0027         rcu_read_lock();
0028         r0 = rcu_dereference(*p);
0029         r1 = READ_ONCE(*r0);
0030         rcu_read_unlock();
0031 }
0032 
0033 exists (1:r0=x /\ 1:r1=0) (* Bad outcome. *)