Hello Friends, in this blog post I am going to explain to you the cache memory, which is related to programming. We will cover the use and working procedure of cache memory.
Inside this blog post, we will explore Why do we use cache memory? What are the 3 types of cache memory? How does cache memory work? What are cache memory and its types?
It is very simple to understand the concept of cache memory, you can easily learn this with the help few real-life examples related to the cache memory.
if we take a real-life banking example, when we go to a bank then we usually get withdrawal and deposit voucher on the desk as they are most frequently used whole day in the bank, so if the bank will assign a resource for doing this then it will be a burden on a bank in terms of time and money both.
Whereas NEFT voucher is not kept usually at the common desk in the bank as they are rarely used in a whole day.
So in a similar fashion to programming, if the active portion of the program and data are placed in fast small memory, the average memory access time can be reduced, thus reducing the total execution time of the program. Such a fast small memory is called cache memory.
it is placed between the CPU and main memory, as shown in fig 1 below. The cache memory access time is less than the access time of the memory. by a factor of 5 to 10. The cache is the fastest component in the memory hierarchy and approaches the speed of CPU components.
The fundamental idea of the organization is that by keeping the most frequently accessed instructions and data in the fast cache memory, the average memory access time will approach the access time of the cache.
Although the cache is only a small fraction of the size of the main memory, a large fraction of memory requests will be found in the fast cache memory because of the locality of reference property of programs.
The basic operation of the cache is as follows. When the CPU needs to access memory, the cache is examined. If the word is found in the cache, it is read from the fast memory. If the word addressed by the CPU is not found in the cache, the main memory is accessed to read the word. A block of words containing the just one accessed is then transferred from the main memory to cache memory.
The block size may vary from one word to 16 words adjacent to the one just accessed. In this way, some data are transferred to the cache so that future references to memory find the required words in the fast cache memory.
Why do we use cache memory?
Cache memory is used to reduce the time of access to a data request. Cache memory is so fast, it is a buffer between RAM and CPU. Whenever CPU needs data in the memory then it easily accesses it from the cache. The most frequently used data are kept in the cache memory.
What are the 3 types of cache memory?
There are three types of cache memory L1, L2, and L3. L1 is generally built within the processor chips. L2 is the occasional part of the CPU but it is often a separate chip between the RAM and CPU. L2 and L3 are larger cache than the L1 but take longer to access.
How does cache memory work?
As we know that RAM is slightly slow and far from the CPU, so cache is a memory that is built somewhere in between the RAM and CPU to store the data, information, and programs. And whenever CPU needs the data it looks into the cache for faster access. The most frequently used data are kept in the cache memory.
What is cache memory and its types?
Cache memory is small and faster memory that is built to provide the frequently used data and information and program to the CPU. This saves lots of time on data access.
There are two types of cache memory, one is memory caching(cache store, memory buffer, RAM cache) and another is disk cache. memory cache is an area made up of high-speed static RAM(SRAM) instead of a cheaper and slower dynamic RAM(DRAM).
In the case of any queries, you can write to us at [email protected] we will get back to you ASAP.
Hope! you would have enjoyed this post about the cache memory.
Please feel free to give your important feedbacks in the comment section below.
Have a great time! Sayonara!