Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— 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 The collection of main memory pages used by the buffer manager to store needed data is called the buffer pool. Buffer Manager Disk Files Requests memory disk

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 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 1s it passed to


Download ppt "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."

Similar presentations


Ads by Google