SlideShare a Scribd company logo
1 of 30
P R E S E N T E D B Y
A H S A N A S H F A Q
B C S ( H O N S ) F R O M U O P ( G O L D M E D A L I S T )
( 2 0 0 8 - 2 0 1 1 )
M S S C H O L A R I N I M | S C I E N C E S P E S H A W A R
( 2 0 1 3 - 2 0 1 5 )
CACHE MEMORY
STRUCTURE, ORGANIZATION AND MAPPING
MAJOR ACHIEVEMENTS
• Gold Medalist from University Of Peshawar.
• Course : BCS (Hons)
• Session : 2008 to 2011
• CGPA : 3.9/4.0
• 3rd Position in Computer Science Group in Board of
Intermediate and Secondary Education Peshawar.
• Course : FSc Computer Science
• Session : 2006-2007
• Marks : 901/1100
2
CONTENTS
• Memory Hierarchy
• Background
• Working of Cache Memory
• Structure and Organization
• Reference of Locality
• Mapping Techniques
• Direct
• Associative
• Set Associative
• Write Policies
• Cache Misses and its types
• Solution for Cache Misses
3Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
MEMORY HIERARCHY
4Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
BACKGROUND
• Main Memory provides data to Processor for
Processing.
• Difference between the speed of Processor and Main
Memory.
• Processor being the Main Resource can not be utilized fully.
5Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
CACHE MEMORY
• Cache Memory is used in order to achieve higher
performance of CPU by allowing the CPU to access
data at faster speed.
6Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
HOW CACHE WORKS ?
7Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
CACHE OPERATION
• CPU requests contents of memory location
• Check cache for this data
• If present, get from cache (fast)
• If not present, read required block from main
memory to cache
• Question : Why a Block is transferred ?
8Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
REFERENCE OF LOCALITY
• Spatial vs. Temporal
Temporal : Recently referenced items are likely to be
references in near future.
Spatial : Items with near by addresses tend to be referenced
close together in time.
9Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
CACHE/MAIN MEMORY STRUCTURE
10Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
TYPICAL CACHE ORGANIZATION
11Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
CACHE ADDRESSING
• Where does cache sit?
• Between processor and virtual memory management unit
• Between MMU and main memory
• Logical cache (virtual cache) stores data using virtual
addresses
• Processor accesses cache directly, not thorough physical
cache
• Cache access faster, before MMU address translation
• Virtual addresses use same address space for different
applications
• Must flush cache on each context switch
• Physical cache stores data using main memory physical
addresses
12Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
MAPPING FUNCTION
• Number of Blocks (M) in the main Memory is quite
large then the Number of Lines (m) in the cache
Memory i.e. m<M.
• So we need a Mapping Function.
• Direct Mapping
• Associative Mapping
• Set Associative Mapping
13Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
DIRECT MAPPING
• Each block of Main Memory can be mapped to a
specific line of Cache.
• If we want a block we will check its present in a
specific line.
• Mapping Function is
• i=j module m
• i=Cache Line number
• J=Main memory Block
• m=Total lines in Cache
14Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
DIRECT MAPPING CACHE
ORGANIZATION
15Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
DIRECT MAPPING ADDRESS FORMAT
2w = Words in a Block
2S = Total blocks in MM
2r = Total lines in Cache
16Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
DIRECT MAPPING PROS & CONS
• Simple
• Inexpensive
• Fixed location for given block
• If a program accesses 2 blocks that map to the same line
repeatedly, cache misses are very high
17Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
ASSOCIATIVE MAPPING
• A main memory block can load into any line of
cache
• Memory address is interpreted as tag and word
• Tag uniquely identifies block of memory
• Every line’s tag is examined for a match
• Cache searching gets expensive
18Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
FULLY ASSOCIATIVE CACHE
ORGANIZATION
19Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
ASSOCIATIVE MAPPING ADDRESS
FORMAT
Tag 22 bit
Word
2 bit
s w
Address Length=(s+w) bits
2w = Words in a Block/Line
2S = Total blocks in MM
Number of Lines in Cache=Undefined
20Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
ASSOCIATIVE MAPPING PROS & CONS
• Associative mapping result in high memory
utilization.
• Less Efficient search criteria
• Search is expensive in terms of price and performance.
21Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
SET ASSOCIATIVE MAPPING
• Cache is divided into a number of sets
• Each set contains a number of lines
• Between MM Block and Cache Set Mapping is
direct and inside Set its Associative.
• Mapping Function
• Set # = Block # module Total Sets
• e.g. 2 lines per set
• 2 way associative mapping
• A given block can be in one of 2 lines in only one set
22Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
SET-ASSOCIATIVE MAPPING
ADDRESS FORMAT
Address Length=(s+w) bits
2w = Words in a Block/Line
2r = Total sets in cache
wrs-r
23Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
K-WAY SET ASSOCIATIVE CACHE
ORGANIZATION
24
REPLACEMENT ALGORITHMS
ASSOCIATIVE & SET ASSOCIATIVE
• Least Recently used (LRU)
• e.g. in 2 way set associative
• Which of the 2 block is lru?
• First in first out (FIFO)
• replace block that has been in cache longest
• Least frequently used
• replace block which has had fewest hits
• Random
25Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
WRITE POLICY
• Must not overwrite a cache block unless main
memory is up to date
• Multiple CPUs may have individual caches
• I/O may address main memory directly
26Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
WRITE THROUGH
• All writes go to main memory as well as cache
• Multiple CPUs can monitor main memory traffic to
keep local (to CPU) cache up to date
• Lots of traffic
• Slows down writes
27Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
WRITE BACK
• Updates initially made in cache only
• Update bit for cache slot is set when update occurs
• If block is to be replaced, write to main memory
only if update bit is set
• I/O must access main memory through cache
28Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
CACHE MISSES
• Compulsory Misses
• Capacity Misses
• Conflict Misses
Solution
Miss Cache
Victim Cache
Prefetching
29Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
Discussions ??
30Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar

