Lab VI: Memory Management

In this lab, you will be simulating a process execution by generating a large string of address references. These are written out to a file.

You will write a second process that simulates memory management. It reads the file and, if the needed page is in memory, calculates the physical address and writes the logical and physical addresses back into the file. If the page is not present in memory, it will load and then mark the address as a page fault.

You will write a third program which reads the updated file containing information on physical and logical addresses, and page faults and generates certain statistics.


Details

PROCESS SIMULATION

Algorithm

  1. Generate a random number C less than M
  2. Generate a second random number L between 512 and 4096
  3. Generate 0.9 * L (round to the nearest integer) random numbers according to a Normal Distribution with mean C and standard deviation S
  4. Update C by generating it again as a random number less than M
  5. Generate 0.1 * L (round to the nearest integer) random numbers according to a uniform distribution between 0 and C.
  6. Repeat steps 2 - 5, M times.
  7. Write all the random numbers into the output file filename

You are free to reorder the steps to make your program efficient.

MEMORY MANAGER

Algorithm

  1. Read the address reference from filename
  2. Calculate page number P and offset X
  3. If P is in memory, write the triplet (logical, physical, 0) into outfile
  4. If P is not in memory, find a free frame E in memory.
  5. If E is found, then update the memory, calculate physical address; write the triplet (logical, physical, 1) to output file outfile
  6. If E is not found, output error "Memory Full!" and STOP.
  7. Repeat the above steps until all address references are read.

Write a program to read the outfile written by the memory manager program. It should output the page fault ratio as

No. of Page Faults/Total No. of Address References

If the page fault requires 100 times the amount of time required for an in-memory access, by how much time did the process slow-down due to page faults?