SlideShare a Scribd company logo
1 of 15
Cache Memory


                          V.Saranya
                              AP/CSE
Sri Vidya College of Engineering and
                         Technology,
                       Virudhunagar
Cache Memories
 Processor is much faster than the main memory.
   As a result, the processor has to spend much of its time waiting while instructions and data
    are being fetched from the main memory.
   Major obstacle towards achieving good performance.
 Speed of the main memory cannot be increased
  beyond a certain point.
 Cache memory is an architectural arrangement which
  makes the main memory appear faster to the
  processor than it really is.
 Cache memory is based on the property of computer
  programs known as “locality of reference”.
Locality of Reference
 Analysis of programs indicates that many instructions in
  localized areas of a program are executed repeatedly during
  some period of time, while the others are accessed relatively
  less frequently.
   These instructions may be the ones in a loop, nested loop
     or few procedures calling each other repeatedly.
   This is called “locality of reference”.
 Temporal locality of reference:
   Recently executed instruction is likely to be executed
     again very soon.
 Spatial locality of reference:
   Instructions with addresses close to a recently instruction
     are likely to be executed soon.
Cache memories

                                                          Main
                                                         Main
              Processor               Cache
                                      cache              memory
                                                        Memory



• Processor issues a Read request, a block of words is transferred from the
  main memory to the cache, one word at a time.
• Subsequent references to the data in this block of words are found in the
  cache.
• At any given time, only some blocks in the main memory are held in the
  cache. Which blocks in the main memory are in the cache is determined
  by a “mapping function”.
• When the cache is full, and a block of words needs to be transferred
  from the main memory, some block of words in the cache must be
  replaced. This is determined by a “replacement algorithm”.
Cache hit
• Existence of a cache is transparent to the processor. The
  processor                issues               Read                and
  Write requests in the same manner.
• If the data is in the cache it is called a Read or Write hit.
• Read hit:
   The data is obtained from the cache.
• Write hit:
   Cache has a replica(copy) of the contents of the main
     memory.
   Contents of the cache and the main memory may be updated
     simultaneously.      This is the write-through protocol.
   Update the contents of the cache, and mark it as updated by
     setting a bit known          as the dirty bit or modified bit. The
     contents of the main memory are updated                 when this
     block is replaced. This is write-back or copy-back protocol.
Cache miss
• If the data is not present in the cache, then a Read miss or
  Write miss occurs.
• Read miss:
   Block of words containing this requested word is transferred from
    the memory.
   After the block is transferred, the desired word is forwarded to the
    processor.
   The desired word may also be forwarded to the processor as soon
    as it is transferred without waiting for the entire block to be
    transferred. This is called load-through or early-restart.

• Write-miss:
   Write-through protocol is used, then the contents of the main
    memory are updated directly.
   If write-back protocol is used, the block containing the
    addressed word is first brought into the cache. The desired word
    is overwritten with new information.
Cache Coherence Problem

• A bit called as “valid bit” is provided for each block.
• If the block contains valid data, then the bit is set to 1, else
  it is 0.
• Valid bits are set to 0, when the power is just turned on.
• When a block is loaded into the cache for the first time, the
  valid bit is set to 1.
• Data transfers between main memory and disk occur
  directly bypassing the cache.
• When the data on a disk changes, the main memory block is
  also updated.
Cache Coherence Problem
• However, if the data is also resident in the cache, then the valid
  bit is set to 0.
• What happens if the data in the disk and main memory
  changes and the write-back protocol is being used?
• In this case, the data in the cache may also have changed and is
  indicated by the dirty bit.
• The copies of the data in the cache, and the main memory are
  different. This is called the cache coherence problem.
• One option is to force a write-back before the main memory is
  updated from the disk.
Mapping functions
 Mapping functions determine how memory
  blocks are placed in the cache.
 A simple processor example:
    Cache consisting of 128 blocks of 16 words each.
    Total size of cache is 2048 (2K) words.
    Main memory is addressable by a 16-bit address.
    Main memory has 64K words.
    Main memory has 4K blocks of 16 words each.
 Three mapping functions:
  Direct mapping
  Associative mapping
  Set-associative mapping.
Direct mapping
                                    Main      Block 0

             Cache                 memory     Block 1
tag
               Block 0
tag
               Block 1

                                            Block 127

                                            Block 128
tag
             Block 127                      Block 129




                                            Block 255
      T ag     Block       W ord
       5           7         4              Block 256

                                            Block 257
        Main memory
        address
                                            Block 4095
