Memory Barriers: a Hardware View for Software Hackers Example 3

自闭症网瘾萝莉.ら 提交于 2019-12-06 02:55:44

Leaving lines 6-9 out of CPU 0 would definitely prevent the assert() from firing. Then again, so would removing all the code other than the assert, given that e is initialized to zero. However, both modifications are unhelpful. Instead, the key point of the assertion is the question "Is it possible for CPU 2 to see the state e==1&&a==0 at the end of its execution?" Looking at it this way should force you to think in terms of what values propagate where in what order.

But the main thing you overlooked is that this paper is extremely old, and there has been a huge amount of progress in understanding and formalizing memory ordering since then. I am in the process of adding a new memory-ordering chapter to Is Parallel Programming Hard, And, If So, What Can You Do About It? In the meantime, the pair of LWN articles here and here may be helpful.

Or if you want to see the current state of the book, git clone git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/perfbook.git.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!