How compiler and processor optimization works to speed up code execution?

82 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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/