Direct mapping
•More than one memory block is mapped onto the same position in the
cache.
•May lead to contention for cache blocks even if the cache is not full.
•Resolve the contention by allowing new block to replace the old block,
leading to a trivial replacement algorithm.
•Memory address is divided into three fields:
   - Low order 4 bits determine one of the 16 words in a block.
   - When a new block is brought into the cache, the next 7 bits
determine which cache block this new block is placed in.
   - High order 5 bits determine which of the possible 32 blocks is
currently present in the cache. These are tag bits.
•Simple to implement but not very flexible.
Associative mapping
                                Main memory
                                      Block 0

               Cache                  Block 1
tag
               Block 0
tag
               Block 1

                                    Block 127

                                    Block 128
tag
           Block 127                Block 129




                                    Block 255
           Tag           Word
          12                4       Block 256

                                    Block 257
      Main memory address


                                   Block 4095
Associative mapping
•Main memory block can be placed into any cache
position.
•Memory address is divided into two fields:
   - Low order 4 bits identify the word within a block.
   - High order 12 bits or tag bits identify a memory block
when it is resident in the cache.
•Flexible, and uses cache space efficiently.
•Replacement algorithms can be used to replace an existing
block in the cache when the cache is full.
•Cost is higher than direct-mapped cache because of the need
to search all 128 patterns to determine whether a given block
is in the cache.
Set-Associative mapping
                           Cache             Main      Block 0
                                            memory     Block 1
       Block 0
           tag            Block 1
tag                       Block 2
          tag

       Block 3
                                                     Block 63

                                                     Block 64
tag
          tag
                        Block 126                    Block 65
      Block 127



tag
                                                     Block 127
                 T ag     Block     W ord
                  5           7       4              Block 128

                                                     Block 129
                   Main memory address

                                                     Block 4095
•Blocks of cache are grouped into sets.
•Mapping function allows a block of the main memory to reside
in any block of a specific set.
•Divide the cache into 64 sets, with two blocks per set.
•Memory block 0, 64, 128 etc. map to block 0, and they can
occupy either of the two positions.
Memory address is divided into three fields:
    - 6 bit field determines the set number.
    - High order 6 bit fields are compared to the tag
       fields of the two blocks in a set.
Set-associative mapping combination of direct and associative
mapping.
Number of blocks per set is a design parameter.
   - One extreme is to have all the blocks in one set,
      requiring no set bits (fully associative mapping).
   - Other extreme is to have one block per set, is
      the same as direct mapping.

More Related Content

What's hot

Memory Management
Memory ManagementMemory Management
Memory ManagementDEDE IRYAWAN
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organizationTushar B Kute
 
Memory organization in computer architecture
Memory organization in computer architectureMemory organization in computer architecture
Memory organization in computer architectureFaisal Hussain
 
Cache memory
Cache memory Cache memory
Cache memory Zalal Udeen
 
Direct access memory
Direct access memoryDirect access memory
Direct access memorymaliksiddique1
 
Presentation on Computer Processor
Presentation on Computer ProcessorPresentation on Computer Processor
Presentation on Computer ProcessorMoizAlSamad
 
CPU - Central processing unit
CPU - Central processing unitCPU - Central processing unit
CPU - Central processing unitAbhinav Vishnoi
 
Cache memory principles
Cache memory principlesCache memory principles
Cache memory principlesbit allahabad
 
Internal architecture-of-8086
Internal architecture-of-8086Internal architecture-of-8086
Internal architecture-of-8086Estiak Khan
 
Booting Process OS
Booting Process OSBooting Process OS
Booting Process OSanilinvns
 
Modes Of Transfer in Input/Output Organization
Modes Of Transfer in Input/Output OrganizationModes Of Transfer in Input/Output Organization
Modes Of Transfer in Input/Output OrganizationMOHIT AGARWAL
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSvampugani
 
Parallel processing
Parallel processingParallel processing
Parallel processingrajshreemuthiah
 
Cache Memory
Cache MemoryCache Memory
Cache MemorySubid Biswas
 

What's hot (20)

Memory Management
Memory ManagementMemory Management
Memory Management
 
Cache memory
Cache memoryCache memory
Cache memory
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organization
 
Memory organization in computer architecture
Memory organization in computer architectureMemory organization in computer architecture
Memory organization in computer architecture
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory
Cache memory Cache memory
Cache memory
 
Direct access memory
Direct access memoryDirect access memory
Direct access memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Presentation on Computer Processor
Presentation on Computer ProcessorPresentation on Computer Processor
Presentation on Computer Processor
 
