SlideShare a Scribd company logo
1 of 10
BuffersBuffers
Let’s go for a swimLet’s go for a swim
BuffersBuffers
• A buffer is simply a collection of bytesA buffer is simply a collection of bytes
– a char[] if you will.a char[] if you will.
• Any information that a program uses canAny information that a program uses can
be stored in a buffer.be stored in a buffer.
• If you have to store a lot of informationIf you have to store a lot of information
you may have more than one buffer toyou may have more than one buffer to
store the informationstore the information
• It makes sense to organize all of theseIt makes sense to organize all of these
buffers in some sort of structure.buffers in some sort of structure.
• A buffer poolA buffer pool
Buffer PoolsBuffer Pools
• A buffer pool can be as simple as an arrayA buffer pool can be as simple as an array
of char[].of char[].
• You can use the buffers as you need themYou can use the buffers as you need them
for quick access to the information if it isfor quick access to the information if it is
stored in the pool.stored in the pool.
• If it’s not in the pool then you can put theIf it’s not in the pool then you can put the
information in it.information in it.
• The problem comes in when the pool isThe problem comes in when the pool is
full.full.
Organizing Buffer PoolsOrganizing Buffer Pools
• Which buffer should be replaced whenWhich buffer should be replaced when
new data must be read?new data must be read?
– First-in, First-out: Use the first one on theFirst-in, First-out: Use the first one on the
queue.queue.
– Least Frequently Used (LFU): Count bufferLeast Frequently Used (LFU): Count buffer
accesses, reuse the least used.accesses, reuse the least used.
– Least Recently used (LRU): Keep buffers onLeast Recently used (LRU): Keep buffers on
a linked list. When buffer is accessed, bringa linked list. When buffer is accessed, bring
it to front. Reuse the one at end.it to front. Reuse the one at end.
Buffer Pool ImplementationsBuffer Pool Implementations
• Two main optionsTwo main options
– Message passingMessage passing
• The pool user asks/gives the buffer pool for aThe pool user asks/gives the buffer pool for a
certain amount of information and tells it where tocertain amount of information and tells it where to
put it.put it.
– Buffer passingBuffer passing
• The pool user is given a pointer to the block theyThe pool user is given a pointer to the block they
request.request.
• Both options have their advantages andBoth options have their advantages and
disadvantages.disadvantages.
Design IssuesDesign Issues
Disadvantage of message passing:Disadvantage of message passing:
– Messages are copied and passed back and forth.Messages are copied and passed back and forth.
Disadvantages of buffer passing:Disadvantages of buffer passing:
– The user is given access to system memory (theThe user is given access to system memory (the
buffer itself)buffer itself)
– The user must explicitly tell the buffer pool whenThe user must explicitly tell the buffer pool when
buffer contents have been modified, so that modifiedbuffer contents have been modified, so that modified
data can be rewritten to disk when the buffer isdata can be rewritten to disk when the buffer is
flushed.flushed.
– The pointer might becomeThe pointer might become stalestale when the bufferwhen the buffer
pool replaces the contents of a buffer.pool replaces the contents of a buffer.
Buffer Pool ApplicationsBuffer Pool Applications
• Usually, buffer pools are used to mediateUsually, buffer pools are used to mediate
between a program and disk access.between a program and disk access.
• A program will use a buffer pool to makeA program will use a buffer pool to make
requests for information.requests for information.
• The buffer pool will go to the disk and getThe buffer pool will go to the disk and get
the information if it doesn’t have it.the information if it doesn’t have it.
Buffer Pool StrategiesBuffer Pool Strategies
• When a buffer pool needs to get theWhen a buffer pool needs to get the
information it has a couple differentinformation it has a couple different
optionsoptions
– It can get just the information it needs fromIt can get just the information it needs from
the filethe file
– It can get the entire block with the informationIt can get the entire block with the information
in itin it
• To the end user the result is the same, theTo the end user the result is the same, the
requested information is returned to themrequested information is returned to them
More on StrategiesMore on Strategies
• If you remember the access times for a byte andIf you remember the access times for a byte and
for a block:for a block:
– 15.05 ms/byte15.05 ms/byte
– 15.1 ms/block15.1 ms/block
• It makes sense to grab the entire block at a timeIt makes sense to grab the entire block at a time
• And then have some logic that goes in the bufferAnd then have some logic that goes in the buffer
once it’s in memory and return the requestedonce it’s in memory and return the requested
infoinfo
What does this mean for me?What does this mean for me?
• For major project 1 we are asking you toFor major project 1 we are asking you to
implement a buffer pool that will bufferimplement a buffer pool that will buffer
individual recordsindividual records
• Therefore, when a record is requestedTherefore, when a record is requested
from the buffer pool it checks to see if itfrom the buffer pool it checks to see if it
has that recordhas that record
– If it does it returns that recordIf it does it returns that record
– If not, it must go to disk and get it.If not, it must go to disk and get it.