More Related Content

What's hot

Cache replacement policies,cache miss,writingtechniques
Cache replacement policies,cache miss,writingtechniquesCache replacement policies,cache miss,writingtechniques
Cache replacement policies,cache miss,writingtechniquesSnehalataAgasti
 
Cache memory principles
Cache memory principlesCache memory principles
Cache memory principlesbit allahabad
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSKumar Pritam
 
Centralized shared memory architectures
Centralized shared memory architecturesCentralized shared memory architectures
Centralized shared memory architecturesGokuldhev mony
 
What is Cache and how it works
What is Cache and how it worksWhat is Cache and how it works
What is Cache and how it worksTabraiz Yaseen
 
12 processor structure and function
12 processor structure and function12 processor structure and function
12 processor structure and functionSher Shah Merkhel
 
Cache performance considerations
Cache performance considerationsCache performance considerations
Cache performance considerationsSlideshare
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAnuj Modi
 

What's hot (20)

Cache Memory
Cache MemoryCache Memory
Cache Memory
 
Cache replacement policies,cache miss,writingtechniques
Cache replacement policies,cache miss,writingtechniquesCache replacement policies,cache miss,writingtechniques
Cache replacement policies,cache miss,writingtechniques
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory principles
Cache memory principlesCache memory principles
Cache memory principles
 
Cache memory presentation
Cache memory presentationCache memory presentation
Cache memory presentation
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Centralized shared memory architectures
Centralized shared memory architecturesCentralized shared memory architectures
Centralized shared memory architectures
 
Mapping
MappingMapping
Mapping
 
What is Cache and how it works
What is Cache and how it worksWhat is Cache and how it works
What is Cache and how it works
 
Memory hierarchy
Memory hierarchyMemory hierarchy
Memory hierarchy
 
12 processor structure and function
12 processor structure and function12 processor structure and function
12 processor structure and function
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
Memory mapping
Memory mappingMemory mapping
Memory mapping
 
