COS 318 : Operating system
Fall 2006, Princeton University

Project 5: Virtual Memory

Important Dates

Introductory Precept: Tue 11/21, 3:00-4:00pm; Wed 11/22, 3:00-4:00pm
Design Review: Mon 11/27, 6:00-9:00pm
Second Precept: Wed 11/29, 8:30-9:30pm
Project Due: Tue 12/05, 11:59pm

To signup for the design review, please use online signup here.

Previous projects have used memory as a flat layout; this project will require you to implement a simple virtual memory mechanism in your operating system. Processes will now execute in separate virtual address spaces that are protected from each other. No process may access or modify data in another process' address space. The kernel will also be protected from processes in a similar manner. Additionally we now make a distinction between regular instructions and 'protected' instructions (i.e. certain instructions are enabled only in certain privelege levels). The x86 architecture has four privelege levels that can be used to enforce different levels of responsibility in the system. We will use only two of these levels, the kernel and the kernel threads will run in kernel mode (privilege level 0) and the processes will run in user mode (privilege level 3).

Your task in this project is to implement a simple, demand-paged virtual memory system with the USB disk. In order to accomplish this, you will need to do the following :

You should use the code we sent to you "5_pre.tar.gz" as a starting point for your project. We have provided you with two main components to help you with the virtual memory implementation:

There are now 39 files. Don't be daunted by the large number of files since you are already familiar with many of them, and the only files that need to be changed are memory.c and memory.h.

Since our entire project will be using the USB disk, please do not read/modify the hard disk.


Detailed Requirements and Hints

Before starting this project, you should read carefully Chapters 2-4 of the Intel Architecture Software Developer's Manual, Volume 3: System Programming Guide to understand the address translation mechanism so that you can understand how to set up the page tables. As discussed in class, x86 architectures use a two-level table structure with a directory page that has 1024 entries pointing to the actual page tables. You need to understand this structure very well.

In this project, you can make several assumptions and constraints to simplify your design and implementation:

Extra Credits

There are one extra credit you can receive in this project.

You can receive 1/2 extra credit if you implement a FIFO replacement policy described in the class. You may receive another 1/2 extra credit point if you implement a FIFO with second chance replacement policy.


Design review

The best way to present your thoughts during the design review is to give us a brief summary of each of the functions in the templates that are missing and will be filled in by you. There is no need for actual C code here, just a few English sentences should suffice. (Please see the detailed grade split down in the next section.)

Before you come to meet the TA, you should prepare for a brief presentation on a piece of paper or on the screen.

Grading criteria

Design review: (one point for each item)


Final project:

Submitting Programming Assignments

Submit your final solution electronically using the following command:

/u/cos318/bin/318submit 5 README otherfiles ...

The submit command copies your files to the directory /u/cs318/submit/user/number and lists all the files that you have submitted for assignment number. user is your user account name. If you execute submit after the project deadline, your files are placed in directory number_late. You can run submit more than once, and you can submit partial lists of files. Note: You just need to submit the files that you have modified. (Eg: memory.h, memory.c, README.)


CS318 Staff