WHAT IS CACHE MEMORY? | LEVELS OF CACHE MEMORY | PROCESS FLOW

Advertisement

What is Cache Memory in computers and laptops? 

So, In this article, we will see what is the importance of the 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. So, before we understand what is cache memory, let’s see different kinds of memory that we see inside the computers.

What is Cache Memory

Different kinds of memory inside the computers.

Before we understand this cache memory, let’s see different kinds of memory that we see inside the computers.
   The first kind of memory that we find inside our computer is the non-volatile kind of memory, like a hard disk drive.

  • HDD (Hard Disk Drive)

Hard Disk Drive contains a mechanically rotating fast disk, also known as the platters. And if you see any commercially available hard disk drive, the typical rotating speed of the disk is either 5400 or 7200 RPM. As this hard disk drive contains a mechanically rotating part, so in terms of the speed, they are quite slow. So, the typical read or write speed that you get with hard disk is in the range of 80 to 150 MBPS. But if see the clock speed of the CPU, it is in the range of 1GHz up to the 4GHz. So, even though the processor is capable of accepting a data much higher speed, but it can’t get the data through this hard disk drive at the same rate.
   That is where the second kind of memory comes into the picture. That is Random Access Memory.

  • RAM (Random Access Memory)

RAM 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 slower than the clock speed of the CPU. So, the typical speed of the RAM is in the range of 400 MHz up to the 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 a much faster rate like 1600 MHz or up to 2100 MHz.
   So, now if you see the speed of these RAMs, they are comparable to the clock speed of the CPU. Now, you may say this newer version of the RAM can supply data to the CPU at the rate at which they want. But the answer is No.
   So, the modern-day processor which we are using is not a single core processor but they are multiple processors. So, this processor could be either dual-core, quad-core or maybe even octa-core. If all the cores are asking for the data at the same time, then this RAM can’t be able to deliver the data to all the cores at the same time. That is where this Cache Memory

Advertisement
comes into the picture.

Cache Memory

Cache Memory is faster among all memories. Cache Memory is also a Random Access Memory but it is a special kind of RAM, which is known as a Static RAM (SRAM). So, unlike the dynamic RAM, which we find inside the normal RAM, this SRAM 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 instruction and data which is required by the CPU are stored in this cache memory.

Different Levels of Cache Memory

Now let’s see the different levels of this cache memory. There are three levels of cache memory.

  1. Level 1 or L1.
  2. Level 2 or L2.
  3. Level 3 or L3.

  • Level 1 or L1 cache   

The first level of cache memory is known as Level 1 cache or L1 cache. In this L1 cache, a tiny amount of memory is integrated inside the CPU itself and all the cores inside CPU have their individual L1 cache.
   So, as this L1 cache integrated inside the CPU, so they can operate at the same speed as the CPU. That is the reason, level 1 cache is fastest among all caches.
   Now, the typical memory size of this L1 cache is 2 KB up to 64 KB. Inside this L1 cache, there are two kinds of the cache.

  1. Instruction cache.
  2. Data cache.    

Instruction cache stores all instruction s which are required by the CPU and the Data Cache stores data which is required by the CPU.

  • Level 2 or L2 cache   

The second level of cache memory is known as either Level 2 cache or L2 cache. Now, this L2 cache could be either inside the CPU or it could be outside the CPU. This L2 cache could be separate for all the cores or it could be shared between all the cores of CPU.
   So, if this L2 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 512 KB. But in terms of speed, they are slower than the L1 cache.

  • Level 3 or L3 cache   

The third level of cache memory is known as Level 3 cache or L3 cache. All the processors do not have this level  3 cache, but some higher-end processors have this level 3 cache. This level 3 cache is used to enhance the performance of this level 1 and level 2 caches. 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 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.

Cache memory

Process Flow

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. So, if it will not find inside the L1 cache then it will look inside the L2 cache, and if the data is not 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 RAM, and still, if it does not find any data inside the RAM then it will get that data from the hard disk drive. So, when you are starting your computer for the first time or you are opening some applications for the first time, then that data will not be available either in cache memory or in the RAM.
   So, at that time CPU will get that data from the hard disk drive. But, once the application is open and then after if it requires some data then CPU will get that data from either RAM or cache memory.
   Now, you may ask that if this cache memory is so fast then why the size of this cache memory is only in MegaBytes. So, the reason is that this cache memory is much costlier than the other memories. And that is the reason you find only a few MegaBytes of cache memory inside the CPU.       So, whenever you are buying some desktop or laptop for yourself, don’t only look at the 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 to the smartphone processors as well.
   I hope you understand this cache memory. If you have any questions regarding the cache memory, let me know in the comments.

Leave a Comment