CSc 335

Project 4 -- Virtual Reality
Due Wednesday, June 3, 2009


Your Mission

So now you've got a paging system that allows multiprogramming. The catch is that every running process must still fit in memory in its entirety. In this last project, you'll remove that limitation by implementing demand paging and virtual memory. You should also consult Lab 6 in the Nachos Project Guide which serves as the inspiration to this project. There are details explained there about Nachos that can help.

Part 1: Pages on demand

Alter your code to implement demand paging. Thus, when a process is first loaded into memory, all of its page table entries should be set as invalid. When the CPU attempts to access a page that is not in memory, a page fault will occur. You will then service the page fault by allocating a free frame, loading the appropriate page into the frame, setting the corresponding page table entry to valid, and then restarting the instruction. Here are some hints and details to help you on your way.

Debug your code until it works. Be sure to test your own homemade user programs from Project 3 to make sure your demand paging works.

Part 2: The Big Swap Out

Now, implement virtual memory by allowing page faults to be serviced even if there are no free frames available. You will need to:

EXTRA CREDIT ALERT: Part 3: PRA comparison

Attempt this if and only if you have the rest of the project working. For 5 more extra credit points, create two page replacement algorithms (PRAs) and compare their performances. If you create each algorithm in a separate file, you should be able to switch between them easily through modification of Makefile.common. You will need to create interesting test programs that stress the two algorithms and then measure their relative performance. Hint: What do those statistics say when Nachos terminates at the end of an execution?

Write a report that explains what you did, what experiments you ran, what you were trying to test, what you measured, and what your conclusions are. Under what circumstances does one algorithm fare better than the other?


The Nachos Project Guide is your friend. Consult it for more details about Nachos in relation to this project.


This project is worth 50 points:

There is a maximum of 10 points of extra credit to be gained in this project.

What to turn in

Turn in a paper copy of your output showing your frames being allocated on demand (as before, use DEBUG stmts). For virtual memory, your output should clearly indicate when a page fault occurs, when and what victim frame is chosen, and when the swap out/swap in occurs. Again, use DEBUG stmts. Occasionally printing out the page table may also be a good way of showing what's going on.

Label your tests well and include explanations so I can tell what is happening. Also, turn in paper copies of source code for all code you have written for this project.

Electronically, please submit your entire nachos directory (the code directory) using our submission script;

/home/csc335pub/submit csc335 <full path to your code directory>

Having trouble? Don't wait until the last minute! Come see me and get your $80 worth.

Administrative statement

Programming assignments, like homework assignments, are individual projects. I encourage you to talk to others about the general nature of the project and ideas about how to pursue it. However, the technical work, the writing, and the inspiration behind these must be substantially your own. If any person besides you contributes in any way to the project, you must credit their work on your homework. Similarly, if you include information that you have gleaned from other published sources, you must cite them as references. Looking at, and/or copying, other people's programs or written work is inappropriate, and will be considered cheating.
Return to Project Index