What is Store buffer?
A small buffer in which a core holds writes temporarily. The core can move on without waiting for writes to complete, but other cores see the writes later.
Japanese name: ストアバッファ
A small buffer in which a core holds writes temporarily. The core can move on without waiting for writes to complete, but other cores see the writes later.
Japanese name: ストアバッファ
When a core executes a store, the target cache line may be missing or held by another core, and gaining write ownership through the coherence protocol can take many cycles. Rather than stall, the core places the address and data in a store buffer and continues executing. Entries drain into the L1 cache later, typically in program order on x86. In out-of-order processors the store buffer also holds speculative stores, which cannot be written to the cache until the store instruction commits and is known not to be squashed.
Because recent stores may still be sitting in the buffer, every load checks it for a matching address. If it finds one, the load takes the data from the newest matching entry instead of from the cache, a mechanism called store-to-load forwarding. This keeps single-threaded behavior intact: a core always sees its own writes immediately, in program order. Forwarding works best when the load reads exactly the bytes a single earlier store wrote; partial overlaps between a load and buffered stores often force the load to wait until those stores drain.
Other cores cannot look into a core's store buffer, so a buffered write is invisible to them until it drains. Consider x and y both 0, with core 1 running x = 1 then r1 = y, and core 2 running y = 1 then r2 = x. Under sequential consistency at least one load must see 1. With store buffers, both stores can wait in their buffers while both loads read 0 from the caches, so r1 = r2 = 0 occurs on real x86 machines. A memory barrier between the store and the load, which waits for the buffer to drain, forbids this result.
The x86 model, total store order (TSO), essentially describes a first-in, first-out store buffer: stores stay ordered with stores and loads with loads, and only a later load to a different address may appear to pass an earlier store. Weaker models such as those of Arm and RISC-V also allow stores to become visible out of order, among other reorderings, so they need fences or acquire/release instructions more often. Programmers normally rely on language-level atomics, which the compiler maps to the right fences.
Answer: C. In what order a core's reads and writes to multiple addresses may be observed by other cores
For performance, CPUs may reorder memory operations, for example by holding writes in a store buffer or performing reads early. They are designed so that results within one core are unchanged, but other cores may observe the operations in a different order. A memory consistency model defines which reorderings can occur and is the contract that lets programmers write correct synchronization.
Answer: C. It is a relatively strong model that allows only a later read of a different address to appear before an earlier write
Under TSO, writes stay ordered with writes, reads with reads, and a write after a read stays ordered; only a read of a different address may overtake an earlier write. This model directly reflects the presence of a store buffer. Many programs behave intuitively within these limits, so barriers are needed relatively rarely on x86.
It is when a load finds a matching earlier store still waiting in the store buffer and takes its data directly from there, so the core sees its own pending writes without waiting for them to reach the cache.
Each core's write sits in its own store buffer, invisible to the other core, while its following load reads the old value from cache; a memory fence between the store and load prevents this.
Total store order is essentially the behavior of a FIFO store buffer: the only reordering it allows is a later load to a different address completing before an earlier store becomes visible.
Store buffer appears in 3 practice questions across 1 topic, including Multicore & Synchronization.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.