top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Why cache memory is faster than RAM?

+3 votes

I have few questions about Cache Memory

1) My understanding of cache memory is, there are 3 type of cache memory,
1. Within RAM
2. Within CPU (L1,L2,L3)
3. Separate Hardware which is costlier than all others.

Please correct if I am wrong,

2) Who stores the data into cache? I mean, can we write a program which should use only cache memory? If yes then how to do it? if no then who manages that?
For example,
Cache memory within RAM, is it managed by Kernel?(Memory Management Unit)
Cache memory within CPU, is it managed by CPU itself?

3) Why cache memory is faster than RAM?

posted Mar 18, 2016 by Chirag Gangdev

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

3 Answers

+1 vote
Best answer

A process need to access the memory time to time in its execution and it is a costly operation as comparte to access the data from the CPU registers. So in the evolution of computers a memory was placed on the CPU chip itself (or placed on a separate chip that has a separate high speed bus interconnect with the CPU) which is faster, closer and smaller then external memory (RAM) and make the program execution faster. CPU transfers the frequently used data to Cache time to time.

Over the period of time cache is evolved into L1, L2, L3 and L4 cache which are slower then previous one in terms of speed. So to understand better assume the L1, L2, L3, L4 and RAM as memory which are in increasing order in terms of size and decreasing order in terms of speed. So when L1 cache miss, means the CPU has to go scampering off to find the data elsewhere. This is where the L2 cache comes into play — while it’s slower, it’s also much larger. If data can’t be found in the L2 cache, the CPU continues down the chain to L3 , then L4 (if it exists) and main memory (RAM/DRAM). And all this is part of larger memory management module of operating system.

answer Mar 22, 2016 by Salil Agrawal
Sir, Really Really nice explanation,
But still i am having this doubt,
1st ) Is that external cache is same as CPU cache? or it is a separate hardware?
2nd ) Who decides whether to store this data to cache memory?
For CPU cache, how CPU will take a decision whether to put this data in cache or not?
As far as i know CPU is used to just to execute instruction at a very high speed then how he is responsible for making decision?
And for RAM memory cache whether to use cache or not is decided by kernel, right?
Cache these days is layered, means we have a L1 cache (cpu cache), L2 cache, L3 and in some cases L4 also. Except L1 (in some cases L2) all cache is the separate chip.
All cache management is done my the Memory Management section of OS which has a separate module for cache management.
It Helps, Thank you Sir
0 votes

Why cache memory is faster than RAM?

It's faster because it's in solid state memory, and not still on the rotating platters.
In the case of the cache on a web site, it's faster because the data has already been retrieved from the database (which, in some cases, could be located anywhere in the world).

answer Mar 18, 2016 by Ajay Kumar
–1 vote

Firstly cahce is secondary memory and RAM is primary memory. For some programs/applications we need to have faster response. And for this purpose there is a memory named cache which stores data/information for small amount of time. Once the data is used is no longer needed, it is erased completely. And this gives a better performance in response to the request.

answer Mar 22, 2016 by Gvoardhan U
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.