Frequently Asked Questions

General Questions

Question (9/14/2001): How do we access the DB object?
Answer: There is a global variable "minibase_globals" that is a pointer to the class SystemDefs. This class contains all global variables.

Question (9/10/2001): Can we use MFC in the programming assignments?
Answer: No. But you are allowed to use the STL if you choose so.

Replacement Policies

Question: I was wondering if the MRU algorithm should compare the referenced time based on seconds or milliseconds.
Answer: For MRU, don't use a timestamp. Just keep simply a linked list, and whenever a page is unpinned (and its pin count is zero), put it at the front of the list. Then replace from the front of the list.

Question: About the Clock replacement policy... The book says that there is a "referenced" variable for each frame, which is set to "on" when pin# becomes 0, and this is to indicated that the frame is recently referenced. Then when the "current" hits that frame, it'll set "reference" to "off", and "current" will increment. Furthermore, it is declared that there are no frames available for replacement if "current" completes a cycle. So my question is, what if every frame has its pin>0 except one, but that frame was recently referenced (ie. "reference" = on)? Then when "current" reaches that frame, it'll turn its "reference" off and keep going. But since every other frame has pin>0, it'll loop back to its original position and declare that there is no available frame. BUT, there is an available frame, namely the one that just had its reference set to off. So it seems like "current" will have to loop through the clock twice. Comments?
Answer: Yes, the "current" will loop around twice

The hash table inside the class BufMgr

Question: I was wondering about what data structure to use to implement the buffer. A hash table would be ideal, but C++ doesn't have one defined and once our buffer gets full, the hash function will be very inefficient. So I'm wondering if it is wise to use the 'map' container defined in C++. It's run time is O(log n), which is pretty good. What do you think? Should we still use a hash table? Thanks.
Answer: For quick (constant time) lookup to check whether a PID exists in the buffer pool, you should implement a small hash table yourself.

Question: Can I use the STL to implement a hash table?
Answer: You may use the STL if you want to. I recommend against usage of the STL, since performance of the lookups is very important. The STL implementation uses a tree-based data structure that gives you an access time of O(log n) instead of O(1).