More Related Content

Similar to Buffers (1)

Distributed applications using Hazelcast
Distributed applications using HazelcastDistributed applications using Hazelcast
Distributed applications using HazelcastTaras Matyashovsky
 
Netty Notes Part 2 - Transports and Buffers
Netty Notes Part 2 - Transports and BuffersNetty Notes Part 2 - Transports and Buffers
Netty Notes Part 2 - Transports and BuffersRick Hightower
 
qdoc.tips_oracle-dba-interview-questions.pdf
qdoc.tips_oracle-dba-interview-questions.pdfqdoc.tips_oracle-dba-interview-questions.pdf
qdoc.tips_oracle-dba-interview-questions.pdfOsamaQahtan
 
Progress OE performance management
Progress OE performance managementProgress OE performance management
Progress OE performance managementYassine MOALLA
 
Progress Openedge performance management
Progress Openedge performance managementProgress Openedge performance management
Progress Openedge performance managementYassine MOALLA
 
Buffer cache unix ppt Mrs.Sowmya Jyothi
Buffer cache unix ppt Mrs.Sowmya JyothiBuffer cache unix ppt Mrs.Sowmya Jyothi
Buffer cache unix ppt Mrs.Sowmya JyothiSowmya Jyothi
 
HP-UX Swap and Dump Unleashed by Dusan Baljevic
HP-UX Swap and Dump Unleashed by Dusan BaljevicHP-UX Swap and Dump Unleashed by Dusan Baljevic
HP-UX Swap and Dump Unleashed by Dusan BaljevicCircling Cycle
 
EnterpriseDB BackUp and Recovery Tool
EnterpriseDB BackUp and Recovery ToolEnterpriseDB BackUp and Recovery Tool
EnterpriseDB BackUp and Recovery ToolEDB
 
Using broadcast media in your teaching
Using broadcast media in your teachingUsing broadcast media in your teaching
Using broadcast media in your teachingChris Willmott
 
Multiprocessor Systems
Multiprocessor SystemsMultiprocessor Systems
Multiprocessor Systemsvampugani
 
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...xKinAnx
 
Oracle Database Buffer Cache Management.pptx
Oracle Database Buffer Cache Management.pptxOracle Database Buffer Cache Management.pptx
Oracle Database Buffer Cache Management.pptxRemote DBA Services
 
Presentation on backup and recoveryyyyyyyyyyyyyyyyyyy
Presentation on backup and recoveryyyyyyyyyyyyyyyyyyyPresentation on backup and recoveryyyyyyyyyyyyyyyyyyy
Presentation on backup and recoveryyyyyyyyyyyyyyyyyyyTehmina Gulfam
 
Presentation on backup and recoveryyyyyyyyyyyyy
Presentation on backup and recoveryyyyyyyyyyyyyPresentation on backup and recoveryyyyyyyyyyyyy
Presentation on backup and recoveryyyyyyyyyyyyyTehmina Gulfam
 
Message:Passing - lpw 2012
Message:Passing - lpw 2012Message:Passing - lpw 2012
Message:Passing - lpw 2012Tomas Doran
 
Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O YourHelper1
 

Similar to Buffers (1) (20)

12-6810-12.ppt
12-6810-12.ppt12-6810-12.ppt
12-6810-12.ppt
 
Distributed applications using Hazelcast
Distributed applications using HazelcastDistributed applications using Hazelcast
Distributed applications using Hazelcast
 
Netty Notes Part 2 - Transports and Buffers
Netty Notes Part 2 - Transports and BuffersNetty Notes Part 2 - Transports and Buffers
Netty Notes Part 2 - Transports and Buffers
 
qdoc.tips_oracle-dba-interview-questions.pdf
qdoc.tips_oracle-dba-interview-questions.pdfqdoc.tips_oracle-dba-interview-questions.pdf
qdoc.tips_oracle-dba-interview-questions.pdf
 
Progress OE performance management
Progress OE performance managementProgress OE performance management
Progress OE performance management
 
Progress Openedge performance management
Progress Openedge performance managementProgress Openedge performance management
Progress Openedge performance management
 
