SlideShare a Scribd company logo
1 of 18
Content:
▪ What is Cache?
▪ Cache Operation.
▪ Cache Design.
▪ Direct Mapping
▪ Associative Mapping.
▪ Replacement Algorithm.
▪ Write Policy.
▪ Write Through.
▪ Write Back.
Cache.
Small amount of fast memory
Sits between normal main memory and CPU
May be located on CPU chip or module
Back
Cache Operation
Back
Cache Design:
Size
Mapping Function
Replacement Algorithm
Write Policy
Block Size
Number of Caches
Direct Mapping:
Each location in RAM has one specific place in cache where
the data will be held
Address is in two parts.
1)Least Significant w bits identify unique word
2)Most Significant s bits specify one memory block .
▪ DM is Inexpensive and simple.
▪ Fixed location for given block:
▪ If a program accesses 2 blocks that map to the same line
repeatedly, cache misses are very high
Direct Mapping Address Structure.
17 bits 9 bits 6 bits
▪ 32 bit address
▪ 6 bits word identifier (4 byte block)
▪ 26 bit block identifier
▪ 17 bit tag (=26-17)
▪ 9 bit slot or line
Replacement Algorithm
Direct Mapping
▪ No choice
▪ Each block only maps to one line
▪ Replace that line
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
Tag 22 bit
Word
2 bit
A Diagram Link
Set Associative Mapping.
▪ Cache is divided into a number of sets
▪ Each set contains a number of lines
▪ A given block maps to any line in a given set
▪ e.g. Block B can be in any line of set i
▪ 2 lines per set
▪ 2 way associative mapping
▪ A given block can be in one of 2 lines in only one set
Example of Set Associative.
▪ 13 bit set number
▪ 000000, 00A000, 00B000, 00C000 … map to same
set
Tag 9 bit Set 13 bit
Word
2 bit
Replacement Algorithms
Associative & Set Associate Mapping.
▪ Hardware implemented algorithm (speed)
▪ Least Recently Used (LRU)
▪ In 2 way set associative
▪ Which of the 2 block is LRU?
Replacement Algorithms
Associative & Set Associate Mapping.
 First in first out (FIFO)
 replace block that has been in cache longest
 Least frequently used
 Replace block which has had fewest hits
 Random
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
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
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
What is Cache and how it works
What is Cache and how it works

More Related Content

What's hot

Computer organization memory
Computer organization memoryComputer organization memory
Computer organization memoryDeepak John
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memoryMazin Alwaaly
 
Cache memory ppt
Cache memory ppt  Cache memory ppt
Cache memory ppt Arpita Naik
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and ArchitectureVinit Raut
 
Cache memory
Cache memoryCache memory
Cache memoryAnuj Modi
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAnuj Modi
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)Sandesh Jonchhe
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memoryvampugani
 
Memory organization
Memory organizationMemory organization
Memory organizationAL- AMIN
 
Memory organization
Memory organizationMemory organization
Memory organizationDhaval Bagal
 
CS4109 Computer System Architecture
CS4109 Computer System ArchitectureCS4109 Computer System Architecture
CS4109 Computer System Architecturektosri
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual MemoryArchith777
 
Lecture1 - Computer Architecture
Lecture1 - Computer ArchitectureLecture1 - Computer Architecture
Lecture1 - Computer ArchitectureVolodymyr Ushenko
 
Memory management ppt coa
Memory management ppt coaMemory management ppt coa
Memory management ppt coaBharti Khemani
 

What's hot (20)

Cache memory
Cache  memoryCache  memory
Cache memory
 
Computer organization memory
Computer organization memoryComputer organization memory
Computer organization memory
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memory
 
Virtual memory
Virtual memory Virtual memory
Virtual memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory ppt
Cache memory ppt  Cache memory ppt
Cache memory ppt
 
Cache memory
Cache memoryCache memory
Cache memory
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 
Memory Hierarchy
Memory HierarchyMemory Hierarchy
Memory Hierarchy
 
Cache memory
Cache memoryCache memory
Cache memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
memory hierarchy
memory hierarchymemory hierarchy
memory hierarchy
 
Memory organization
Memory organizationMemory organization
Memory organization
 
Memory organization
Memory organizationMemory organization
Memory organization
 
