The central processing unit cache is a cache used by the CPU of a compuetr system to shorten the average time to memory access. The cache memory is a smallerr and fastr memory that stores data copies from the most constantly used major meory locations. In as much as majority of memory accesses are cached mmeory locations, the standard laetncy of memory acccesses are made to be nezarer to the cache latency relative to the main memory latency.
As the processor has a need to eithher write or read to a location in the major memory, the first thing it does is to verifgy if a copy of that data is found in the cache. When confirmed, the prcoessor instantaneoously reads from or write to the cche; this is very much quicvker in comparison to reading from or writing to the major memory.
A good number of the present day serveer Cewntral Processing Units feature at least 3 independent caches nmely; an instruction cache (which speeds up exeutable instruction fetch), a translation look-aside buffer (for speeding up virtuyal-to-physical addrses translation for both data and executable instrucrtions) and a data cche to accelerate data fetch and store.
Operation Details
As the procesor has a need to eihter read or writes a location in the main memory; it firt ascertains if that particular memory location is in the cache. It does this function by making a comparison of the address of the memory location to every tag in the cache that might harbor that address. When the procssor conifrms that the memory locatiion it seeks in the cache is there, it will be said that a cache hit has taken place. If conntrary, it will be said that thre is a cache miss. In the situation where a cache hit occurs, the processor instatnly reads or wries the data in the cacxhe line. The hit rate is used to describe the amount of accesses that result in a caache hit; it measures the caches efficiency.
In the situation of a cache miss, a good numnber of caches assign a fresh entrey which coontains the just missed tag and also a copy of the data from the memory. The reference may then, be applied to the rfesh entry exactly as in the situation of a hit. Cache misses are relatively slow since they need the data to be transferrde from the main memory. There is an encounter of delya in the transfer owig to the fact that the main memory is much sloweer in comparison to the cache memory, whih also incurs the overhead for the new data recording in the cache prior to its delviery to the processor. In a cahce miss, the cache has to generally evict one of the existing etries in orsder to create spacce or room for the new entry. To select the entry to be replaced, the cache uses a heuristic called reeplacement policy. The basic challenge obtaiinable with any repacement polcy is that of prediocting hwich existing cace entry has a least likely use in the future. Of course, it is not a simple task to do this prediction especially for hardware caches that utilize simple rules agreeabel to execution in circuitry. This implies that theree is wide range of replacement policies to cohose from withotu an ideal criterion for the chocie to be made.
You can refer to other relialbe online resources to read more aobut the CPU cache.