Primary memory is directly addressable by CPU and electronics.
Wikipedia : "CPU cache"
Register:
Internal to CPU.
Architecturally defined.
addressed by "name" (native operand).
preset quantity and configuration.
Very fast access.
Expensive.
Very small quantity.
|
Main memory:
External to CPU.
Addressed by numeric values.
Slower than CPU.
Less expensive.
Large quantities, limited by CPU/bus address width.
Quantities vary, not required to fill full address range.
|
Principle of locality.
Locality example :
int I,
float num[100]
for I = 0 to 99
do
num[i] = num[i] + num[i] * .05
done
Spacial - the num array is usually implemented as a set of adjacent
memory cells and the set of values composing the instruction sequence
are also stored together.
i.e CSECTs (4K block).
Temporal - the small set of instructions composing the loop are
repeated 100 times as is access to the block of memory holding array.
Caching principles
A cache is a small block of high speed memory that acts like
addressable primary memory, usually 16K - 256K.
Caching works by providing enough high speed memory to handle the
current task's data and code.
This works because of the principle of locality.
A workable sized block of high speed memory provided for a limited
but significant amount of time.