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
- Inputs: M (number of pages), S,
a real value between 0 and 5 indicating how well-behaved the
program is (0 is Very well behaved, 5 is very poor)
and filename to write the output references.
- Output:Address references
written into the filename.
Algorithm
- Generate a random number C less
than M
- Generate a second random number L between 512 and
4096
- Generate 0.9 * L (round to the nearest integer)
random numbers according to a Normal Distribution with
mean C and standard deviation S
- Update C by generating it again as a random number
less than M
- Generate 0.1 * L (round to the nearest integer)
random numbers according to a uniform distribution between 0
and C.
- Repeat steps 2 - 5, M times.
- Write all the random numbers into the output
file filename
You are free to reorder the steps to make your program
efficient.
MEMORY MANAGER
- Inputs:Filename containing address
references, F the number of frames in physical
memory and outfile an output file name to store
logical and physical address pairs as also information about
page faults.
- Output:Triplets of (logical address, physical
address, pagefault) written into outfile.
Algorithm
- Read the address reference from filename
- Calculate page number P and offset X
- If P is in memory, write the triplet (logical,
physical, 0) into outfile
- If P is not in memory, find a free frame E
in memory.
- If E is found, then update the memory, calculate
physical address; write the triplet (logical, physical, 1) to
output file outfile
- If E is not found, output error "Memory Full!" and
STOP.
- 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?