0

In Linux Kernel Development (3rd Edition), Kernel Synchronization Methods, Ordering and Barriers. There is an example:

enter image description here

And I'm confused about the statement in this book:

Again, without memory barriers, it would be possible for b to be set to pp before pp was set to p.

So, does the author mean if there is no read_barrier_depends(), b = *pp would be executed before pp = p? How could this be possible?

7
  • 1
    Most likely they meant b to be set to *p before pp was set to p, while it's possible that p could change its value in between. Commented Apr 12, 2019 at 7:20
  • So, what does read_barrier_depends() do? Commented Apr 12, 2019 at 7:34
  • 1
    It tells the compiler not to reorder memory reads before and after it. E.g., all the reads and writes before must be issued first, and only then all the reads after the barrier. Commented Apr 12, 2019 at 10:22
  • 1, all the reads and writes before or all the reads before? 2, read_barrier_depends only affect compiler but do not affect processor reordering? Commented Apr 12, 2019 at 11:11
  • 2
    lwn.net/Articles/5159 Commented Apr 12, 2019 at 14:37

1 Answer 1

1

I was interested in your problem, so I searched a bit longer. I found the post of the read_barrier_depends functionality on the kernel list, with some explanation:

https://lwn.net/Articles/5159/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.