2

cppreference.com says:

Threads and data races

When an evaluation of an expression writes 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-write thread2-read' (W-R) and about the scenario of 'thread1-write thread2-modify' (W-M).

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

Amit
  • 645
  • 1
  • 3
  • 19
  • 8
    short answer is no. If you are just reading, there would be no race. But you have to be sure that you are ONLY reading. – timpone Apr 20 '22 at 14:18
  • Well, since it doesn't mention that situation in the context of data races... – molbdnilo Apr 20 '22 at 14:18
  • In particular, as long as the data at that memory-location never changes, any and all threads can reliably read that location and see the same value. – Jeremy Friesner Apr 20 '22 at 14:23

1 Answers1

4

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.

eerorika
  • 232,697
  • 12
  • 197
  • 326