Function, levels, and characteristics of cache memory
Cache memory also known as CPU memory is a high-speed intelligent memory buffer that temporarily stores data the processor needs. This allows the computer processor to execute instructions faster. Cache reduces retrieval time compared to if data was accessed directly from the main memory (RAM). It is said to be intelligent since it not only stores data but it stores the data that will be used by the processor on its next execution.
It is made up of Static RAM (SRAM) which is either integrated into the processor or in a separate chip within the computer motherboard. Its main function is to increase the processor speed. There are 3 levels of cache memory L1, L2, and L3. In their architecture, they are arranged in such a way that the processor looks for data from cache L1 up to L3 in that order.
Functions of cache memory
Cache memory is implemented in computers since it is very fast memory that can keep up with processor speed. Its primary function is to increase system performance by reducing data retrieval time from the main memory.
Computer processors are fast devices when compared to main memory (RAM). So manufacturer had to come up with a way to ensure the speed is not reduced by retrieving data from slower RAM. A cache is expensive to manufacture but it is worth compared to the improvement it gives the computers.
Architecture and block diagram of cache memory
Cache being within the processor microchip means it is close to the CPU compared to any other memory. Different cache levels are arranged in such a way that data is retrieved in a hierarchy order.
When the processor requires to execute any instructions it checks the data from the level 1 cache. If it is not available it moves next on the hierarchy which is level 2 and then 3. In case we have a cache miss on all levels then data is requested from the main memory.
Again in the event that still data was not loaded into the RAM then it can be retrieved from secondary storage (Hard disk). This hierarchy of data requests is followed all the time to ensure system consistency.
Levels and types of cache memory
There are 3 main cache levels depending on how fast the processor can retrieve data from them. Cache memories are classified into 2 types primary and secondary cache. Primary caches are integrated within the processor while secondary were housed in a different chip but today most caches are within the processor chip.
Level1 cache (internal cache)
This is the cache that is built within the processor chip. It runs at the speed of the processor and it is the first place CPU looks for data before checking other caches. It holds the current working code and it has no wait state since it works at the same speed as the CPU. It has the smallest memory capacity among all the memories which is in KiloBytes (KB).
Level 2 cache
In the old computer system, the memory was a separate chip within the motherboard and it operated at the clock speed of the motherboard. This means was slower than level 1 but faster than the main memory. With the latest computers, level 2 is now integrated within the processor chip just like level 1.
When a cache miss occurs on level 1 the processor now looks for the data on the level 2 cache which also operates at the processor speed.
Level 3 cache
This is the 3rd level cache and it has the biggest memory capacity which ranges into megabytes (MB). When we have a cache miss on L1 and L2 then the processor checks from L3. If still not available then it requests data from the main memory. For multi-core processors, L3 can be shared among cores while both L1 and L2 are dedicated to their own processor cores.
Characteristics of cache
- Very fast memory compared to other computer memories.
- Made of SRAM types of memory. The memory circuitry doesn’t require to be refreshed to keep data.
- Cache memory is integrated within the processor microchip. For the standard user, you cannot go and buy a cache memory for your computer to upgrade.
- It is a volatile memory. This means it keeps data only when the device is powered. When the power goes OFF the data is lost.
Advantages of using cache memory
- Cache increases the overall computer processing speed by offering faster data retrieval.
- It is faster than the main memory of the computer.
- Cache memory is integrated within the processor microchip. This means it is part of the processor.
- The memory provides data in advance before the processor request it.
Disadvantages of CPU cache
- They are expensive to manufacture compared to other memories. This is why they have a small capacity.
- The cache has a limited storage capacity. Level 1 cache has capacity in the range of KB and the highest is MB for level 3.
- The processor will still have a cache miss which means some time processor will have to wait for the data from slower RAM.
- Cache store data temporarily only when the system is powered.
- The processor chip requires a bigger space to accommodate the memory components.
Cache controller
The controller is what makes the cache to be intelligence. It helps to guess which data the processor requires next and bring it to the cache. Without the cache controller, the cache can’t tell which data processor will use next and we will have cache misses.
What is cache miss?
When a processor requests data from the cache and at that time it is not available then it creates a condition called a cache miss. The cache miss can occur at any level but most modern computers have less than 5%, cache miss. This means that more than 95% of the time the processor is working at optimum.
What is cache hit?
Every time the processor requests data from the cache and it is available it is a cache hit. Most systems can have a cache hit of more than 98%. This means 98% of the time the cache controller was able to predict the data that the processor will use next.
How to check cache memory in windows 10
To view the cache size of your computer using the windows 10 operating system open the task manager. Click on the performance tab which shows the performance of the CPU, memory, disk, and network. You will see windows that give the size of the 3 levels of cache as shown below.
As you can see L1 is the smallest and L3 is the largest of them all.