Homework 1 Clarifications
Please note: The deadline for HW1 will be extended a few extra
days. It is now due on Tuesday, February 13,
at 10:00PM.
When you're interacting with the disk manager, you should not
be instantiating a new DB anywhere in your BfrMgr. Access it with a
call to SystemDefs.JavabaseDB (i.e. SystemDefs.JavabaseDB.read_page).
This DB is created by the call to SystemDefs.initDiskMgr in the
BMDriver.initBeforeTests method.
Use the parameter numbufs that's passed into the BfrMgr constructor
to specify how many buffers are in the pool, not the global
variable NUMBUF.
A call to freePage or flushPage in the BfrMgr class should not
be allowed if the pin count is > 1. For flushPage, if the pin count
is > 1, write it back to disk but do raise an exception! If
it is equal to 0 or 1, it's fine. You are
allowed to call freePage on a page that's not in the buffer pool.
However, you should not be allowed to flush a page that's not
in the buffer pool -- if that happens, throw an Exception.
Because the comments are confusing, please make sure that you're
using read_page to read a page from disk into memory, and write_page to
write the page from memory to disk.
For the method BfrMgr.pinPage method, you can ignore the emptyPage
parameter -- always regard it as false.
When we are testing your code, we will be testing it as one
cohesive piece. This means that we will only be making calls directly
to the BfrMgr class. It doesn't matter in exactly which classes the
work is being done, as long as the results of a call to any of the
BfrMgr's methods are as expected.
Finally, to fix the problem with the
BufMgrReplacer.setBufferManager() method which overrides the
corresponding method in the AbstractBufMgrReplacer, try explicitly
typecasting the replacer object to a BufMgrReplacer one. Normally, this
setBufferManager method will be called from some initialization routine
inside the BufMgr class. That call should look something like this:
setReplacer("STRING REPRESENTING REPLACER SUB-CLASS");
((BufMgrReplacer)replacer).setBufferManager(this);
Your code will be tested to verify that it performs like a buffer
manager. For example, pin() and unpin() should correctly pin and unpin
pages under different states of the buffer pool, dirty pages should be
written to disk at the appropriate times, and pick_victim() should pick
a frame correctly for a given replacement policy. These examples are
only examples, and not meant to define the only set of tests that will
be run against your code. During testing, we will only be
making direct calls to the methods in the BfrMgr class. This means that
a bug in your BfrMgr class could cause you to lose all points even
though the replacement policies are totally correct, so be sure to
test your code thoroughly with the provided BMDriver!