Skip to content

Commit

Permalink
doc: Fix memory-barrier control-dependency example
Browse files Browse the repository at this point in the history
Each control-dependency example needs its barriers between the "if"
condition and the body of the "if" because a control dependency is
a dependency induced by a branch.  This commit makes the needed
adjustment.

Reported-by: Yongming Shen <symingz@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
  • Loading branch information
Paul E. McKenney committed Aug 20, 2013
1 parent 6ae3771 commit 45c8a36
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Documentation/memory-barriers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,10 @@ dependency barrier to make it work correctly. Consider the following bit of
code:

q = &a;
if (p)
if (p) {
<data dependency barrier>
q = &b;
<data dependency barrier>
}
x = *q;

This will not have the desired effect because there is no actual data
Expand All @@ -542,9 +543,10 @@ attempting to predict the outcome in advance. In such a case what's actually
required is:

q = &a;
if (p)
if (p) {
<read barrier>
q = &b;
<read barrier>
}
x = *q;


Expand Down

0 comments on commit 45c8a36

Please sign in to comment.