Translate

Sunday, May 3, 2020

What is Cache Memory ?

what is cache memory, what is cache memory in computer, where is cache memory located, what is cache memory in linux, how cache memory works, types of cache memory, importance of cache memory, cache memory mapping, cache memory tutorial, cache memory size, levels of cache memory, cache memory pdf
what-is-cache-memory

What is Cache Memory?

What is Cache Memory? It is very easy to understand. We all know that running a program in a computer is the work of the CPU (Central processing unit). He needs many instructions and data to do this work. Often these things are stored in Random access memory (RAM) or hard disk.

Now because the CPU works very fast, compared to which RAM and Hard disk are very slow. For this reason, it takes a lot of time for the CPU to get these instructions and data. Which affects the overall performance of the computer system. To avoid this, "Cache Memory" is used in all modern computers.

Although the data storage capacity of Cache Memory is very less. But it is the fastest compared to the rest of the computer memory. So Cache Memory is used to store instructions and data that the CPU needs repeatedly.

What is Cache Memory - use this information

In this post what is cache memory, we will learn further what is the importance of Cache Memory in a computer, what are the benefits of cache memory and where is cache memory located? But before that what is cache memory? Understand this in some detail.

What is Cache Memory?

Cache Memory is a Volatile Computer Memory, in which the instructions or data frequently used by the CPU is stored. This is very small memory, meaning that more data cannot be stored in it. But it is considered the fastest memory because it is located very close to the CPU chip. Cache Memory is used to reduce the average time it takes to access data from main memory.

What is Cache Memory - use this information


This is more expensive than RAM and disk memory. Also the closest is the CPU. This is why CPU accesses the data stored in Cache Memory the fastest. So Cache Memory is a very high speed semiconductor memory, which holds (repeatedly) used data to speed-up the CPU. It acts as a buffer between the CPU and main memory.

Most modern computers have at least three types of Cache Memory, including: Instructions cache which accelerates fetch executable instructions, data cache it accelerates to fetch and store end. In Translation look a side buffer (TLB) it is used to speed up virtual-to-physical address translation of both executable instructions and data.

Importance of Cache Memory in Computer

System performance matters a lot to a computer user. As we know, it is necessary for the CPU to be faster and more efficient. That is, the faster and efficiently a process is done by the CPU, the better will be the performance of the computer. So Cache Memory improves CPU efficiency in a way. From some important points mentioned below, you can understand the importance or importance of Cache Memory.

What is Cache Memory - use this information

1) CPU slows down the overall process of program execution due to slowing of main memory. While using Cache Memory speeds up the process.

2) Cache memory holds those instructions / data, which are often required by the CPU or they are very common. Because of this, the CPU does not have to go to main memory for the required data. In this way, Cache Memory practically acts as a buffer between CPU and RAM.

3) Cache memory is the fastest access memory as compared to RAM, as it is present in CPU Chip only. So the CPU receives the necessary instructions soon.

4) The data stored in Cache Memory is temporary. This means that when the stored data is of no use, it is absolutely useless, then it is immediately replaced.

5) Its throughput (the amount of data passing through a system) is higher than the rest of the memory. Because Cache Memory uses back-side-bus to connect to CPU core. Whose width is about 128 bit and 256 bit. The higher the width of the bus, the higher the limit of data transfer will be.

Read Also - What is Data ?

How Cache Memory Works -

You have already known what Cache Memory is and what is its role in the computer. Let us now see that what is the role of Cache Memory when you run an application / program in your computer. Whenever you run a program, it is usually stored on the hard disk.

Now because CPU cannot fetch data directly from hard disk, because it is very slow. Due to which the program has to load in RAM memory. Because RAM is much faster than a hard disk. However, the problem here is that RAM is not as fast as CPU. The data transfer speed and access time (latency) of RAM is much less compared to CPU.

So when the CPU requests a program from RAM, RAM takes a certain time to deliver it. Which causes the CPU to wait that much time. Due to this, its overall performance reduces to a great extent. To avoid this, Cache Memory is used in computers.