CPU - Central processing unit
CPU - Central processing unitCPU - Central processing unit
CPU - Central processing unit
 
Cache memory principles
Cache memory principlesCache memory principles
Cache memory principles
 
Internal architecture-of-8086
Internal architecture-of-8086Internal architecture-of-8086
Internal architecture-of-8086
 
Processors
ProcessorsProcessors
Processors
 
Booting Process OS
Booting Process OSBooting Process OS
Booting Process OS
 
Modes Of Transfer in Input/Output Organization
Modes Of Transfer in Input/Output OrganizationModes Of Transfer in Input/Output Organization
Modes Of Transfer in Input/Output Organization
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Memory management
Memory managementMemory management
Memory management
 
Instruction code
Instruction codeInstruction code
Instruction code
 
Parallel processing
Parallel processingParallel processing
Parallel processing
 
Cache Memory
Cache MemoryCache Memory
Cache Memory
 

Viewers also liked (9)

cache memory
cache memorycache memory
cache memory
 
Cache memory presentation
Cache memory presentationCache memory presentation
Cache memory presentation
 
cache memory management
cache memory managementcache memory management
cache memory management
 
CS6303 - Computer Architecture
CS6303 - Computer ArchitectureCS6303 - Computer Architecture
CS6303 - Computer Architecture
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
INSTRUCTION LEVEL PARALLALISM
INSTRUCTION LEVEL PARALLALISMINSTRUCTION LEVEL PARALLALISM
INSTRUCTION LEVEL PARALLALISM
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 

Similar to Cachememory

coa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptxcoa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptxRuhul Amin
 
Computer organization memory hierarchy
Computer organization memory hierarchyComputer organization memory hierarchy
Computer organization memory hierarchyAJAL A J
 
Memory (Computer Organization)
Memory (Computer Organization)Memory (Computer Organization)
Memory (Computer Organization)JyotiprakashMishra18
 
cache memory
 cache memory cache memory
cache memoryNAHID HASAN
 
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
 
Ct213 memory subsystem
Ct213 memory subsystemCt213 memory subsystem
Ct213 memory subsystemSandeep Kamath
 
04 cache memory
04 cache memory04 cache memory
04 cache memorydilip kumar
 
Elements of cache design
Elements of cache designElements of cache design
Elements of cache designRohail Butt
 
04 cache memory
04 cache memory04 cache memory
04 cache memoryFaisal Hayat
 
04 cache memory
04 cache memory04 cache memory
04 cache memoryInshad Arshad
 
CAO-Unit-III.pptx
CAO-Unit-III.pptxCAO-Unit-III.pptx
CAO-Unit-III.pptxClassicFUKRA
 
CPU Caching Concepts
CPU Caching ConceptsCPU Caching Concepts
CPU Caching ConceptsAbhijit K Rao
 

Similar to Cachememory (20)

coa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptxcoa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptx
 
Computer organization memory hierarchy
Computer organization memory hierarchyComputer organization memory hierarchy
Computer organization memory hierarchy
 
Memory (Computer Organization)
Memory (Computer Organization)Memory (Computer Organization)
Memory (Computer Organization)
 
cache memory
 cache memory cache 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 introduction, level, function
cache memory introduction, level, functioncache memory introduction, level, function
cache memory introduction, level, function
 
Ct213 memory subsystem
Ct213 memory subsystemCt213 memory subsystem
Ct213 memory subsystem
 
cache memory
cache memorycache memory
cache memory
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
Elements of cache design
Elements of cache designElements of cache design
Elements of cache design
 
cache memory.ppt
cache memory.pptcache memory.ppt
cache memory.ppt
 
cache memory.ppt
cache memory.pptcache memory.ppt
cache memory.ppt
 
FlashCache
FlashCacheFlashCache
FlashCache
 
Mapping
MappingMapping
Mapping
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
CAO-Unit-III.pptx
CAO-Unit-III.pptxCAO-Unit-III.pptx
CAO-Unit-III.pptx
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
CPU Caching Concepts
CPU Caching ConceptsCPU Caching Concepts
CPU Caching Concepts
 

More from Slideshare

Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010Slideshare
 
Report generation
Report generationReport generation
Report generationSlideshare
 
Security in Relational model
Security in Relational modelSecurity in Relational model
Security in Relational modelSlideshare
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship ModelSlideshare
 
Major issues in data mining
Major issues in data miningMajor issues in data mining
Major issues in data miningSlideshare
 
