-
Project #1 BUFFER POOL MANAGER
Key member data :
*pages_
: array ofPage
with array size ofpool_size
. APage
is a in-memory block that could be either free, or contains some contents read from disk. A content is identified bypage_id
. APage
could contains different contents (i.e. differentpage_id
) at different time. If a in-Page content is accessed by a thread, then say it is pinned; andpin_count
is incremented by 1. If the content is overwritten in memory, it is said dirty.*page_table_
: pointer to a hash table, who recordspage_id
-Page*
KV pair. When a thread want to access to certain page, it always firstly check whether the page exit inpage_table
or not. If not, then askdisk_manager_
to copy the page content to somereplacement
, wherereplacement
is either: free page in*free_list_
, or victim page in*replacer_
. (The implementation of hash table is of Task #1 of this project).*free_list_
: list ofPage
that are free to be newly referenced to some contents*replacer_
: LRU replacer, who tracks all the pages that are not being accessed by any thread (i.e.pin_count == 0
). A page in LRU replacer could be used for containing new contents, but if the page is marked as dirty, the old contents should be written back to disk (bydisk_manager_
) before associating with new contents. (The implementation of LRUReplacer is of Task #2 of this project).
Key methods:
FetchPage(page_id)
: look for a page inpage_table_
, if no exit then make areplacement
page that referenced to givenpage_id
. The replacement page either pop from*free_list
, or if*free_list
is empty, sacrify a victim page in*replacer_
and make it thereplacement
.NewPage(page_id)
andDeletePage(page_id)
: askdisk_manager_
to allocate / deallocate new page in diskFlushPage(page_id)
: write the content from in-memory page to diskUnpinPage(page_id, is_dirty)
: if a thread finish accessing a page, then unpin it (pin_count--
) and if the thread has written to the content, set is_dirty flag to be true.
-
Project #2
-
Project #3
-
Project #4