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

Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and ArchitectureVinit Raut
 
Pipelining
PipeliningPipelining
PipeliningAmin Omi
 
Computer architecture memory system
Computer architecture memory systemComputer architecture memory system
Computer architecture memory systemMazin Alwaaly
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipeliningMazin Alwaaly
 
Shared-Memory Multiprocessors
Shared-Memory MultiprocessorsShared-Memory Multiprocessors
Shared-Memory MultiprocessorsSalvatore La Bua
 
Cache memory principles
Cache memory principlesCache memory principles
Cache memory principlesbit allahabad
 
Interprocess communication
Interprocess communicationInterprocess communication
Interprocess communicationSushil Singh
 
Computer architecture control unit
Computer architecture control unitComputer architecture control unit
Computer architecture control unitMazin Alwaaly
 
Computer architecture cache memory
Computer architecture cache memoryComputer architecture cache memory
Computer architecture cache memoryMazin Alwaaly
 

What's hot (20)

Cache memory
Cache memoryCache memory
Cache memory
 
Cache coherence ppt
Cache coherence pptCache coherence ppt
Cache coherence ppt
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 
Cache memory
Cache memoryCache memory
Cache memory
 
Pipelining
PipeliningPipelining
Pipelining
 
Memory management
Memory managementMemory management
Memory management
 
Computer architecture memory system
Computer architecture memory systemComputer architecture memory system
Computer architecture memory system
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
 
Shared-Memory Multiprocessors
Shared-Memory MultiprocessorsShared-Memory Multiprocessors
Shared-Memory Multiprocessors
 
Cache memory
Cache memoryCache memory
Cache memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory principles
Cache memory principlesCache memory principles
Cache memory principles
 
Cache memory
Cache memoryCache memory
Cache memory
 
Interprocess communication
Interprocess communicationInterprocess communication
Interprocess communication
 
Computer architecture control unit
Computer architecture control unitComputer architecture control unit
Computer architecture control unit
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Computer architecture cache memory
Computer architecture cache memoryComputer architecture cache memory
Computer architecture cache memory
 
Parallel processing
Parallel processingParallel processing
Parallel processing
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 

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 (17)

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
 
Cache memory
Cache memoryCache memory
Cache memory
 
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
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
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
 
Cache memory presentation
Cache memory presentationCache memory presentation
Cache memory presentation
 
Address mapping
Address mappingAddress mapping
Address mapping
 

Similar to Cache memory

Cache Memory for Computer Architecture.ppt
Cache Memory for Computer Architecture.pptCache Memory for Computer Architecture.ppt
Cache Memory for Computer Architecture.pptrularofclash69
 
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)

04 cache memory
04 cache memory04 cache memory
04 cache memory
 
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
 
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
 
Cache coherence
Cache coherenceCache coherence
Cache coherence
 

Recently uploaded

UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
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
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
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
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
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
 
(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
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
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
 
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
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
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
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 

Recently uploaded (20)

UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
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...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
(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
 
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
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
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...
 
(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...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
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
 
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
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
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
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 

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