Data preprocessing
Data preprocessingData preprocessing
Data preprocessingSlideshare
 
What is in you
What is in youWhat is in you
What is in youSlideshare
 
Propositional logic & inference
Propositional logic & inferencePropositional logic & inference
Propositional logic & inferenceSlideshare
 
Logical reasoning 21.1.13
Logical reasoning 21.1.13Logical reasoning 21.1.13
Logical reasoning 21.1.13Slideshare
 
Logic agent
Logic agentLogic agent
Logic agentSlideshare
 
Statistical learning
Statistical learningStatistical learning
Statistical learningSlideshare
 
Resolution(decision)
Resolution(decision)Resolution(decision)
Resolution(decision)Slideshare
 
Reinforcement learning 7313
Reinforcement learning 7313Reinforcement learning 7313
Reinforcement learning 7313Slideshare
 
Neural networks
Neural networksNeural networks
Neural networksSlideshare
 
Instance based learning
Instance based learningInstance based learning
Instance based learningSlideshare
 
Statistical learning
Statistical learningStatistical learning
Statistical learningSlideshare
 
Neural networks
Neural networksNeural networks
Neural networksSlideshare
 
Logical reasoning
Logical reasoning Logical reasoning
Logical reasoning Slideshare
 

More from Slideshare (20)

Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010
 
Report generation
Report generationReport generation
Report generation
 
Trigger
TriggerTrigger
Trigger
 
Security in Relational model
Security in Relational modelSecurity in Relational model
Security in Relational model
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
OLAP
OLAPOLAP
OLAP
 
Major issues in data mining
Major issues in data miningMajor issues in data mining
Major issues in data mining
 
Data preprocessing
Data preprocessingData preprocessing
Data preprocessing
 
What is in you
What is in youWhat is in you
What is in you
 
Propositional logic & inference
Propositional logic & inferencePropositional logic & inference
Propositional logic & inference
 
Logical reasoning 21.1.13
Logical reasoning 21.1.13Logical reasoning 21.1.13
Logical reasoning 21.1.13
 
Logic agent
Logic agentLogic agent
Logic agent
 
Statistical learning
Statistical learningStatistical learning
Statistical learning
 
Resolution(decision)
Resolution(decision)Resolution(decision)
Resolution(decision)
 
Reinforcement learning 7313
Reinforcement learning 7313Reinforcement learning 7313
Reinforcement learning 7313
 
Neural networks
Neural networksNeural networks
Neural networks
 
Instance based learning
Instance based learningInstance based learning
Instance based learning
 
Statistical learning
Statistical learningStatistical learning
Statistical learning
 
Neural networks
Neural networksNeural networks
Neural networks
 
Logical reasoning
Logical reasoning Logical reasoning
Logical reasoning
 

Recently uploaded

Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
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
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
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
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
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
 

Recently uploaded (20)

Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
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
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
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
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

