简体   繁体   English

Linux内核内存障碍

[英]Linux kernel memory barriers

I am new to Linux kernel programming. 我是Linux内核编程的新手。 I am confused by the memory barriers documentation, in the GUARANTEES chapter. GUARANTEES章节中,我对内存屏障文档感到困惑。

Overlapping loads and stores within a particular CPU will appear to be ordered within that CPU. 在特定CPU中重叠的加载和存储似乎是在该CPU中排序的。

 *X = c; d = *X; 

the CPU will only issue: CPU 只会发出:

 STORE *X = c, d = LOAD *X 

And then another example after that: 然后是另一个例子:

It must be assumed that overlapping memory accesses may be merged or discarded. 必须假设可以合并或丢弃重叠的存储器访问。

 *A = X; Y = *A; 

we may get either of: 我们可能得到以下任何一个

 STORE *A = X; Y = LOAD *A; STORE *A = Y = X; 

They look like the same, what's the difference between the two examples? 它们看起来一样,这两个例子有什么区别?

You are right, the documnetation is not correct. 你是对的,documnetation是不正确的。 Actually your version of the file isn't up to date. 实际上你的文件版本不是最新的。 There have been a commit in 3.8-rc3 which fixed the issue: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=f191eec58803e1e16c3421638cdcc9195c425851 在3.8-rc3中有一个修正问题:... http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=f191eec58803e1e16c3421638cdcc9195c425851

Hope that helps. 希望有所帮助。 Matthias 马蒂亚斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM