Cache Memory in Computers and Laptops
Anyone using electronic gadgets with memory (RAM), will definitely know about the term ‘cache’. We more often see this cache memory in computers and laptops and mobiles.
In this article, we will understand what is cache memory in computers and laptops.
So, in this article, we will see what is the importance of this cache memory, what is a typical size of this cache memory, and what are the different levels of cache memory that we find inside the computers.
Before we understand this cache memory, let’s see different kinds of memory that we see inside our computers.
Types of Memories in Computers
1. Non-Volatile Memory (ROM)
The first kind of memory that we find inside our computer is the non-volatile kind of memory. Like a hard disk drive.
This hard disk drive contains a mechanically rotating fast disk, which is also known as platters.
And if you see any commercially available hard disk drive, the typical rotating speed of the disk is either 5400 or 7200 RPM.
So, as this hard disk drive contains a mechanically rotating part, so in terms of the speed, they are quite slow.
The typical read or write speed that you get with this hard disk drive is in the range of 80 to 150 MBPS.
But if you see the clock speed of the CPU, it is in the range of 1GHz up to the 4 GHz.
Even though the processor is capable of accepting a much higher speed, it can’t get the data through this hard disk drive at the same rate.
And that is where this second kind of memory comes into the picture.
2. Volatile memory (RAM)
That is nothing but Random Access Memory.
Now, this Random Access Memory is faster compared to the hard disk drive. So, this RAM can provide data to the CPU at a much faster rate compared to the Hard disk drive.
But still, it is slower than the clock speed of the CPU. So, the typical speed of the RAM is in the range of 400 MHz up to 800 MHz.
Still, it is slower than the clock speed of the CPU. But if you see the newer generations of the RAM like DDR3 and DDR4, then they can operate at much faster rates like 1600 MHz or up to the 2100 MHz.
So, now if you see the speed of these RAMs, they are comparable to the speed of the CPU.
Now, you may say that this newer version of RAM can supply data to the CPU at the rate at which they want.
But the answer is no.
What is Cache Memory?
The modern-day processors which we are using are not single-core processors but they are multicore processors.
This processor could be either dual-core, quad-core, or maybe even octa-core.
If all the cores are asking for data at the same time, then this RAM can’t be able to deliver the data to all the cores at the same time.
And that is where this cache memory comes into the picture. So, this cache memory is the fastest among all memories.
This cache memory is also Random Access Memory but it is a special kind of RAM, which is known as Static RAM.
Unlike the Dynamic RAM, which we find inside the normal RAM, this static RAM is quite fast.
And the typical size of this cache memory is in the range of KiloBytes up to the Few MegaBytes.
So, the data which is frequently required by the CPU can be supplied by this cache memory.
Generally, some instructions and data which are required by the CPU are stored in this cache memory. So, now let’s see the different levels of this cache memory.
Types of Cache Memories
1. Level 1 Cache (or) L1 Cache
The first level of cache memory is known as Level 1 cache or L1 cache. So, in this level 1 cache, a tiny amount of memory is integrated inside the CPU itself.
And all the cores inside the CPU have their individual level 1 cache. So, as this level 1 cache is integrated inside the CPU, so they can operate at the same speed as the CPU.
And that is the reason, level 1 cache is fastest among all caches. Now, the typical memory size of this level1 cache is 2KB up to 64 KB.
Now inside this level 1 cache, there are two kinds of the cache. The one is the instruction cache and the second data cache.
So, the instruction cache stores all instructions which are required by the CPU, and the data cache stores the data which is required by the CPU.
2. Level 2 Cache (or) L2 Cache
Now, let’s see the second level of cache. So, this cache is known as either Level 2cache or L2 cache.
This level 2 cache could be either inside the CPU or it could be outside the CPU. Now, this level 2 cache could be separate for all the cores or it could be shared between all cores of the CPU.
If this level 2 cache is outside the CPU, then it is connected with a very high-speed bus with the CPU.
The memory size of this level 2 cache is in the range of 256 KB to the 512 KB. But in terms of speed, they are slower than the L1 cache.
3. Level 3 Cache (or) L3 Cache
Now, the third kind of cache is known as Level3 cache.
So, all the processors do not have this level3 cache, but some higher-end processors have this level 3 cache.
And this level 3 cache is used to enhance the performance of this level 1 and level 2 cache. So, now this level 3 cache is shared among all cores. And it is outside the CPU.
The memory size of this level 3 cache is in the range of 1 MB up to the 8 MB for high-end processors.
But it is slower than the L1 and L2 cache. But still, it is faster than the Random Access Memory or RAM.
How does Cache Memory work?
Now let’s see the process flow when the CPU needs some data. So, whenever the CPU needs some data, then, first of all, it will look inside the L1 cache.
If it is not found inside the L1 cache then it will look inside the L2 cache. And if data is inside the L2 cache then it will look into the L3 cache.
So, if the CPU finds the data inside the cache memory then it is known as a cache hit. But if data is not unavailable inside the cache then it is known as a cache miss.
Suppose if data is not available in the L3 cache, the CPU will look inside the Random Access Memory or RAM.
And still, if it doesn’t find any data inside the RAM then it will get that data from the Hard Disk Drive.
When you are starting your computer for the first time or you are opening some application for the first time, then that data will not be available in either cache memory or in RAM.
At that time CPU will get that data from the hard disk drive. But, once the application is open and thereafter if it requires some data then the CPU will get that data from either RAM or cache memory.
Now, you may ask if this cache memory is so fast then why the size of this cache memory is only in MegaBytes.
The reason is that this cache memory is much much costlier than the other memories. And that is the reason you find only a few MegaBytes of cache memory inside the CPU.
Whenever you are buying some desktop or laptop for yourself, don’t only look at Random Access memory but also look at how much cache memory that CPU has.
Because this cache memory decides the overall performance of the processor. And the same thing is applicable for the smartphone processors as well.
I hope in this article you understood what is cache memory and what is the significance of this cache memory inside the computers.
know more about this cache memory here
Hey, if you want to give any suggestions to the tech geek, then comment down below.