In both cases, the instruction stream continues as soon as the cache access completes, without waiting
for slower memory to catch up.
The cache on a SPARCstation 2 holds 64 Kbytes of write-through data, and a line is 32 bytes in size.
Much larger caches are becoming commonplace: the SPARCserver 1000 has a 1-Mbyte write-back
cache memory. There may be a separate cache for the I/O bus if the processor uses memory-mapped
I/O, and there are often separate caches for instructions and data. There can also be multi level caches,
and caches also can be applied whenever there is an interface between fast and slow devices (e.g.,
between disk and memory). PC's often use a main memory cache to help a slow disk. They call this
"RAMdisk". In UNIX, disk inodes are cached in memory. This is why the filesystem can be corrupted
by power-ing the machine off without first flushing the cache to disk with the "sync" command.
Cache and virtual memory are both invisible to the applications programmer, but it's important to
know the benefits that they provide and the manner in which they can dramatically affect performance.
Table 7-1. Cache Memories Are Made of This
Term Definition
Line A line is the unit of access to a cache. Each line has two parts: a data section, and a tag
specifying the address that it represents.
Block The data content of a line is referred to as a block. A block holds the bytes moved between a
line and main memory. A typical block size is 32 bytes.
The contents of a cache line represent a particular block of memory, and it will respond if a
processor tries to access that address range. The cache line "pretends" to be that address range
in memory, only considerably faster.
"Block" and "line" are used loosely and interchangeably by most people in the computer
industry.
Cache A cache consists of a big (typically 64 Kbytes to 1 Mbyte or more) collection of lines.
Sometimes associative memory hardware is used to speed up access to the tags. Cache is
located next to the CPU for speed, and the memory system and bus are highly tuned to
optimize the movement of cache-block-sized chunks of data.
Handy Heuristic
One Experience with Cache
Run the following program to see if you can detect cache effects on your system.