SlideShare a Scribd company logo
1 of 30
Cache Memory
E048-Shailesh Tanwar
E061-Yash Nair
E017-Shairal Neema
E019-Aashita Nyati
Agenda
 Memory Hierarchy
 What is Cache Memory
 Working of Cache
 Structure of Cache
 Cache Write Policies
 Levels of Cache
 Cache Organization
 Mapping techniques
 Replacement algorithms
Memory Hierarchy –
Diagram
Decreasing cost per bitIncreasing capacityIncreasing access timeDecreasing frequency of
access of the memory by
the processor
What is Cache Memory?
 Cache memory is used in order to achieve higher performance of CPU by
allowing the CPU to access data at faster speed.
 It is placed closest to the processor in the computer assembly.
 It is way too costly.
 It is also a type of memory but keeping in mind the cost factor it cannot be
used as a primary memory.
AN INSIGHT INTO THE WORKING OF CACHE
Structure of the Cache memory
Contains address of actual
data fetched from Main Memory
Contains actual data fetched
From the Main Memory
Cache write policies
When we write ,should we write to cache or memory?
 Write through cache – write to both cache and main memory.
Cache and memory are always consistent.
 Write back cache – write only to cache and set a “dirty bit”. When
the block gets replaced from the cache ,write it out to memory.
Levels of Cache
Fastest Fast
Less Fast
Slow
Cache Organization
Address
Address
buffer
Control Control
Data
Data
buffer
System bus
Mapping Techniques
Direct mapping
Associative mapping
Set associative mapping
Direct mapping
Simplest technique
In this , each block of main memory is mapped into
only one possible cache line .
i = j modulo m
where , i= cache memory
j= main memory
m=no. of lines in the cache
Address length = (s + w) bits
Number of addressable units = 2^(s+w) words or
bytes
Block size = line size = 2w words or bytes
Number of blocks in main memory = 2^(s+
w)/2^w = 2s
Number of lines in cache = m = 2^r
Size of tag = (s – r) bits
ASSOCIATIVE MAPPING
It overcomes the disadvantage of direct
mapping.
It permits each main memory block to be
loaded into any line of the cache .
Address length = (s + w) bits
Number of addressable units = 2^(s+w)
words or bytes
Block size = line size = 2^w words or bytes
Number of blocks in main memory =
2^(s+ w)/2^w = 2^s
Number of lines in cache = undetermined
Size of tag = s bits
SET ASSOCIATIVE MAPPING
 The relationship which is followed here is
m= v*k
i= j modulo v
Where ,
i= cache set no.
j= main memory
m= no. of lines in the cache
v= no. of set
k= no. of lines in each set
This is called k-way set associative mapping .
Address length = (s + w) bits
Number of addressable units = 2s+w words
or bytes
Block size = line size = 2^w words or bytes
Number of blocks in main memory = 2^s
Number of lines in set = k
Number of sets = v = 2d
Number of lines in cache = kv = k * 2d
Size of tag = (s – d) bits
Replacement algorithms
Discard itemsAdd new ones
Cache Memory
Cache Full…
Replacement algorithms
 Optimizing instructions.
 To manage cache information on computer.
 In direct mapping.
Each block only maps to one cache block .
 Associative and set associative mapping.
 Least recently used(LRU)
 First in first out(FIFO)
 Least frequently used(LFU)
 Random
Replacement algorithms
Least Recently used
 The most effective.
 Keeps track of which block used when.
 Discards the least recently used blocks first.
USE bit
0
USE bit
1
2 3 4 2 1 3 7
1 2 3 4 5 6 7
2 2 2 2 2 2 7
3 3 3 1 1 1
4 4 4 3 3
EXAMPLE
Page hit
1
Page fault
3
7
First In First Out
 The simplest algorithm.
 Bad performance.
 First entering block, is discarded first.
 Replaces the block that has been in cache the longest.
2 3 4 2 1 3 7
1 2 3 4 5 6 7
2 2 2 2 1 1 1
3 3 3 3 3 3
4 4 4 4 7
EXAMPLE
Page hit Page hit
1
7 Page fault
Least Frequently Used
 Counts how often a block is needed.
 Every block has one counter of its own which is initially
set to 0.
 As the block is referenced, the counter is incremented.
 Replaces the lowest reference frequency block.
2 3 4 2 1 3 7
1 2 3 4 5 6 7
2 2 2 2 2 2 2
3 3 3 3 1 1
4 4 4 4 3
EXAMPLE
Page hit
1 7
Page fault
I I I II I I I
3
Random
 Randomly selects a block.
 Discards it to make space.
 Does not keep track of access history.
 This eliminates the overhead cost of tracking page
references.
Thank You

More Related Content

What's hot (20)

Memory organization
Memory organizationMemory organization
Memory organization
 
Memory organization
Memory organizationMemory organization
Memory organization
 
