What is Data race?

A situation in which threads access the same variable concurrently without synchronization and at least one access is a write. Results vary between runs; in C and C++ it is undefined behavior.

Field: Multicore & Synchronization

Data race in the explanations

Questions that mention Data race (4)

  1. Which describes a data race?
  2. When two threads run the code above simultaneously, the final counter can be less than 200000. Why?
  3. What does a fetch-and-add instruction, such as RISC-V amoadd.w or x86 lock xadd, do?
  4. Which describes a critical section?

Related terms

Critical section ABA problem Acquire-release semantics Atomic instruction Barrier synchronization Bus snooping Compare-and-swap Condition variable Deadlock Directory-based coherence

Back to the glossary