Primary Memory

Cache Memory

Cache Memory

The cache memory is one of the fastest memory. Though it is costlier than the main memory but more useful than the registers. The cache memory basically acts as a buffer between the main memory and the CPU. Moreover, it synchronizes with the speed of the CPU. Besides, it stores the data and instructions which the CPU uses more frequently so that it does not have to access the main memory again and again. Therefore the average time to access the main memory decreases.

It is placed between the main memory and the CPU. Moreover, for any data, the CPU first checks the cache and then the main memory.

Levels of Cache Memory

There can be various levels of cache memory, they are as follows:

Level 1 (L1) or Registers

It stores and accepts the data which is immediately stores in the CPU. For example instruction register, program counter, accumulator, address register, etc.

Level 2 (L2) or Cache Memory

It is the fastest memory that stores data temporarily for fast access by the CPU. Moreover, it has the fastest access time.

Level 3 (L3) or Main Memory

It is the main memory where the computer stores all the current data. It is a volatile memory which means that it loses data on power OFF.

Level 4 (L4) or Secondary Memory

It is slow in terms of access time. But, the data stays permanently in this memory.

Browse more Topics under Primary Memory

Types of Cache Memory

There are two types, as follows:

Primary Cache

It’s located on the processor chip always. Besides, its access time is comparable to the processor.

Secondary Cache

This memory is present between the primary cache and the main memory. Besides, we can also call it level 2 (L2) cache.

Basic Operations of Cache Memory

Its basic operations are as follows:

  • The CPU first checks any required data in the cache. Furthermore, it does not access the main memory if that data is present in the cache.
  • On the other hand, if the data is not present in the cache then it accesses the main memory.
  • The block of words that the CPU accesses currently is transferred from the main memory to the cache for quick access in the future.
  • The hit ratio defines the performance of the cache memory.

Cache Performance

The performance of the cache is in terms of the hit ratio.

The CPU searches the data in the cache when it requires writing or read any data from the main memory. In this case, two cases may occur as follows:

  • If the CPU finds that data in the cache, a cache hit occurs and it reads the data from the cache.
  • On the other hand, if it does not find that data in the cache, a cache miss occurs. Furthermore, during cache miss, the cache allows the entry of data and then reads data from the main memory.
  • Therefore, we can define the hit ratio as the number of hits divided by the sum of hits and misses.

hit ratio = hit / (hit + miss)

= number of hits/total accesses

Also, we can improve cache performance by:

  • using a higher cache block size.
  • higher associativity.
  • reducing the miss rate.
  • reducing the time to hit in the cache.

Advantages of Cache Memory

The advantages are as follows:

  • It is faster than the main memory.
  • The access time is quite less in comparison to the main memory.
  • The speed of accessing data increases hence, the CPU works faster.
  • Moreover, the performance of the CPU also becomes better.
  • The recent data stores in the cache and therefore, the outputs are faster.

Disadvantages of Cache Memory

The disadvantages are as follows:

  • It is quite expensive.
  • The storage capacity is limited.

Frequently Asked Questions (FAQs)

Q1. What is cache memory?

A1. The cache memory is one of the fastest memory. It basically acts as a buffer between the main memory and the CPU. Besides, it stores the data and instructions which the CPU uses more frequently.

Q2. What is the hit ratio in the cache?

A2. The hit ratio basically measures the performance of the cache. It is the ratio of the number of hits to the total number of accesses.

Share with friends

Customize your course in 30 seconds

Which class are you in?
5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
tutor
tutor
Ashhar Firdausi
IIT Roorkee
Biology
tutor
tutor
Dr. Nazma Shaik
VTU
Chemistry
tutor
tutor
Gaurav Tiwari
APJAKTU
Physics
Get Started

Leave a Reply

Your email address will not be published. Required fields are marked *

Download the App

Watch lectures, practise questions and take tests on the go.

Customize your course in 30 seconds

No thanks.