Cache Memory
Cache MemoryCache Memory
Cache Memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Computer architecture cache memory
Computer architecture cache memoryComputer architecture cache memory
Computer architecture cache memory
 
cache memory
 cache memory cache memory
cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Computer organization memory
Computer organization memoryComputer organization memory
Computer organization memory
 
Elements of cache design
Elements of cache designElements of cache design
Elements of cache design
 
Cache memory
Cache memory Cache memory
Cache memory
 
Cache memory and cache
Cache memory and cacheCache memory and cache
Cache memory and cache
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Mapping
MappingMapping
Mapping
 
Cache memory
Cache memoryCache memory
Cache memory
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
Memory Addressing
Memory AddressingMemory Addressing
Memory Addressing
 
Memory organization
Memory organizationMemory organization
Memory organization
 
04 Cache Memory
04  Cache  Memory04  Cache  Memory
04 Cache Memory
 
Cache memory
Cache memoryCache memory
Cache memory
 

Similar to An Insight into the Working of Cache Memory

CACHEMAPPING POLICIE AND MERITS & DEMERITS
CACHEMAPPING POLICIE AND MERITS & DEMERITSCACHEMAPPING POLICIE AND MERITS & DEMERITS
CACHEMAPPING POLICIE AND MERITS & DEMERITSAnkitPandey440
 
waserdtfgfiuerhiuerwehfiuerghzsdfghyguhijdrtyunit5.pptx
waserdtfgfiuerhiuerwehfiuerghzsdfghyguhijdrtyunit5.pptxwaserdtfgfiuerhiuerwehfiuerghzsdfghyguhijdrtyunit5.pptx
waserdtfgfiuerhiuerwehfiuerghzsdfghyguhijdrtyunit5.pptxabcxyz19691969
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer ArchitectureSubhasis Dash
 
9.1-CSE3421-multicolumn-cache.pdf
9.1-CSE3421-multicolumn-cache.pdf9.1-CSE3421-multicolumn-cache.pdf
9.1-CSE3421-multicolumn-cache.pdfrishav957243
 
Cache.pptx
Cache.pptxCache.pptx
Cache.pptxVCETCSE
 
ECECS 472572 Final Exam ProjectRemember to check the errat.docx
ECECS 472572 Final Exam ProjectRemember to check the errat.docxECECS 472572 Final Exam ProjectRemember to check the errat.docx
ECECS 472572 Final Exam ProjectRemember to check the errat.docxtidwellveronique
 
ECECS 472572 Final Exam ProjectRemember to check the err.docx
ECECS 472572 Final Exam ProjectRemember to check the err.docxECECS 472572 Final Exam ProjectRemember to check the err.docx
ECECS 472572 Final Exam ProjectRemember to check the err.docxtidwellveronique
 

Similar to An Insight into the Working of Cache Memory (20)

CACHEMAPPING POLICIE AND MERITS & DEMERITS
CACHEMAPPING POLICIE AND MERITS & DEMERITSCACHEMAPPING POLICIE AND MERITS & DEMERITS
CACHEMAPPING POLICIE AND MERITS & DEMERITS
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
waserdtfgfiuerhiuerwehfiuerghzsdfghyguhijdrtyunit5.pptx
waserdtfgfiuerhiuerwehfiuerghzsdfghyguhijdrtyunit5.pptxwaserdtfgfiuerhiuerwehfiuerghzsdfghyguhijdrtyunit5.pptx
waserdtfgfiuerhiuerwehfiuerghzsdfghyguhijdrtyunit5.pptx
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
9.1-CSE3421-multicolumn-cache.pdf
9.1-CSE3421-multicolumn-cache.pdf9.1-CSE3421-multicolumn-cache.pdf
9.1-CSE3421-multicolumn-cache.pdf
 
module3.ppt
module3.pptmodule3.ppt
module3.ppt
 
memory.ppt
memory.pptmemory.ppt
memory.ppt
 
memory.ppt
memory.pptmemory.ppt
memory.ppt
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache.pptx
Cache.pptxCache.pptx
Cache.pptx
 
ECECS 472572 Final Exam ProjectRemember to check the errat.docx
ECECS 472572 Final Exam ProjectRemember to check the errat.docxECECS 472572 Final Exam ProjectRemember to check the errat.docx
ECECS 472572 Final Exam ProjectRemember to check the errat.docx
 
ECECS 472572 Final Exam ProjectRemember to check the err.docx
ECECS 472572 Final Exam ProjectRemember to check the err.docxECECS 472572 Final Exam ProjectRemember to check the err.docx
ECECS 472572 Final Exam ProjectRemember to check the err.docx
 
Cache memory
Cache  memoryCache  memory
Cache memory
 

Recently uploaded

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 

Recently uploaded (20)

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 

