• Shared memory Processor
Distributed memory processor
Basic structure of centralized shared memory
multiprocessor
• The use of large multilevel caches can substantially reduce memory
bandwidth demands of a processor.
• This has made it possible for several (micro)processors to share the same
memory through a shared bus.
• Caching supports both private and shared data.
– For private data, once cached, it's treatment is identical to that of a
uniprocessor.
– For shared data, the shared value may be replicated in many caches.
• it also introduces a problem: Cache coherence
Cache Coherence
• With multiple caches, one CPU can modify memory at locations that other
CPUs have cached.
• For example:
• CPU A reads location x, getting the value N .
• Later, CPU B reads the same location, getting the value N .
• Next, CPU A writes location x with the value N - 1 .
• At this point, any reads from CPU B will get the value N ,
while reads from CPU A will get the value N - 1 .
• This problem occurs both with write-through caches and (more seriously)
with write-back caches.
Another example…
Multiprocessor Cache Coherence
• Memory system is coherent, if any read of a data item returns the most
recently written value of that data item.
• This definition, is vague and simplistic; the reality is much more complex.
• This simple definition contains two different aspects of memory system
behaviour, which are critical to writing correct shared-memory programs.
– The first aspect, called coherence, defines what values can be
returned by a read.
– The second aspect, called consistency, determines when a written
value will be returned by a read.
A memory system is coherent if
1. A read by a processor P to a location X that follows a write by P to X,
with no writes of X by another processor occurring between the write and
the read by P, always returns the value written by P.
2. A read by a processor to location X that follows a write by another
processor to X returns the written value if the read and write are
sufficiently separated in time and no other writes to X occur between the
two accesses.
3. Writes to the same location are serialized; that is, two writes to the same
location by any two processors are seen in the same order by all
processors.
4. For example: If the values 1 and then 2 are written to a location,
processors can never read the value of the location as 2 and then later
read it as 1.