They take data / instructions from some memory addresses in RAM and backup them in Cache Memory. After which Cache reads memory before retrieving data from CPU, RAM or hard disk. If the data is present there, the CPU will retrieve it instantly. If the requested data / instructions CPU is not found in cache then it will have to retrieve the data from hard drive again.

This will take more time because the processing time is already lost in searching the data in cache memory. However processing speed can be improved with the help of multiple cache layers. These two conditions are defined under the names Cache Hit and Cache Miss. Let's know about them.

Cache Hit: This is the situation when the data requested by the CPU is found in the cache memory.

Cache Miss: In this case the data requested by the CPU is not found in the cache memory (not found).

What is Cache Memory - use this information

What is Cache Mapping?

Cache Mapping is a technique under which the requested content is mapped from main memory to cache in case of Cache miss. In simple words, if the CPU does not find the content that it needs in the cache memory, then the process of finding that content in the main memory and bringing it back to the cache memory is called Cache Mapping. Cache mapping is done using three different types of techniques which are as follows.

  • Direct mapping
  • Fully Associative Mapping
  • Set Associative Mapping

Direct mapping

As the name suggests, there is a fixed cache memory locations to mapped each block in Direct mapped cache. That is, it is fixed in which cache line to put a main memory block.

Fully Associative Mapping

Although its structure is quite similar to direct mapping. But in fully associative mapping, a memory block can be mapped to any cache line instead of the defined location.

Set Associative Mapping


It is seen as a combination of direct mapping and associative mapping. In which cache lines are divided into sets. Where each set contains k-number of lines. In this, the particular block of main memory can be mapped to one particular set of cache memory. However, within that set, memory block can be mapped to any cache line. Hence it is sometimes called K-way Set Associative Mapping.

What is Cache Memory - use this information

We will not elaborate about them now because this post will become longer. Soon we will write an entire post on Cache Mapping, under which these three techniques will be explained with the help of diagram.


Different Levels in Cache Memory

A computer has many different levels of Cache Memory. These Cache levels reflect their closeness and accessibility from the CPU. That is, the cache which will be located close to the CPU in the computer will be faster than other levels. But it will store the lowest data and will also be more expensive. So let's learn about these different levels of Cache Memory.

Level 1 or L1 Cache
This is the fastest cache, the reason is that L1 cache is embedded in the CPU chip. In most computers, it acts as a CPU cache. Therefore it is also called primary cache. L1 cache is the lowest size and can store up to 64kb cache memory. However, in some powerful CPUs, the size of this cache is around 1mb.

In terms of priority of usage, L1 holds the type of data that the CPU needs repeatedly to perform a task. This is a cache made of SRAM (Static RAM). Address register is an example of this.

What is Cache Memory - use this information

Level 2 or L2 Cache

L2 Cache is slower than L1 but it is bigger in size than it. It usually has a memory between 64kb-8mb. Although it is also present in the CPU, but often it is a separate chip between the CPU and RAM. Whenever the CPU searches the instructions in L1 Cache and they do not find it there, it will search the required instructions in L2 Cache. That is why L2 is also called secondary cache.

There is a high speed system bus to connect Cache to CPU. Due to which traffic is not slow even in the case of traffic on the main system bus.

Level 3 or L3 Cache

L3 is the largest cache memory compared to L1 and L2 but also the slowest among the three. Its size can be up to about 4mb-50mb. This is a large form of memory present on the computer motherboard. The main use of L3 cache is to speed up the processing operation. This reduces the time it takes to request data and receive requests.

Even in a multi core processor, there can be separate L1 and L2 cache for each core. But all cores share the same L3 cache among themselves.

Where is Cache Memory Located

Cache Memory is usually located on the computer's CPU chip. Now because cache has many different levels. For example - L1 cache, L2 cache and L3 cache. Therefore their location in the computer may be different from each other. L1 and L2 are part of the Cache processor core in most modern processors. We call them SRAM. The L3 Cache is often located either in the processor or outside it in the motherboard. Thus, based on the location of Cache Memory, we define them as internal cache and external cache.

What is Cache Memory - use this information

No comments:

Post a Comment

Please do not enter any spam link in the comment box.