c++multithreadingc++11data-race

Is it a data-race when several thread *read* the same memory at the same time?


cppreference.com says:

Data races

When an evaluation of an expression modifies to a memory location and another evaluation reads or modifies the same memory location, the expressions are said to conflict. A program that has two conflicting evaluations has a data race unless...

This speaks about the scenario of 'thread1-modify thread2-read' (M-R) and about the scenario of 'thread1-modify thread2-modify' (M-M).

What about 'thread1-read thread2-read' (R-R)?


Solution

  • No. Multiple threads reading memory sequenced is not a data race as long as no thread is writing unsequenced in that memory location.

    That scenario was probably left out of that description of data races, because that scenario is not a data race.