Buffer cache unix ppt Mrs.Sowmya Jyothi
Buffer cache unix ppt Mrs.Sowmya JyothiBuffer cache unix ppt Mrs.Sowmya Jyothi
Buffer cache unix ppt Mrs.Sowmya Jyothi
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
 
HP-UX Swap and Dump Unleashed by Dusan Baljevic
HP-UX Swap and Dump Unleashed by Dusan BaljevicHP-UX Swap and Dump Unleashed by Dusan Baljevic
HP-UX Swap and Dump Unleashed by Dusan Baljevic
 
Gstreamer internals
Gstreamer internalsGstreamer internals
Gstreamer internals
 
EnterpriseDB BackUp and Recovery Tool
EnterpriseDB BackUp and Recovery ToolEnterpriseDB BackUp and Recovery Tool
EnterpriseDB BackUp and Recovery Tool
 
Using broadcast media in your teaching
Using broadcast media in your teachingUsing broadcast media in your teaching
Using broadcast media in your teaching
 
Multiprocessor Systems
Multiprocessor SystemsMultiprocessor Systems
Multiprocessor Systems
 
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...
Ibm spectrum scale fundamentals workshop for americas part 4 Replication, Str...
 
Oracle Database Buffer Cache Management.pptx
Oracle Database Buffer Cache Management.pptxOracle Database Buffer Cache Management.pptx
Oracle Database Buffer Cache Management.pptx
 
Cache Memory.pptx
Cache Memory.pptxCache Memory.pptx
Cache Memory.pptx
 
Presentation on backup and recoveryyyyyyyyyyyyyyyyyyy
Presentation on backup and recoveryyyyyyyyyyyyyyyyyyyPresentation on backup and recoveryyyyyyyyyyyyyyyyyyy
Presentation on backup and recoveryyyyyyyyyyyyyyyyyyy
 
Presentation on backup and recoveryyyyyyyyyyyyy
Presentation on backup and recoveryyyyyyyyyyyyyPresentation on backup and recoveryyyyyyyyyyyyy
Presentation on backup and recoveryyyyyyyyyyyyy
 
Message:Passing - lpw 2012
Message:Passing - lpw 2012Message:Passing - lpw 2012
Message:Passing - lpw 2012
 
Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O
 

More from Avijeet Negel

More from Avijeet Negel (20)

TCP/IP
TCP/IPTCP/IP
TCP/IP
 
Upper OSI LAYER
Upper OSI LAYERUpper OSI LAYER
Upper OSI LAYER
 
SONET/SDH
SONET/SDHSONET/SDH
SONET/SDH
 
ATM
ATMATM
ATM
 
Frame Relay
Frame RelayFrame Relay
Frame Relay
 
X.25
X.25X.25
X.25
 
Integrated Services Digital Network (ISDN)
Integrated Services Digital Network (ISDN)Integrated Services Digital Network (ISDN)
Integrated Services Digital Network (ISDN)
 
Switching
SwitchingSwitching
Switching
 
Point to Point Protocol
Point to Point ProtocolPoint to Point Protocol
Point to Point Protocol
 
Networking and Networking Devices
Networking and Networking DevicesNetworking and Networking Devices
Networking and Networking Devices
 
DATA Link Control
DATA Link ControlDATA Link Control
DATA Link Control
 
CRC
CRCCRC
CRC
 
Error Detection and Correction
Error Detection and CorrectionError Detection and Correction
Error Detection and Correction
 
Telephone Network
Telephone NetworkTelephone Network
Telephone Network
 
Time Division Multiplexing
Time Division MultiplexingTime Division Multiplexing
Time Division Multiplexing
 
MULTIPLEXING
MULTIPLEXINGMULTIPLEXING
MULTIPLEXING
 
Radio Communication Band
Radio Communication BandRadio Communication Band
Radio Communication Band
 
Transmission Media
Transmission MediaTransmission Media
Transmission Media
 
DB-37 AND DB-9 CONNECTORS
DB-37 AND DB-9 CONNECTORSDB-37 AND DB-9 CONNECTORS
DB-37 AND DB-9 CONNECTORS
 
Transmission Of Digital Data
Transmission Of Digital DataTransmission Of Digital Data
Transmission Of Digital Data
 