Cache performance considerations
Cache performance considerationsCache performance considerations
Cache performance considerations
 
Memory hierarchy
Memory hierarchyMemory hierarchy
Memory hierarchy
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 

Viewers also liked

Coa swetappt copy
Coa swetappt   copyCoa swetappt   copy
Coa swetappt copysweta_pari
 
Memory mapping techniques and low power memory design
Memory mapping techniques and low power memory designMemory mapping techniques and low power memory design
Memory mapping techniques and low power memory designUET Taxila
 
Memory organisation ppt final presentation
Memory organisation ppt final presentationMemory organisation ppt final presentation
Memory organisation ppt final presentationrockymani
 
Computer organization
Computer organizationComputer organization
Computer organizationishapadhy
 
Central Processing Unit
Central Processing UnitCentral Processing Unit
Central Processing UnitJan Ralph
 
Cpu and its functions
Cpu and its functionsCpu and its functions
Cpu and its functionsmyrajendra
 
08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)Akhila Dakshina
 
Cpu presentation
Cpu presentationCpu presentation
Cpu presentationHarry Singh
 
History of CPU Architecture
History of CPU ArchitectureHistory of CPU Architecture
History of CPU ArchitectureTim Hall
 
Address mapping
Address mappingAddress mapping
Address mappingrockymani
 

Viewers also liked (15)

cache memory
cache memorycache memory
cache memory
 
Coa swetappt copy
Coa swetappt   copyCoa swetappt   copy
Coa swetappt copy
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Memory mapping techniques and low power memory design
Memory mapping techniques and low power memory designMemory mapping techniques and low power memory design
Memory mapping techniques and low power memory design
 
How Motherboards Work
How Motherboards WorkHow Motherboards Work
How Motherboards Work
 
Windows Utilities
Windows UtilitiesWindows Utilities
Windows Utilities
 
Memory organisation ppt final presentation
Memory organisation ppt final presentationMemory organisation ppt final presentation
Memory organisation ppt final presentation
 
Computer architecture
Computer architecture Computer architecture
Computer architecture
 
Computer organization
Computer organizationComputer organization
Computer organization
 
Central Processing Unit
Central Processing UnitCentral Processing Unit
Central Processing Unit
 
Cpu and its functions
Cpu and its functionsCpu and its functions
Cpu and its functions
 
08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)
 
Cpu presentation
Cpu presentationCpu presentation
Cpu presentation
 
History of CPU Architecture
History of CPU ArchitectureHistory of CPU Architecture
History of CPU Architecture
 
Address mapping
Address mappingAddress mapping
Address mapping
 

Similar to Cache memory

Elements of cache design
Elements of cache designElements of cache design
Elements of cache designRohail Butt
 
Cache Memory for Computer Architecture.ppt
Cache Memory for Computer Architecture.pptCache Memory for Computer Architecture.ppt
Cache Memory for Computer Architecture.pptrularofclash69
 
Computer organization memory hierarchy
Computer organization memory hierarchyComputer organization memory hierarchy
Computer organization memory hierarchyAJAL A J
 
cache memory introduction, level, function
cache memory introduction, level, functioncache memory introduction, level, function
cache memory introduction, level, functionTeddyIswahyudi1
 
Computer architecture for HNDIT
Computer architecture for HNDITComputer architecture for HNDIT
Computer architecture for HNDITtjunicornfx
 
coa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptxcoa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptxRuhul Amin
 
04_Cache Memory.ppt
04_Cache Memory.ppt04_Cache Memory.ppt
04_Cache Memory.pptShiva340703
 
Cache Memory.ppt
Cache Memory.pptCache Memory.ppt
Cache Memory.pptAmarDura2
 
04 cache memory.ppt 1
04 cache memory.ppt 104 cache memory.ppt 1
04 cache memory.ppt 1Anwal Mirza
 
Ct213 memory subsystem
Ct213 memory subsystemCt213 memory subsystem
Ct213 memory subsystemSandeep Kamath
 

Similar to Cache memory (20)

Elements of cache design
Elements of cache designElements of cache design
Elements of cache design
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
cache memory
cache memorycache memory
cache memory
 
Cache Memory
Cache MemoryCache Memory
Cache Memory
 
Cache Memory for Computer Architecture.ppt
Cache Memory for Computer Architecture.pptCache Memory for Computer Architecture.ppt
Cache Memory for Computer Architecture.ppt
 
cache memory.ppt
cache memory.pptcache memory.ppt
cache memory.ppt
 
cache memory.ppt
cache memory.pptcache memory.ppt
cache memory.ppt
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
Computer organization memory hierarchy
Computer organization memory hierarchyComputer organization memory hierarchy
Computer organization memory hierarchy
 
cache memory introduction, level, function
cache memory introduction, level, functioncache memory introduction, level, function
cache memory introduction, level, function
 
Computer architecture for HNDIT
Computer architecture for HNDITComputer architecture for HNDIT
Computer architecture for HNDIT
 
CAO-Unit-III.pptx
CAO-Unit-III.pptxCAO-Unit-III.pptx
CAO-Unit-III.pptx
 
coa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptxcoa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptx
 
04_Cache Memory.ppt
04_Cache Memory.ppt04_Cache Memory.ppt
04_Cache Memory.ppt
 
Cache Memory.ppt
Cache Memory.pptCache Memory.ppt
Cache Memory.ppt
 
04_Cache Memory.ppt
04_Cache Memory.ppt04_Cache Memory.ppt
04_Cache Memory.ppt
 
04_Cache Memory.ppt
04_Cache Memory.ppt04_Cache Memory.ppt
04_Cache Memory.ppt
 
04 cache memory.ppt 1
04 cache memory.ppt 104 cache memory.ppt 1
04 cache memory.ppt 1
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
Ct213 memory subsystem
Ct213 memory subsystemCt213 memory subsystem
Ct213 memory subsystem
 

Recently uploaded

MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGSIVASHANKAR N
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
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
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
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
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
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
 
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
 
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
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
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
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 

