0% found this document useful (0 votes)
9 views

Associative Mapping

Associative mapping and Operating system

Uploaded by

aniqaumar6
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Associative Mapping

Associative mapping and Operating system

Uploaded by

aniqaumar6
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Associative Mapping

Introduction to Associative Mapping


 To overcome the limitations of direct mapping we have Associative
Mapping.
 A block of main memory can be mapped to any freely available
cache line. This makes associative mapping more flexible than direct
mapping.
 It is also known as many to many mappings.
Working of associative mapping
 Any block of main memory can be stored in any cache line.
 Memory address is divided into:
Tag: Identifies the block.
Word: Specifies the exact data within the block.
 In associative mapping the tag of the requested memory compared with
tags of all cache lines .
 If the tag matches and data is valid the data is directly retrieved from
the cache.
 If no match is found the data is fetched from MM and stored in cache
line.
 When cache is full then determines which cache line to replace.
Numerical Example
Given data
Main memory size: 32KB ( 32 * 1024 bytes)
Cache size 4 KB (4 × 1024 bytes)
Block Size: 64 bytes
Steps to Solve:
1. Number of Cache Lines:
Number of Cache Lines=Cache Size/Block Size
Number of Cache Lines= 4096/64 = 64
2. Number of Blocks in Main Memory:
Number of Blocks=Main Memory Size/Block Size
Number of Blocks= 32*1024/64
=512

3. Mapping process
Each block in main memory can be placed in any of the 64 cache lines.
To identify the block in cache, a tag is used.
4. Physical address bits
P.A bits= log2 (MM size )32,768
 We know 32,768= 2^15
So, P.A bits 15
Block Offset
Block Offset Bits=log2 (Block Size in Bytes)
log2 (64)= 2^6=6bits
Tag bits
The tag bits helps to identify which block is stored in cache.
To calculate the tag bits use total number of blocks.
Tag bits= 512= 2^9
Tag bits = 9
Accessing Data:
The cache controller searches the tag field of all lines in the cache.If the tag matches, it's a cache hit
and the data is fetched.
If no match is found, it's a cache miss.
Advantages & Disadvantages
Advantages
 Eliminates mapping conflicts.
 Allows better cache utilization
Disadvantages
 Higher cost due to complex hardware
 Slower access times due to tag comparison

Conclusion
 Associative mapping is an efficient cache mapping technique
 It balance flexibility and complexity for better performance.

You might also like