1 / 8

Buffer Management

Buffer Management. The buffer manager reads disk pages into a main memory page as needed. The general idea is to minimize the amount of disk I/O by keeping likely-to-be-requested pages in memory. Overview. Requests. The collection of main memory pages used by the

lieu
Download Presentation

Buffer Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Buffer Management The buffer manager reads disk pages into a main memory page as needed. The general idea is to minimize the amount of disk I/O by keeping likely-to-be-requested pages in memory.

  2. Overview Requests The collection of main memory pages used by the buffer manager to store needed data is called the buffer pool. Buffer Manager memory disk Disk Files

  3. When a Page is Requested... • If the requested page is not in the pool: • Choose a buffer block for replacement • If it has been modified, write it back to the disk • Read the requested page into the buffer block • Pin the page and return its address • A pin_count is used since a page can be requested multiple times.

  4. When a Page is Released... • Requestor of page must unpin it after using, and indicate if the page has been modified. • Set the dirty flag accordingly • Decrement the pin_count • A page is a candidate for replacement iff its pin_count = 0

  5. Buffer Replacement Strategies(1) • Least-Recently Used (LRU) • Choose the block that has not been accessed for the longest time • Intuitively, buffers that have not been used for a long time are less likely to be accessed sooner than those that have been accessed recently • Maintain information after each access operation

  6. Buffer Replacement Strategies(2) • Most-Recently Used (MRU) • Opposite to LRU • First-In-First-Out (FIFO) • Choose the block that has been occupied by the same page for the longest time • Require less maintenance than LRU, but it can make more mistakes. A block used repeatedly will eventually become the oldest block in the pool. It will be written back only to be reread shortly thereafter into another block

  7. Buffer Replacement Strategies(3) • Clock • Efficient approximation to LRU • Think of the buffer blocks as arranged in a circle, each associated with a flag, which is either 0 or 1. Blocks with a 0 flag are vulnerable to be replaced, while with a 1 flag are not. When the block is accessed, its flag is set to 1

  8. 0 0 0 0 1 1 1 1 0 0 1 0 1 0 1 0 Buffer Replacement Strategies(4) • The buffer manager maintain a “hand” pointing to one of the blocks. When choosing a block for replacement, it looks for the first 0 it can find, rotating clockwise, and sets all 1’s it passed to 0

More Related