Selecting Replacement Policy

 

You can tell the buffer manager which replacement policy to use by reading an environment variable. Here's how to do it:

Setting Environment Variable

You can set an environment variable in several ways:

- From a DOS shell prompt you can type:

SET<space><name of environment variable> = <content of variable>.

For example, to set the value of the variable POLICY to MRU. You would type the following:

SET<space>POLICY=MRU.

- Another way you can set the variable is by opening the autoexec.bat file on your C: drive and adding a line at the end of it that has the same format as the above. For example, in autoexec.bat you would add the line:

SET<space>POLICY=MRU.

Reading Environment Variable

- From inside the buffer manager, you can read the environment variable by using the function getenv which has the format:

char *getenv(const char *name);

This function takes a string which is the name of the environment variable and returns the content of that variable as a string also.

So your code inside bufmgr.cpp could be something like this:

if (strcmp(getenv("POLICY"), "MRU") = = 0)

<Initialize your policy to be MRU>

else

<Initialize your policy to be Clock>

- getenv is a member of the stdlib so be sure to include stdlib.h in your source code.

What you should do

- You should implement the buffer manager such that it reads the environment variable POLICY (all capital letters).

- POLICY can have the values of either MRU or CLOCK (both all capital letters).

- Based on the value of POLICY the buffer manager should implement the MRU and Clock replacement policy accordingly.

- Please email the newsgroup for any question.

- If you have already submitted your project, please add this little modification and resubmit it. Sorry for the inconvenience.

This will help us grade your projects much faster.