Presentation is loading. Please wait.

Presentation is loading. Please wait.

HW4: Buffer Manager Instructors: Winston Hsu, Hao-Hua Chu Fall 2010.

Similar presentations


Presentation on theme: "HW4: Buffer Manager Instructors: Winston Hsu, Hao-Hua Chu Fall 2010."— Presentation transcript:

1 HW4: Buffer Manager Instructors: Winston Hsu, Hao-Hua Chu Fall 2010

2 Buffer Management in a DBMS Data must be in RAM for DBMS to operate on it! Buffer Mgr hides the fact that not all data is in RAM DB MAIN MEMORY DISK disk page free frame Page Requests from Higher Levels BUFFER POOL choice of frame dictated by replacement policy

3 Buffer Manager Simple Buffer Manager Structure – Pages in the buffer pool is not ordered in any way – Hash table to figure out what frame a given disk page occupies – Love/Hate buffer replace algorithm Operations – bring a disk page into the buffer pool and pin it – unpin a page in the buffer pool – allocate/de-allocate pages on disk – flush/flush all buffer page(s) into the disk page

4 Buffer Manager Memory Structure FrameDesc pageNo dirtyFlag pin_count Buffer Page Description numbuf Page Buffer Pool Buffer Hash Table HTSIZE pageNo frameNo *next pageNo frameNo *next ……

5 Love/Hate Replacement upper level user hints the buffer manager that the page is loved or hated. Replace hated pages first, then loved pages. MRU list for the hated pages, LRU list for the loved pages “ Love conquers hate “

6 Functions (in buf.h and buf.C) BufMgr – Initializes buffer manager: create buffer pool, buffer pool description, hash table….etc. pinPage, unpinPage, newPage, freePage, flushPage, flushAllPages – Use Minibase API Your own functions (if needed) – For hash table and replacement policy

7 Minibase APIs Page – Status MINIBASE_DB->read_page(PageId pageno, Page* pageptr) – Status MINIBASE_DB->write_page(PageId pageno, Page* pageptr) – Status MINIBASE_DB->allocate_page(PageId& start_page_num, int run_size=1) – Status MINIBASE_DB->deallocate_page(PageId start_page_num, int run_size=1) Errors handling status = MINIBASE_DB->write_page(pageid, &bufPool[i]); if (status != OK) {// status: OK or FAIL // your own error message } (See ErrProc.sample for more information)

8 Get Started Read the PDF for detail description. Group assignment (at most 2 people/group) Download BufMgr for source code. Read README.first before you start. Post your questions on ptt.cc / CSIE_DBMS. Minibase homepage and Google Minibase homepageGoogle


Download ppt "HW4: Buffer Manager Instructors: Winston Hsu, Hao-Hua Chu Fall 2010."

Similar presentations


Ads by Google