CS4109 Computer System Architecture
CS4109 Computer System ArchitectureCS4109 Computer System Architecture
CS4109 Computer System Architecture
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Lecture1 - Computer Architecture
Lecture1 - Computer ArchitectureLecture1 - Computer Architecture
Lecture1 - Computer Architecture
 
Memory management ppt coa
Memory management ppt coaMemory management ppt coa
Memory management ppt coa
 

Similar to What is Cache and how it works

Similar to What is Cache and how it works (20)

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
 cache memory cache memory
cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
coa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptxcoa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptx
 
COA
COACOA
COA
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
cache memory
cache memorycache memory
cache memory
 
04 Cache Memory
04  Cache  Memory04  Cache  Memory
04 Cache Memory
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
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
 
Memory Mapping Cache
Memory Mapping CacheMemory Mapping Cache
Memory Mapping Cache
 
Ct213 memory subsystem
Ct213 memory subsystemCt213 memory subsystem
Ct213 memory subsystem
 
cache memory introduction, level, function
cache memory introduction, level, functioncache memory introduction, level, function
cache memory introduction, level, function
 
Memory Hierarchy PPT of Computer Organization
Memory Hierarchy PPT of Computer OrganizationMemory Hierarchy PPT of Computer Organization
Memory Hierarchy PPT of Computer Organization
 

Recently uploaded

ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 

Recently uploaded (20)

ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 

What is Cache and how it works

  • 1. Content: ▪ What is Cache? ▪ Cache Operation. ▪ Cache Design. ▪ Direct Mapping ▪ Associative Mapping. ▪ Replacement Algorithm. ▪ Write Policy. ▪ Write Through. ▪ Write Back.
  • 2. Cache. Small amount of fast memory Sits between normal main memory and CPU May be located on CPU chip or module
  • 5. Cache Design: Size Mapping Function Replacement Algorithm Write Policy Block Size Number of Caches
  • 6. Direct Mapping: Each location in RAM has one specific place in cache where the data will be held Address is in two parts. 1)Least Significant w bits identify unique word 2)Most Significant s bits specify one memory block . ▪ DM is Inexpensive and simple. ▪ Fixed location for given block: ▪ If a program accesses 2 blocks that map to the same line repeatedly, cache misses are very high
  • 7. Direct Mapping Address Structure. 17 bits 9 bits 6 bits ▪ 32 bit address ▪ 6 bits word identifier (4 byte block) ▪ 26 bit block identifier ▪ 17 bit tag (=26-17) ▪ 9 bit slot or line
  • 8. Replacement Algorithm Direct Mapping ▪ No choice ▪ Each block only maps to one line ▪ Replace that line
  • 9. 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 Tag 22 bit Word 2 bit A Diagram Link
  • 10. Set Associative Mapping. ▪ Cache is divided into a number of sets ▪ Each set contains a number of lines ▪ A given block maps to any line in a given set ▪ e.g. Block B can be in any line of set i ▪ 2 lines per set ▪ 2 way associative mapping ▪ A given block can be in one of 2 lines in only one set
  • 11. Example of Set Associative. ▪ 13 bit set number ▪ 000000, 00A000, 00B000, 00C000 … map to same set Tag 9 bit Set 13 bit Word 2 bit
  • 12. Replacement Algorithms Associative & Set Associate Mapping. ▪ Hardware implemented algorithm (speed) ▪ Least Recently Used (LRU) ▪ In 2 way set associative ▪ Which of the 2 block is LRU?
  • 13. Replacement Algorithms Associative & Set Associate Mapping.  First in first out (FIFO)  replace block that has been in cache longest  Least frequently used  Replace block which has had fewest hits  Random
  • 14. 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
  • 15. 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
  • 16. 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

Editor's Notes

  1. Direct has the lowest performance, but is easiest to implement • Direct is often used for instruction cache • Sequential addresses fill a cache line and then go to the next cache line
  2. The cache memory is divided into blocks or lines. Currently lines can range from 16 to 64 bytes • Data is copied to and from the cache one line at a time
  3. DM: Each block of main memory maps to only one cache line i.e. if a block is in cache, it must be in one specific place… Address is in two parts 1)Least Significant w bits identify unique word 2)Most Significant s bits specify one memory block . DM is Inexpensive and simple. Fixed location for given block: If a program accesses 2 blocks that map to the same line repeatedly, cache misses are very high
  4. A main memory block can load into any line of cache.. Memory address is interpreted as tag and word…Cache searching gets expensive