- 论坛徽章:
- 0
|
据说有些编译器就有这么牛. Paul McKenney 讲RCU的一篇文章:http://lwn.net/Articles/262464/
However, it is not sufficient to only enforce ordering at the updater, as the reader must enforce proper ordering as well. Consider for example the following code fragment:
1 p = gp;
2 if (p != NULL) {
3 do_something_with(p->a, p->b, p->c);
4 }
Although this code fragment might well seem immune to misordering, unfortunately, the DEC Alpha CPU [PDF] and value-speculation compiler optimizations can, believe it or not, cause the values of p->a, p->b, and p->c to be fetched before the value of p! This is perhaps easiest to see in the case of value-speculation compiler optimizations, where the compiler guesses the value of p, fetches p->a, p->b, and p->c, then fetches the actual value of p in order to check whether its guess was correct. This sort of optimization is quite aggressive, perhaps insanely so, but does actually occur in the context of profile-driven optimization.
底层软件的话,考虑多nasty的东西都无所谓。不过给用户态程序造成这样的混乱实在太蛋疼了。
@塑料袋 元芳,你怎么看? |
|