Cache Memory
Cache memory pronounced as cash, is a special, high speed, and expensive semiconductor memory paced between RAM and CPU. It is used in the CPU so that the CPU doesn’t have to wait for data to be delivered. The most frequently used instructions are kept in the cache memory so that the CPU can look there first. This allows the CPU to run faster because it doesn’t have to take to swap instructions in and out of RAM. It is made by the components of static RAM. It is usually 5 to 10 times faster than the main memory. The speed of the CPU is faster than RAM. Hence, cache memory is placed in between CPU and RAM so that the speed of operation of the main memory and cache memory together can meet the speed requirements of the high-speed CPU.
There are two types of cache memory. They are:
- Internal cache
- External cache
Cache present in the CPU is known as internal cache and cache present in outside CPU is known as an external cache.
When the processor needs data and instructions, first it checks whether that data is in the cache or not. If the CPU finds data in the cache, we say that a cache hit; otherwise, we say that a cache miss. In the case of cache hist, the CPU immediately reads or writes the data in the cache. The proportion of accesses that result in a cache hit is known as the hit rate and is a measure of the effectiveness of the cache. In the case of a cache miss, it copies the data from memory. Misses are comparatively slow because they require the data to be transferred from the main memory. This transfer results in a delay since the main memory are much slower than cache memory, and also results in the overhead for recording the new data in the cache before it is delivered to the CPU.
In general, the cache has two levels, Level 1(L1) and Level 2(L2). In which, L1 is smaller and the faster among two and L2 is larger but slower. Multi-level caches generally operate by checking the smallest L1 cache first; if it hits, the processor proceeds at high speed. If the smaller cache misses, the next larger cache L2 is checked, and so on, before the main memory is checked.