An Insight into the Working of Cache Memory

  • 1. Cache Memory E048-Shailesh Tanwar E061-Yash Nair E017-Shairal Neema E019-Aashita Nyati
  • 2. Agenda  Memory Hierarchy  What is Cache Memory  Working of Cache  Structure of Cache  Cache Write Policies  Levels of Cache  Cache Organization  Mapping techniques  Replacement algorithms
  • 3. Memory Hierarchy – Diagram Decreasing cost per bitIncreasing capacityIncreasing access timeDecreasing frequency of access of the memory by the processor
  • 4. What is Cache Memory?  Cache memory is used in order to achieve higher performance of CPU by allowing the CPU to access data at faster speed.  It is placed closest to the processor in the computer assembly.  It is way too costly.  It is also a type of memory but keeping in mind the cost factor it cannot be used as a primary memory.
  • 5. AN INSIGHT INTO THE WORKING OF CACHE
  • 6. Structure of the Cache memory Contains address of actual data fetched from Main Memory Contains actual data fetched From the Main Memory
  • 7. Cache write policies When we write ,should we write to cache or memory?  Write through cache – write to both cache and main memory. Cache and memory are always consistent.  Write back cache – write only to cache and set a “dirty bit”. When the block gets replaced from the cache ,write it out to memory.
  • 8. Levels of Cache Fastest Fast Less Fast Slow
  • 10. Mapping Techniques Direct mapping Associative mapping Set associative mapping
  • 11. Direct mapping Simplest technique In this , each block of main memory is mapped into only one possible cache line . i = j modulo m where , i= cache memory j= main memory m=no. of lines in the cache
  • 12.
  • 13. Address length = (s + w) bits Number of addressable units = 2^(s+w) words or bytes Block size = line size = 2w words or bytes Number of blocks in main memory = 2^(s+ w)/2^w = 2s Number of lines in cache = m = 2^r Size of tag = (s – r) bits
  • 14. ASSOCIATIVE MAPPING It overcomes the disadvantage of direct mapping. It permits each main memory block to be loaded into any line of the cache .
  • 15.
  • 16. Address length = (s + w) bits Number of addressable units = 2^(s+w) words or bytes Block size = line size = 2^w words or bytes Number of blocks in main memory = 2^(s+ w)/2^w = 2^s Number of lines in cache = undetermined Size of tag = s bits
  • 17. SET ASSOCIATIVE MAPPING  The relationship which is followed here is m= v*k i= j modulo v Where , i= cache set no. j= main memory m= no. of lines in the cache v= no. of set k= no. of lines in each set This is called k-way set associative mapping .
  • 18.
  • 19. Address length = (s + w) bits Number of addressable units = 2s+w words or bytes Block size = line size = 2^w words or bytes Number of blocks in main memory = 2^s Number of lines in set = k Number of sets = v = 2d Number of lines in cache = kv = k * 2d Size of tag = (s – d) bits
  • 20. Replacement algorithms Discard itemsAdd new ones Cache Memory Cache Full…
  • 21. Replacement algorithms  Optimizing instructions.  To manage cache information on computer.  In direct mapping. Each block only maps to one cache block .  Associative and set associative mapping.
  • 22.  Least recently used(LRU)  First in first out(FIFO)  Least frequently used(LFU)  Random Replacement algorithms
  • 23. Least Recently used  The most effective.  Keeps track of which block used when.  Discards the least recently used blocks first. USE bit 0 USE bit 1
  • 24. 2 3 4 2 1 3 7 1 2 3 4 5 6 7 2 2 2 2 2 2 7 3 3 3 1 1 1 4 4 4 3 3 EXAMPLE Page hit 1 Page fault 3 7
  • 25. First In First Out  The simplest algorithm.  Bad performance.  First entering block, is discarded first.  Replaces the block that has been in cache the longest.
  • 26. 2 3 4 2 1 3 7 1 2 3 4 5 6 7 2 2 2 2 1 1 1 3 3 3 3 3 3 4 4 4 4 7 EXAMPLE Page hit Page hit 1 7 Page fault
  • 27. Least Frequently Used  Counts how often a block is needed.  Every block has one counter of its own which is initially set to 0.  As the block is referenced, the counter is incremented.  Replaces the lowest reference frequency block.
  • 28. 2 3 4 2 1 3 7 1 2 3 4 5 6 7 2 2 2 2 2 2 2 3 3 3 3 1 1 4 4 4 4 3 EXAMPLE Page hit 1 7 Page fault I I I II I I I 3
  • 29. Random  Randomly selects a block.  Discards it to make space.  Does not keep track of access history.  This eliminates the overhead cost of tracking page references.

Editor's Notes

  1. The CPU initially looks in the Cache for the data it needs If the data is there, it will retrieve it and process it If the data is not there, then the CPU accesses the system memory and then puts a copy of the new data in the cache before processing it Next time if the CPU needs to access the same data again, it will just retrieve the data from the Cache instead of going through the whole loading process again The legit question of Why use Cache when we have RAM?
  2. Each line is assigned a USE bit .It is changed to 1 when a line is referenced.