Will other threads see a variable entry saying "volatile" in a reasonable amount of time?

When you ask about a more specific issue , I find this to be a key issue when people are not completely sure.

The following assumptions can be made:

  • The processor uses a cache coherence protocol such as MESI (F) (examples: x86 / x86_64 and ARMv7mp) It is assumed that the variable
  • has a size that is atomically written / read by the processor (aligned and proper word size)
  • Variable declared volatile

Questions:

  • If I write to a variable in one thread, will other threads see the change?
  • What is the order of magnitude of the timeframe in which other threads will see the change?
  • Do you know about architectures where cache coherence is not enough to provide transparency between processors / cross-core?

The question is NOT:

  • Is it possible to use such a variable?
  • reordering issues
  • about c ++ 11 atomics

This may be considered a duplicate. In C / C ++, are there volatile variables that guarantee consistent semantics of betwen threads? and other similar questions, but I think that none of these clear requirements regarding the target architecture, which leads to a lot of confusion regarding various assumptions.

+4
source share
5 answers

, --?

, . , - , Intel, Intel QPI, .

Wiki Intel QPI :

http://en.wikipedia.org/wiki/Intel_QuickPath_Interconnect

+2

, ?

. , , , .

, ?

. .

, --?

, ++, . , , , "" ++.

, "". , (, , ).

+1

, , . , ( ) . , . , , , , , , , , .

, , , .

0

x86/64:

, ?

. , /-.

, ?

, . , = 200 NUMA node. node, 2 node. . , +/- 50 .

60-70ns 3GHz node.

, --?

, - . , , , , , x86, . , .

0

, , volatile "" .

, ( ) .

() PowerPC , - volatile. , , ( ).

, , , (, , ..) , , .

volatile ++ , --. volatile, , , , ( ). - .

, . , , , , ( ..), .

, - volatile, . , , , . ( ) , , , .

++ ( , , , ), , , , , volatile. - - - , . (, , , , ).

0

Source: https://habr.com/ru/post/1618007/


All Articles