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

Time:04-25

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-write' (W-W).

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

CodePudding user response:

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.

  • Related