Parallel Processors and Cache Coherency in Shared Memory Systems

Parallel Processors and Cache Coherency in Shared Memory Systems

Verified Sources
Nov 4, 2026

Parallel processors execute multiple instructions concurrently by using multiple processing elements (e.g., cores, CPUs, or specialized accelerators). In shared memory systems, all processors access a logically common address space, but each processor typically has private caches for performance. The tension is that caches can hold stale or conflicting copies of the same memory block, so the system must enforce cache coherency: a consistent rule for what value reads should observe after writes. This is the core of the cache coherency problem in shared memory multiprocessors.

A useful mental model is: processors may run in parallel, but memory appears “as if” operations are properly ordered according to the memory model, which the hardware must approximate using protocols and interconnect behavior.

Key concepts you’ll use repeatedly:

  • parallel processor
  • shared memory
  • cache coherence
  • cache line
  • memory model

Why coherency is hard: consider two cores that both cache the same cache line. If core 1 writes to its cached copy without informing core 2 (or without the protocol ensuring invalidation/update), core 2 may later read an outdated value from its own cache—leading to incorrect behavior even though both cores “see” the same shared address space.

Important distinction: Cache coherence is about values and visibility across caches; correctness still also depends on the system’s memory model and how software uses synchronization.

Cache Coherence: MESI Protocol (intuitive explanation)

Parallel processors: how they differ (and why coherency shows up)

Parallel processing can be organized at multiple levels:

  1. Instruction/data parallelism (vector/SIMD): a single instruction stream operates on many data elements. Coherency issues are usually less about multiple writers to the same address and more about memory bandwidth and alignment.
  2. Multiple-instruction, multiple-data (MIMD): different cores run different instruction streams on different data. Coherency becomes central when cores can read/write overlapping memory regions in shared memory.
  3. Shared-memory MIMD multiprocessors: each core has caches; all cores communicate via shared interconnect and memory. Coherency protocols coordinate cache states and interconnect transactions.

Common shared-memory hardware mechanisms:

  • Snooping (bus-based): caches “snoop” transactions on a broadcast interconnect; when a write occurs, other caches can invalidate/update their copies.
  • Directory-based coherence: a centralized (or distributed) directory tracks which caches hold copies of each cache line and directs invalidations/updates.

Key terms:

  • snooping
  • directory-based coherence
  • invalidation
  • update protocol
  • shared cache state

The cache coherency problem in more detail

Assume:

  • Each cache contains a copy of some cache lines.
  • A cache line can be in one of several coherence states (exact set depends on protocol).
  • Reads/writes are served by caches when possible.
  • Without coordination, multiple caches may diverge.

A canonical scenario (no coherence):

  1. Core 1 reads address XX → loads cache line containing XX into its cache.
  2. Core 2 reads address XX → also loads the same cache line into its cache.
  3. Core 1 writes to XX (modifies its cached line).
  4. Core 2 later reads XX → still has the old cached line, returns stale value.

Coherence protocols prevent this by enforcing invariants such as:

  • Before a core reads a line, the protocol ensures it has a valid copy according to the protocol rules.
  • Before a core writes a line, the protocol ensures no other cache has a conflicting usable copy (or updates them).

Cost model: coherency requires extra control traffic (invalidation/update messages), possible stalls, and serialization effects on the interconnect.

How a write typically propagates coherency (invalidation-based intuition)

  1. 1
    Step 1

    Multiple cores may hold the same cache line in a shared/clean state.

  2. 2
    Step 2

    The writing core intends to modify the cache line.

  3. 3
    Step 3

    The coherence protocol causes other caches holding that line to invalidate.

  4. 4
    Step 4

    After invalidations, the writer’s cache line moves into a state that allows modification.

  5. 5
    Step 5

    The writer updates its cached data; other cores will fault/refresh on next read.

  6. 6
    Step 6

    Readers either miss and fetch, or receive updates according to the protocol.

Coherency vs. race conditions

Even with perfect cache coherence, data races can still occur at the software level. Coherence ensures cached values stay consistent; synchronization primitives ensure correct program order/visibility.

Coherence protocols and states (MESI family overview)

Many practical systems use state-machine protocols (e.g., MSI/MESI/MOESI). They treat each cache line as being in a state that describes:

  • whether the line is valid,
  • whether it is shared with others,
  • whether it is owned exclusively and can be modified,
  • and (in some protocols) whether another cache may have a copy.

In an MESI-like family:

  • Modified (M): cache line is dirty (changed) and unique to that cache.
  • Exclusive (E): cache line is clean and unique (not shared) to that cache.
  • Shared (S): cache line may exist in multiple caches and matches memory.
  • Invalid (I): cache line is not valid for use.

These states exist because “what actions are allowed” depends on whether other caches may also hold the line.

Key terms:

  • MESI
  • cache line invalid
  • dirty cache line
  • downgrade

False sharing: coherency makes it worse, not better

If independent variables share the same cache line, writes to one variable trigger invalidations for the entire line. Performance can degrade even when program logic is correct.

Shared-memory hardware coherence lifecycle (conceptual)

Caches hold copies

Initial

Cache lines may be loaded into private caches."

Coherence checks validity

Read phase

Reads use the cached line if protocol rules allow it."

Ownership transition

Write phase

A write requests a state that prevents conflicts (often invalidating others)."

Invalidation/update messages

Propagation

Other caches respond, enabling the writer to proceed correctly."

Continual state transitions

Ongoing execution

States change dynamically based on subsequent reads/writes."

Conceptual coherence traffic per operation (qualitative)

Coherence overhead depends on whether the operation causes invalidations or ownership changes.

Common questions about cache coherency

Cache Coherency Quick Checks

1 / 5
Question · Term

What is cache coherence?

Click to reveal
Answer · Definition

Rules/protocols ensuring cached copies of the same memory block remain consistent with respect to reads/writes.

Knowledge Check

Question 1 of 4
Q1Single choice

In a shared-memory multiprocessor, what problem does cache coherency primarily solve?