A memory hierarchy organizes different forms of computer memory based on performance. Memory performance decreases and capacity increases for each level down the hierarchy.
Cache memory is placed in the middle of the hierarchy to bridge the processor-memory performance gap.
Cache is memory placed in between the processor and main memory. Cache is responsible for holding copies of main memory data for faster retrieval by the processor.
Cache memory consists of a collection of blocks. Each block can hold an entry from the main memory. Each entry has the following information:
A cache hit is when a computer processor finds the data it needs inside cache memory.
When a program requests data from memory, the processor will first look in the cache. If the memory location matches one of the tags in a cache entry the result is a cache hit and the data is retrieved from the cache.
Cache hits improve performance by retrieving data from a smaller and faster memory source.
A cache miss is when a computer processor does not find the data it needs in cache memory and must request it from the main memory. The main memory places the memory location and data in as an entry in the cache. The data is then retrieved by the processor from the cache.
A replacement policy defines how data is replaced within the cache. Examples of replacement policies are:
Associativity, or placement policy, is the process of mapping locations in main memory to specified blocks in the cache.
A cache write policy defines how data is written to the main memory once it is written to the cache.