简体   繁体   English

“与主存储器同步”是什么意思?

[英]What does “synchronization with main memory” mean?

短语“ synchronization with main memory ”是什么意思?

When you have multiple threads each thread may keep a local copy of a variable's value. 当您有多个线程时,每个线程可以保留变量值的本地副本。 However the "official copy" of the value is kept in main memory. 然而,价值的“官方副本”保存在主存中。 So what that phrase means is that any local copy of a variable's value will be made consistent with main memory (either reading to check for updates, or writing to publish updates made to the local copy). 因此,该短语意味着变量值的任何本地副本将与主存储器一致(读取以检查更新,或写入以发布对本地副本所做的更新)。

Synchronization helps to create read and write barriers. 同步有助于创建读写障碍。 ie it establishes a boundary whereby you can be assured that whatever be the order of operations (read/write) there will be a 'happens-before' relationship between them. 也就是说它建立了一个边界,你可以放心,无论操作的顺序如何(读/写),它们之间都会有“先发生过”的关系。 It makes it obvious for the processor to flush out all changes in local (cache/register) copies of objects under synchronization to the main memory, in the meanwhile giving no access to that particular memory instance under synchronization. 这使得处理器显而易见地将同步下的对象的本地(高速缓存/寄存器)副本中的所有更改清除到主存储器,同时在同步时不允许访问该特定存储器实例。

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

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