Lab 9: Memory Management using Paging

In today's lab, we will simulate a memory management mechanism called paging. 

Lab Materials
Assignment

Your task for today's lab is to implement a page table. The page table should be able to hold references of the frame numbers for the page numbers. You will be given the following as an input file:
  1. Compile the given code:

     gcc VM_addr_map.c -o VM_addr_map -lm

  2. Run the program on the given input files:

     ./VM_addr_map < inp1.txt

  3. It doesn't do much yet. The input and output are given below:

     Input:
      Logical address space size: 2^32
      Physical address space size: 2^32
      Page size: 2^31
      0xd6334873
      0x74b0dc51
      0xa9495cff
      0x2ae8944a


     Output without page table and address translation:
      Logical address: 0xd6334873
      Logical address: 0x74b0dc51
      Logical address: 0xa9495cff
      Logical address: 0x2ae8944a

  4. Your task is to implement the page table and address translation in the VM_addr_map.c file, so that we can get the following output for the given inp1.txt file:

    Output with page table and address translation:
      Number of Pages: 2, Number of Frames: 2

      Logical address: 0xd6334873
      Page Number: 1
      Page Fault!
      Frame number: 0
      Physical address: 0x56334873

      Logical address: 0x74b0dc51
      Page Number: 0
      Page Fault!
      Frame number: 1
      Physical address: 0xf4b0dc51

      Logical address: 0xa9495cff
      Page Number: 1
      Frame number: 0
      Physical address: 0x29495cff

      Logical address: 0x2ae8944a
      Page Number: 0
      Frame number: 1
      Physical address: 0xaae8944a

  5. Observe that some of the mapping outputs are printing Page Fault. Page fault occurs if a page (from logical address space) is not currently mapped to a frame (from physical address space). You can check for this error based on the page table and print out Page Fault when appropriate. Then you can look for the first available frame (sequentially from the beginning of mem_map table) in the physical address space and map that to that specific page using the page table.

Assignment

Once you are done with the code, please check your output on the given input text files. Before submission, please ensure that your code is working on the cycle servers. Finally, you can submit just the source code through Canvas.

Evaluation

< Back to the Lab Home Page