Operating Systems Lab2: Memory Management

Due: Monday Nov 20th at 11:59pm


In this lab you will have the opportunity to practice using some of the memory management techniques that we've studied in class. You will modify a memory management simulator, written in Java to add  page replacement algorithms other than what you are given to start with.

The Simulator:

We will use the MOSS memory simulator for this lab. (MOSS: Modern Operating Systems Simulators). The original MOSS was written for Java 1.0 some time ago. I've updated the version on Eagle to java 1.5. To begin copy

~jsantore/OSLab2Starter.zip to your directory. Unzip it and you will get a lab2 folder in your home folder with the simulator in it.

Read http://webhost.bridgew.edu/jsantore/Fall2006/OpSys/user_guide.html  for instructions on using this simulator.

compile the entire simulation using the command
javac *.java
from your lab2 directory. There are no compile errors but one warning, you can ignore that warning for the duration of the project.

Look over the code, it is a stripped down operating system simulator with only the memory management system. There is also a very simple GUI componant designed to let you see the results of memory allocations. Run the simulator with the existing memory.conf and commands files. Take a look at the gui results.

Note also that this simulation assumes that the number of virtual pages is twice the number of physical pages.

Your assignment:

Part 1:

First edit the memory.conf so that you have 32 virtual pages of 4k each. Right now there are 64 virtual pages of 16K each. Notice that this means you will have to change the memory allocations in the file as well. You'll need to get rid of any reference to a page with a physical page number above 15. Notice that now the page buttons on the right hand column of buttons are useless since they refer to pages that don't exist. Don't push them, just ignore them. They spew lots of error messages if pushed but won't cause the program to crash.

Now costruct two motivating examples for your memory managment tests in the form of commands files. Make sure you have read the users guide section on commands files before attempting this. I will use my own commands files as well. Your tests should be designed to test your page replacement algorithms as well as possible. I'll give you some guidelines below.

Call the first commands file twoGroups. In this file we will simulate a program that is using one set of pages at the beginning, and another set of pages at the end. You will need to have 56 read and write commands in this file. For the first 25, you should read addresses from the first 3 virtual pages and both read and write to addresses on virtual pages 12, 14, 25, 29, and 30.  Make sure to chood different addresses for each memory reference. For the middle six instructions, read or write to virtual pages 13, 7, 20, 15, and a random address. For the last 25 commands, read from virtual pages 3, 4, and 5 and write to pages 16, 17, 19 and 20.

Call the second commands file continuous. This file will simulate traversing a large data structure. In this file you will need 50 commands. Every two to three commands should be a read command reading from pages 2, 3 and 5 (evenly distributed between the three) The remainder of the commands should be read and write commands to increasing memory addresses on pages 14-27. Make sure you have at least once memory reference for each of those pages.

Run your two files and see how things go with the existing first in first out page replacement algorithm. Notice that by default, the simulation writes the trace of the memory accesses to a file called tracefile.

Part 2:

In this part of the assigment, you will implement two of the page replacement algorithms that we've looked at in class. Page replacement is done in the replacePage method in the PageFault.java class. Since you will be doing two page replacement algoritms, first copy the replace page method and paste it below. Now comment it out. From emacs on eagle, simply select the entire region, and select the java menu and then the comment out region menu item. The entire region will have line comments at the beginning of the lines. To uncomment out regions, select the region and choose <java><uncomment region. This will remove the line comments from the beginning of each line in the selection. This way you can work on one page replacement function while keeping the other one commented. I'll compile with one and test it and then comment it out and uncomment the other. Make sure that you mark which function implements which algorithm.

Your two algorithms to implement are:

Not recently used: Implement this relatively straight-forward page replacement algorithm.

WSClock page replacement: Implement this much more realistic page replacement algorithm.

Part 3:

Develop a readme file with the following information:
  1. Your name
  2. A short set of instructions for running your program, especially if you changed how the simulation is run.
  3. A 2-3 paragraph analysis, comparing how the two page replacement algorithms fared. Did one perform better than the other? Or were there simply so few accesses (50ish access is way too low for a real program after all) that you didn't see any performance difference
  4. As always, if there is anything not quite finished, let me know in this part of the readme.


Zip up your entire lab2 folder as before

zip -r <your last name>Lab2.zip lab2
replacing <your last name> with your actual last name of course.

Then attach it to an email in pine and send it to me.