Cachememory

  • 1. Cache Memory V.Saranya AP/CSE Sri Vidya College of Engineering and Technology, Virudhunagar
  • 2. Cache Memories  Processor is much faster than the main memory.  As a result, the processor has to spend much of its time waiting while instructions and data are being fetched from the main memory.  Major obstacle towards achieving good performance.  Speed of the main memory cannot be increased beyond a certain point.  Cache memory is an architectural arrangement which makes the main memory appear faster to the processor than it really is.  Cache memory is based on the property of computer programs known as “locality of reference”.
  • 3. Locality of Reference  Analysis of programs indicates that many instructions in localized areas of a program are executed repeatedly during some period of time, while the others are accessed relatively less frequently.  These instructions may be the ones in a loop, nested loop or few procedures calling each other repeatedly.  This is called “locality of reference”.  Temporal locality of reference:  Recently executed instruction is likely to be executed again very soon.  Spatial locality of reference:  Instructions with addresses close to a recently instruction are likely to be executed soon.
  • 4. Cache memories Main Main Processor Cache cache memory Memory • Processor issues a Read request, a block of words is transferred from the main memory to the cache, one word at a time. • Subsequent references to the data in this block of words are found in the cache. • At any given time, only some blocks in the main memory are held in the cache. Which blocks in the main memory are in the cache is determined by a “mapping function”. • When the cache is full, and a block of words needs to be transferred from the main memory, some block of words in the cache must be replaced. This is determined by a “replacement algorithm”.
  • 5. Cache hit • Existence of a cache is transparent to the processor. The processor issues Read and Write requests in the same manner. • If the data is in the cache it is called a Read or Write hit. • Read hit:  The data is obtained from the cache. • Write hit:  Cache has a replica(copy) of the contents of the main memory.  Contents of the cache and the main memory may be updated simultaneously. This is the write-through protocol.  Update the contents of the cache, and mark it as updated by setting a bit known as the dirty bit or modified bit. The contents of the main memory are updated when this block is replaced. This is write-back or copy-back protocol.
  • 6. Cache miss • If the data is not present in the cache, then a Read miss or Write miss occurs. • Read miss:  Block of words containing this requested word is transferred from the memory.  After the block is transferred, the desired word is forwarded to the processor.  The desired word may also be forwarded to the processor as soon as it is transferred without waiting for the entire block to be transferred. This is called load-through or early-restart. • Write-miss:  Write-through protocol is used, then the contents of the main memory are updated directly.  If write-back protocol is used, the block containing the addressed word is first brought into the cache. The desired word is overwritten with new information.
  • 7. Cache Coherence Problem • A bit called as “valid bit” is provided for each block. • If the block contains valid data, then the bit is set to 1, else it is 0. • Valid bits are set to 0, when the power is just turned on. • When a block is loaded into the cache for the first time, the valid bit is set to 1. • Data transfers between main memory and disk occur directly bypassing the cache. • When the data on a disk changes, the main memory block is also updated.
  • 8. Cache Coherence Problem • However, if the data is also resident in the cache, then the valid bit is set to 0. • What happens if the data in the disk and main memory changes and the write-back protocol is being used? • In this case, the data in the cache may also have changed and is indicated by the dirty bit. • The copies of the data in the cache, and the main memory are different. This is called the cache coherence problem. • One option is to force a write-back before the main memory is updated from the disk.
  • 9. Mapping functions  Mapping functions determine how memory blocks are placed in the cache.  A simple processor example:  Cache consisting of 128 blocks of 16 words each.  Total size of cache is 2048 (2K) words.  Main memory is addressable by a 16-bit address.  Main memory has 64K words.  Main memory has 4K blocks of 16 words each.  Three mapping functions:  Direct mapping  Associative mapping  Set-associative mapping.
  • 10. Direct mapping Main Block 0 Cache memory Block 1 tag Block 0 tag Block 1 Block 127 Block 128 tag Block 127 Block 129 Block 255 T ag Block W ord 5 7 4 Block 256 Block 257 Main memory address Block 4095
  • 11. Direct mapping •More than one memory block is mapped onto the same position in the cache. •May lead to contention for cache blocks even if the cache is not full. •Resolve the contention by allowing new block to replace the old block, leading to a trivial replacement algorithm. •Memory address is divided into three fields: - Low order 4 bits determine one of the 16 words in a block. - When a new block is brought into the cache, the next 7 bits determine which cache block this new block is placed in. - High order 5 bits determine which of the possible 32 blocks is currently present in the cache. These are tag bits. •Simple to implement but not very flexible.
  • 12. Associative mapping Main memory Block 0 Cache Block 1 tag Block 0 tag Block 1 Block 127 Block 128 tag Block 127 Block 129 Block 255 Tag Word 12 4 Block 256 Block 257 Main memory address Block 4095
  • 13. Associative mapping •Main memory block can be placed into any cache position. •Memory address is divided into two fields: - Low order 4 bits identify the word within a block. - High order 12 bits or tag bits identify a memory block when it is resident in the cache. •Flexible, and uses cache space efficiently. •Replacement algorithms can be used to replace an existing block in the cache when the cache is full. •Cost is higher than direct-mapped cache because of the need to search all 128 patterns to determine whether a given block is in the cache.
  • 14. Set-Associative mapping Cache Main Block 0 memory Block 1 Block 0 tag Block 1 tag Block 2 tag Block 3 Block 63 Block 64 tag tag Block 126 Block 65 Block 127 tag Block 127 T ag Block W ord 5 7 4 Block 128 Block 129 Main memory address Block 4095
  • 15. •Blocks of cache are grouped into sets. •Mapping function allows a block of the main memory to reside in any block of a specific set. •Divide the cache into 64 sets, with two blocks per set. •Memory block 0, 64, 128 etc. map to block 0, and they can occupy either of the two positions. Memory address is divided into three fields: - 6 bit field determines the set number. - High order 6 bit fields are compared to the tag fields of the two blocks in a set. Set-associative mapping combination of direct and associative mapping. Number of blocks per set is a design parameter. - One extreme is to have all the blocks in one set, requiring no set bits (fully associative mapping). - Other extreme is to have one block per set, is the same as direct mapping.