FAQ for Assignment 2
Q: Is it okay to use STL containers like map, dequeue, etc?
A:Yes
Q: The second assignment has left LRU and Frames to be implemented in a fashion of our choice. However if the given interface is used, is it enough if the function in the header is implemented as per the signature given?
A:
Yes
Q: Does the DB's instantiation need Buffer manager?
A: Yes
Q: I wonder whether you can provide the .cpp file for class DB?
A: It has been provided in the ‘include’ directory.
Q: Member functions of class DB are not static and so calls like DB::AllocatePage will not work from member functions of class BufMgr. How are these two classes related? Can I create an object of class DB in class BufMgr?
A: Use the global database instance MINIBASE_DB to invoke member functions of class DB.
Q: In frame.h, what is the difference between EmptyIt and Free?
A: Descriptions for the functions in frame.h were not provided so that you have the freedom to implement them as you like. If you wish, EmptyIt() empties the frame (i.e. resets the pincount, pid and dirty bit) and Free() deallocates the page contained in the frame (in addition to emptying the frame.)
Q: In
FlushAllPages, should I write a page to disk
even if it is pinned?
A: Yes
Q: In LRU, do I need to keep track of the pages that
might be present in the frames with pincount 0? Should I add/remove frames from
the LRU queue in FlushAllPages?
A: Not really. It is enough to record the frame
numbers.
Q: Which component should manage the memory that holds pages in buffer pool?
A: The Frame object should. When a frame is initialized, the memory for holding a page should be allocated. When the object is destroyed, the memory should be released.
Q: After all the buffer manager tests are run, the system may crash right before it exits (when ‘delete minibase_globals’ is called in main() function). What's happening?
A: There might be a bug in the provided library files. You should not worry about it though. Ensure your code pass the buffer manager test cases.
Q: What is the function Frame::Free() supposed to do?
A: For Frame::Free(), the intention was to deallocate the page held by this
frame from the database (by invoking DB::DeallocatePage). This way, it can be
invoked from BufMgr::FreePage(). Note that "free" does not mean to
free the memory held in the frame itself. However, you can of course
"inline" its logic in BufMgr::FreePage(), in which case you do not
need this function Frame::Free() any more.
Q: When I start the system, it crashes at executing line 17 of main() function. What happens?
A: Basically in line 17, some member functions in BufMgr will be invoked, such as PinPage. You can refer to db.cpp to figure out exactly what happened when the database is initialized. Therefore if you did not implement these BufMgr member functions correctly, the system will crash.
In particular, when BufMgr::PinPage and BufMgr::UnpinPage are invocated by DB::DB() indirectly from line 17 of main.cpp, the page that is pinned and returned is a directory page, with pid = 0 or 1. You should make sure that PinPage and UnpinPage corrects pings and unpins the directory pages.
Due to an issue in the library provided, the system may not behavior correctly when the size of a BufMgr class instance is too big. To reduce the size, it is recommended that you define member variables LRU* replacer in BufMgr, instead of LRU replacer.
---
Some minor errors in the code: