Cache memory: Difference between revisions

From Computer Science Wiki
No edit summary
No edit summary
 
(One intermediate revision by one other user not shown)
Line 8: Line 8:




Cache memory is used to reduce the average memory access times. This is done by storing the data that is frequently accessed in main memory addresses therefore allowing the CPU to access the data faster. This is due to the fact that cache memory can be read a lot faster than main memory. There are different types of cache (e.g. L1,L2 and L3)<ref>https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory</ref>
Cache memory is used to reduce the average memory access times. This is done by storing the data that is frequently accessed in main memory addresses therefore allowing the CPU to access the data faster. This is due to the fact that cache memory can be read a lot faster than main memory. There are different types of cache (e.g. L1,L2 and L3).  Reference from https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory which is now kaput.




Line 36: Line 36:
<iframe width="560" height="315" src="https://www.youtube.com/embed/6JpLD3PUAZk" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/6JpLD3PUAZk" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</html>
</html>
== Standards ==
* Explain the use of cache memory.
== References ==
== References ==



Latest revision as of 08:08, 18 October 2021

This is a basic concept in computer science

Cache is very fast and small memory that is usually on the CPU.

  1. Cache memory can be accessed/is faster than RAM;
  2. It is used to hold common/expected/frequently used data/operations;
  3. It is closer to CPU than RAM/situated between RAM and CPU/on same board as CPU/ with faster read/write speed;


Cache memory is used to reduce the average memory access times. This is done by storing the data that is frequently accessed in main memory addresses therefore allowing the CPU to access the data faster. This is due to the fact that cache memory can be read a lot faster than main memory. There are different types of cache (e.g. L1,L2 and L3). Reference from https://compsci2014.wikispaces.com/2.1.3+Explain+the+use+of+cache+memory which is now kaput.


The steps to access the data from cache memory are:

  • A request is made by the CPU
  • Cache is checked for data
  • If the data is found in the cache it is returned to the CPU (this is called a cache hit)
  • If the data is not found in the cache then the data will be returned from the main memory.

There is a wonderful analogy I found here. If you are confused about cache memory, I suggest you read the top part of this story.

Cache memory is fast because:

  • In the case of a CPU cache, it is faster because it's on the same die as the processor. In other words, the requested data doesn't have to be bussed over to the processor; it's already there.
  • In the case of the cache on a hard drive, 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).

So it's about locality, mostly. Cache eliminates the data transfer step.

Locality is a fancy way of saying data that is "close together," either in time or space. Caching with a smaller, faster (but generally more expensive) memory works because typically a relatively small amount of the overall data is the data that is being accessed the most often.[1]

DRAM today has a cycle time of around 70ns. Cache is on-die static RAM and has an access time of around 6ns.[2]


Standards[edit]

  • Explain the use of cache memory.


References[edit]