OpSys Fall 2005 - HW4

HW4 - Virtual Memory Simulator

Due Date: Nov 3rd by 11:59PM

Submit to WebCT drop box labeled HW4

Late Policy

- VM Simulator

The objectives of this assignment are:

  1. Understanding of the basic operations involved with a virtual memory system.
  2. Understand how various page replacement algorithms work.
  3. Analysis of page replacement algorithms.

You are to write a simulator for a virtual memory system. The simulator will support a number of different page-replacement algorithms (listed below) and will be able to report some statistics after each run. A run will be defined by a sequence of lines of text which your simulator will read from STDIN - each line in the input file corresponds to either a memory access by a process, or the beginning or end of a (simulated) process.

Simulation Input

The input contains a series of lines, each line conforms to one of the patterns shown below. You can easily generate and store sample input sequences in a file, then run your simulator with input redirected to this file. Note that as part of the testing of your program we will generate some input files that are not available to you during development (although we will provide some sample input files). The format of the input files is simple enough that you should consider writing a program that can generate a file according to some model of a pattern of virtual memory accesses by some number of processes.

OperationSyntaxDescription
Start process S pid Corresponds to the creation of a new process. The pid is a number that is used to refer to this specific processs.
Terminate process T pid Corresponds to the termination of an existing process. The pid indicates which process is to be completely removed from memory (this simulates a process exit).
Memory Read R pid address Corresponds to a memory read operation by the process corresponding to the given pid. The address specified (in decimal) is a byte address, so you will need to convert this to a page address (as far as your simulation is concerned, there is no difference between accesses as long as they are on the same virtual page).
Memory Write W pid address Corresponds to a memory write operation by the process corresponding to the given pid. The address specified (in decimal) is a byte address, so you will need to convert this to a page address (as far as your simulation is concerned, there is no difference between writes as long as they are on the same virtual page).

Simulator Command Line

Your simulator must support the command line options described below (using the syntax described below). You probably should use getopt to process the command line, there is a sample program that uses getopt available: getoptexample

./vmsim [-v] [-p pagesize] [-n numpages] [-a algorithm] [-t timestep]

Command line example: The following command line would run the simulator with the page size set to 32 bytes, a total of 8 pages of physical memory, simulating a clock interrupt every 100 lines of input, using the clock page-replacement algorithm and reading simulation commands from the file "sim1":

./hw4  -n 8 -t 100 -a clock < sim1

Below is a small sample of the kind of input that will be feed to your simulator, note a few complete (and larger ) files will be available soon...

S 0
S 1
S 3
R 1 29
R 0 20
R 3 38
R 1 26
R 0 38
R 0 49
R 0 45
R 3 1
R 3 35
S 2
R 2 16
R 1 14
W 2 37
R 1 32
R 3 16
R 3 13
R 0 0
R 0 11
R 2 8
R 0 2
R 1 4
R 1 55
R 1 41
W 0 24
R 0 30
R 2 2
T 2
R 1 3
R 3 5
R 1 18
R 1 7
R 3 41
R 3 38
S 2
R 2 15
R 2 10
R 2 39
R 1 33
R 1 41
W 1 5
R 3 55
R 1 42
R 1 9
R 2 50
R 2 7
R 1 31
R 2 7
R 2 21

Simulator Output

Your simulator should always generate the following output:

- Project Requirements

The following are the requirements for the project:

Grading: Your code will be graded according to the formula below. Note that to get full credit we must be able to understand your code (it must be commented!)

30% Basic simulator functionality (processes command line properly and reads, processes input lines correctly, etc).
60% Page replacement algorithm implementations (20% each).
10%Code quality (comments, organization, how hard is it to understand ?).

You can get partial credit for any part.

If you code does not compile and run under FreeBSD, you will lose at least 1/2 the relevant points ( partial credit will be awarded based on visual inspection of the code).

- How to Submit

Log in to WebCT at webct.rpi.edu using your RCS id and password. Once you get to MyWebCT click on "Operating Systems", and from there go to the homework drop boxes. Submit your files (individually, zipped or tarred) to the drop box labeled HW4.

-Resources