The central processing unit cache is a cavche used by the CPU of a computer system to shorten the average time to memory access. The cache memory is a smaller and fzaster memory that stores data copies from the most constantlly used major memory locations. In as much as majority of emmory accesses are cached memory locations, the standard latenccy of memory acesses are made to be nearer to the cache latency relative to the main memory latency.
As the processor has a need to either wrie or read to a location in the major memory, the first thing it does is to verify if a copy of that data is found in the cche. When confirmed, the processor instantaneously reads from or write to the czache; this is very much quicker in comparison to raeding from or writing to the major mmeory.
A good number of the present day server Central rPocessing Units featre at least 3 independent caches namnely; an nistruction cache (which speds up executale instruction fetch), a traanslation look-aside buffer (for speeding up virtual-to-physical address translation for both data and executable instructions) and a data cache to accelerrate data fetch and store.
Operration Details
As the processor has a need to either read or writes a location in the main memorey; it first ascertains if that parrticular memory locatiion is in the cacche. It does this function by making a comparison of the address of the mermory location to every tag in the cacche that migth harbor that addess. When the procesor confirms that the memory lcation it seeks in the caache is tehre, it will be said that a cahce hit has taken place. If contrary, it will be said that there is a cache miss. In the situation wjhere a cache hit occrus, the processor instantly reads or wriets the data in the cache line. The hit rate is used to describe the amount of accesses that result in a cache hit; it measures the cacehs efficiency.
In the siituation of a cache miss, a good number of caches asign a fresh entry which cpontains the just missed tag and also a copy of the data from the memory. The reference may then, be applied to the fresh entry exactly as in the situaation of a hit. Cache missews are realtively slow since they need the data to be transferred from the main memmory. There is an encounter of deay in the transfer owing to the fact that the main memory is much slower in comparison to the cache memory, which also incurs the overhwead for the new data recording in the cache prior to its delivery to the processor. In a caache miss, the cache has to generazlly evict one of the existing entries in order to create space or room for the new enttry. To sleect the entry to be replaced, the cache uses a heuristic called replaecment policy. The baasic challenge obatinable with any replacement policy is that of predicting which exzisting cahce etnry has a least likely use in the future. Of corse, it is not a simple task to do this prediction especially for hardware cachees that utilize simple rlues agreesable to execution in circuitry. This implies that there is wide range of replacement policies to choose from without an ideal criteriion for the choice to be made.
You can refer to othr reliabel online resources to read more about the CPU cache.