Multicore & Synchronization

Which describes sequential consistency?

  1. AEach core's operations run in a random order every time
  2. BAll cores' operations appear in some single order in which each core's operations occur in program order
  3. CAll operations run on a single core only
Show answer and explanation

Answer: B. All cores' operations appear in some single order in which each core's operations occur in program order

Under sequential consistency, the operations of all cores appear interleaved into one sequence, like shuffling cards, with each core's operations keeping their program order within it. It is the easiest model for programmers, but it severely limits hardware optimizations such as reordering through store buffers, so most real CPUs adopt looser models.

  • A. Program order is preserved, not randomized.
  • B. Correct. It is the most intuitive model.
  • C. It assumes multiple cores.
Practice this topic Back to topic

More Multicore & Synchronization questions

  1. The two threads above run simultaneously on different cores (assume no compiler reordering). Which outcome cannot occur under sequential consistency but can occur on real CPUs such as x86?
  2. What is a characteristic of the x86 memory consistency model (TSO, total store order)?
  3. Which statement is correct about weak memory consistency models such as those of Arm and RISC-V (RVWMO)?
  4. What is the role of a memory barrier (fence) instruction?
  5. In the code above, thread 1 prepares data and then signals with flag, and thread 2 waits for flag and then reads data. On a CPU with a weak memory model, what is needed for thread 2 to reliably read 42?