Recently uploaded

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Recently uploaded (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Buffers (1)

  • 1. BuffersBuffers Let’s go for a swimLet’s go for a swim
  • 2. BuffersBuffers • A buffer is simply a collection of bytesA buffer is simply a collection of bytes – a char[] if you will.a char[] if you will. • Any information that a program uses canAny information that a program uses can be stored in a buffer.be stored in a buffer. • If you have to store a lot of informationIf you have to store a lot of information you may have more than one buffer toyou may have more than one buffer to store the informationstore the information • It makes sense to organize all of theseIt makes sense to organize all of these buffers in some sort of structure.buffers in some sort of structure. • A buffer poolA buffer pool
  • 3. Buffer PoolsBuffer Pools • A buffer pool can be as simple as an arrayA buffer pool can be as simple as an array of char[].of char[]. • You can use the buffers as you need themYou can use the buffers as you need them for quick access to the information if it isfor quick access to the information if it is stored in the pool.stored in the pool. • If it’s not in the pool then you can put theIf it’s not in the pool then you can put the information in it.information in it. • The problem comes in when the pool isThe problem comes in when the pool is full.full.
  • 4. Organizing Buffer PoolsOrganizing Buffer Pools • Which buffer should be replaced whenWhich buffer should be replaced when new data must be read?new data must be read? – First-in, First-out: Use the first one on theFirst-in, First-out: Use the first one on the queue.queue. – Least Frequently Used (LFU): Count bufferLeast Frequently Used (LFU): Count buffer accesses, reuse the least used.accesses, reuse the least used. – Least Recently used (LRU): Keep buffers onLeast Recently used (LRU): Keep buffers on a linked list. When buffer is accessed, bringa linked list. When buffer is accessed, bring it to front. Reuse the one at end.it to front. Reuse the one at end.
  • 5. Buffer Pool ImplementationsBuffer Pool Implementations • Two main optionsTwo main options – Message passingMessage passing • The pool user asks/gives the buffer pool for aThe pool user asks/gives the buffer pool for a certain amount of information and tells it where tocertain amount of information and tells it where to put it.put it. – Buffer passingBuffer passing • The pool user is given a pointer to the block theyThe pool user is given a pointer to the block they request.request. • Both options have their advantages andBoth options have their advantages and disadvantages.disadvantages.
  • 6. Design IssuesDesign Issues Disadvantage of message passing:Disadvantage of message passing: – Messages are copied and passed back and forth.Messages are copied and passed back and forth. Disadvantages of buffer passing:Disadvantages of buffer passing: – The user is given access to system memory (theThe user is given access to system memory (the buffer itself)buffer itself) – The user must explicitly tell the buffer pool whenThe user must explicitly tell the buffer pool when buffer contents have been modified, so that modifiedbuffer contents have been modified, so that modified data can be rewritten to disk when the buffer isdata can be rewritten to disk when the buffer is flushed.flushed. – The pointer might becomeThe pointer might become stalestale when the bufferwhen the buffer pool replaces the contents of a buffer.pool replaces the contents of a buffer.
  • 7. Buffer Pool ApplicationsBuffer Pool Applications • Usually, buffer pools are used to mediateUsually, buffer pools are used to mediate between a program and disk access.between a program and disk access. • A program will use a buffer pool to makeA program will use a buffer pool to make requests for information.requests for information. • The buffer pool will go to the disk and getThe buffer pool will go to the disk and get the information if it doesn’t have it.the information if it doesn’t have it.
  • 8. Buffer Pool StrategiesBuffer Pool Strategies • When a buffer pool needs to get theWhen a buffer pool needs to get the information it has a couple differentinformation it has a couple different optionsoptions – It can get just the information it needs fromIt can get just the information it needs from the filethe file – It can get the entire block with the informationIt can get the entire block with the information in itin it • To the end user the result is the same, theTo the end user the result is the same, the requested information is returned to themrequested information is returned to them
  • 9. More on StrategiesMore on Strategies • If you remember the access times for a byte andIf you remember the access times for a byte and for a block:for a block: – 15.05 ms/byte15.05 ms/byte – 15.1 ms/block15.1 ms/block • It makes sense to grab the entire block at a timeIt makes sense to grab the entire block at a time • And then have some logic that goes in the bufferAnd then have some logic that goes in the buffer once it’s in memory and return the requestedonce it’s in memory and return the requested infoinfo
  • 10. What does this mean for me?What does this mean for me? • For major project 1 we are asking you toFor major project 1 we are asking you to implement a buffer pool that will bufferimplement a buffer pool that will buffer individual recordsindividual records • Therefore, when a record is requestedTherefore, when a record is requested from the buffer pool it checks to see if itfrom the buffer pool it checks to see if it has that recordhas that record – If it does it returns that recordIf it does it returns that record – If not, it must go to disk and get it.If not, it must go to disk and get it.