简体   繁体   English

顺序发出的存储/装载是否以相同顺序完成?

[英]Are sequentially issued stores/loads completed in the same order?

I've been having a huge headache debugging and fixing some parallel execution bugs. 我一直在调试和修复一些并行执行错误方面感到头疼。

My main issue is that some shared variables in RAM memory are not coherent between processes. 我的主要问题是RAM内存中的某些共享变量在进程之间不一致。 Let's say that I have two variables a and b updated as such: 假设我有两个变量a和b这样更新:

a = 5;
b = 10;

If I prevent the compiler AND hardware from reordering these two stores, is it always true that other processes will never see a value of 10 in b without also seeing a value of 5 in a ? 如果我阻止重排这两种存储编译器和硬件,是它总是真的,其他进程将永远不会看到在10的值b不还看到值为5 a

If I prevent the compiler AND hardware from reordering these two stores, is it always true that other processes will never see a value of 10 in b without also seeing a value of 5 in a ? 如果我阻止重排这两种存储编译器和硬件,是它总是真的,其他进程将永远不会看到在10的值b不还看到值为5 a

If you prevent the compiler AND hardware from reordering these two stores then by definition yes. 如果您阻止编译器和硬件对这两个存储区重新排序,那么按定义是。

But, good luck with that. 但是,祝你好运。 Just use a mutex, and your life will be much easier. 只需使用互斥锁,您的生活就会轻松得多。

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

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