Cache memory

  • 1. P R E S E N T E D B Y A H S A N A S H F A Q B C S ( H O N S ) F R O M U O P ( G O L D M E D A L I S T ) ( 2 0 0 8 - 2 0 1 1 ) M S S C H O L A R I N I M | S C I E N C E S P E S H A W A R ( 2 0 1 3 - 2 0 1 5 ) CACHE MEMORY STRUCTURE, ORGANIZATION AND MAPPING
  • 2. MAJOR ACHIEVEMENTS • Gold Medalist from University Of Peshawar. • Course : BCS (Hons) • Session : 2008 to 2011 • CGPA : 3.9/4.0 • 3rd Position in Computer Science Group in Board of Intermediate and Secondary Education Peshawar. • Course : FSc Computer Science • Session : 2006-2007 • Marks : 901/1100 2
  • 3. CONTENTS • Memory Hierarchy • Background • Working of Cache Memory • Structure and Organization • Reference of Locality • Mapping Techniques • Direct • Associative • Set Associative • Write Policies • Cache Misses and its types • Solution for Cache Misses 3Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 4. MEMORY HIERARCHY 4Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 5. BACKGROUND • Main Memory provides data to Processor for Processing. • Difference between the speed of Processor and Main Memory. • Processor being the Main Resource can not be utilized fully. 5Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 6. CACHE MEMORY • Cache Memory is used in order to achieve higher performance of CPU by allowing the CPU to access data at faster speed. 6Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 7. HOW CACHE WORKS ? 7Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 8. CACHE OPERATION • CPU requests contents of memory location • Check cache for this data • If present, get from cache (fast) • If not present, read required block from main memory to cache • Question : Why a Block is transferred ? 8Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 9. REFERENCE OF LOCALITY • Spatial vs. Temporal Temporal : Recently referenced items are likely to be references in near future. Spatial : Items with near by addresses tend to be referenced close together in time. 9Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 10. CACHE/MAIN MEMORY STRUCTURE 10Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 11. TYPICAL CACHE ORGANIZATION 11Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 12. CACHE ADDRESSING • Where does cache sit? • Between processor and virtual memory management unit • Between MMU and main memory • Logical cache (virtual cache) stores data using virtual addresses • Processor accesses cache directly, not thorough physical cache • Cache access faster, before MMU address translation • Virtual addresses use same address space for different applications • Must flush cache on each context switch • Physical cache stores data using main memory physical addresses 12Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 13. MAPPING FUNCTION • Number of Blocks (M) in the main Memory is quite large then the Number of Lines (m) in the cache Memory i.e. m<M. • So we need a Mapping Function. • Direct Mapping • Associative Mapping • Set Associative Mapping 13Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 14. DIRECT MAPPING • Each block of Main Memory can be mapped to a specific line of Cache. • If we want a block we will check its present in a specific line. • Mapping Function is • i=j module m • i=Cache Line number • J=Main memory Block • m=Total lines in Cache 14Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 15. DIRECT MAPPING CACHE ORGANIZATION 15Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 16. DIRECT MAPPING ADDRESS FORMAT 2w = Words in a Block 2S = Total blocks in MM 2r = Total lines in Cache 16Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 17. DIRECT MAPPING PROS & CONS • Simple • Inexpensive • Fixed location for given block • If a program accesses 2 blocks that map to the same line repeatedly, cache misses are very high 17Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 18. ASSOCIATIVE MAPPING • A main memory block can load into any line of cache • Memory address is interpreted as tag and word • Tag uniquely identifies block of memory • Every line’s tag is examined for a match • Cache searching gets expensive 18Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 19. FULLY ASSOCIATIVE CACHE ORGANIZATION 19Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 20. ASSOCIATIVE MAPPING ADDRESS FORMAT Tag 22 bit Word 2 bit s w Address Length=(s+w) bits 2w = Words in a Block/Line 2S = Total blocks in MM Number of Lines in Cache=Undefined 20Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 21. ASSOCIATIVE MAPPING PROS & CONS • Associative mapping result in high memory utilization. • Less Efficient search criteria • Search is expensive in terms of price and performance. 21Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 22. SET ASSOCIATIVE MAPPING • Cache is divided into a number of sets • Each set contains a number of lines • Between MM Block and Cache Set Mapping is direct and inside Set its Associative. • Mapping Function • Set # = Block # module Total Sets • e.g. 2 lines per set • 2 way associative mapping • A given block can be in one of 2 lines in only one set 22Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 23. SET-ASSOCIATIVE MAPPING ADDRESS FORMAT Address Length=(s+w) bits 2w = Words in a Block/Line 2r = Total sets in cache wrs-r 23Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 24. K-WAY SET ASSOCIATIVE CACHE ORGANIZATION 24
  • 25. REPLACEMENT ALGORITHMS ASSOCIATIVE & SET ASSOCIATIVE • Least Recently used (LRU) • e.g. in 2 way set associative • Which of the 2 block is lru? • First in first out (FIFO) • replace block that has been in cache longest • Least frequently used • replace block which has had fewest hits • Random 25Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 26. WRITE POLICY • Must not overwrite a cache block unless main memory is up to date • Multiple CPUs may have individual caches • I/O may address main memory directly 26Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 27. WRITE THROUGH • All writes go to main memory as well as cache • Multiple CPUs can monitor main memory traffic to keep local (to CPU) cache up to date • Lots of traffic • Slows down writes 27Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 28. WRITE BACK • Updates initially made in cache only • Update bit for cache slot is set when update occurs • If block is to be replaced, write to main memory only if update bit is set • I/O must access main memory through cache 28Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 29. CACHE MISSES • Compulsory Misses • Capacity Misses • Conflict Misses Solution Miss Cache Victim Cache Prefetching 29Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar
  • 30. Discussions ?? 30Cache Memory By Ahsan Ashfaq MS Scholar, IM|Sciences Peshawar