Memory Fences - Need help to understand

前端 未结 1 1025
小蘑菇
小蘑菇 2020-12-24 09:35

I\'m reading Memory Barriers by Paul E. McKenney http://www.rdrop.com/users/paulmck/scalability/paper/whymb.2010.07.23a.pdf everything is explained in great details and when

相关标签:
1条回答
  • 2020-12-24 10:01

    What does it mean?

    It means that if you have:

    read
    read
    read
    READ BARRIER
    read
    read
    read
    

    then the read barrier acts as a "join point" dividing these reads into two batches. All the reads preceding the read barrier will have been done before any read following the read barrier is begun.

    Which loads in bar() must complete before the load of a (#4) is begun?

    All reads of b (#3) are forced to precede any read of a (#4). This means that a is not read till after b is no longer 0. Because foo() uses a write barrier to ensure that a has already been changed to 1 (#1) by the time that b is changed (#2). The two barriers thus work together to ensure the assert statement will always succeed.

    0 讨论(0)
提交回复
热议问题