Lab IV: Virtual Memory Management


This lab contains two problems related to pure demand paging. Please finish both the problems in the Lab itself: they are not that hard.

The following files simulate processes. The first line in each file contains the number of pages in the process. The remaining lines contain one number per line where each number is a logical memory address reference.

  1. Process 00
  2. Process 01
  3. Process 02
  4. Process 03
  5. Process 04
  6. Process 05

Question 1

Pick any process of your choice from the above. Assume a page size of 4096 bytes. The main memory is 16 KB. Use pure demand paging. In other words, when the process starts running, the physical main memory is empty (completely free). Read one line at a time from the process file and translate the logical address into its physical address. Write them into an output file where each line in the file contains

logical address, physical address, <page fault>
<page fault> is 0 if there is no page fault for that logical address reference and 1 if there is a page fault. When a page fault occurs, call a page replacement algorithm. For this lab, implement only FIFO replacement, i.e. replace the first page brought into the memory.

Write an output on the screen every 1000 lines of the process showing the pages of the process in the main memory and the number of page faults until that time (from the beginning of the process).

Model the main memory as an array of frames and each frame entry contains the page number and the process ID. In our case, the PID is 0 because there is only one process.

Increase the main memory size to 20 KB. Repeat the experiment with the same process and make a note of page faults after each 1000 lines of the process. Compare the numbers of page faults with those you observed earlier. Are there any instances where the number of page faults is more when the memory size is 20 KB?

Submit your outputs, source code and the names of the process data files that you used. Choose file names appropriately.


Question 2

In this question, select one more process from the files above. Repeat the above question but now assume that each process is given two frames in memory. Use a local FIFO page replacement algorithm. Assume that each process can run for 1024 lines before control is given to the other process. Write output to screen every time execution shifts from one process to another showing the pages in main memory, number of page faults for each process and list the currently active process. Assume the process PIDs are 0 and 1.


T H E     E N D