Lab 9: Memory Management using Paging |
In today's lab, we will simulate a memory management mechanism
called paging.
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:
- Logical address space size - (Could be a different value but, no need to change for this
lab)
- Physical address space size - (Could be a different value but, no need to change for this
lab)
- Page size - (Change this and try with different page sizes)
- List of logical addresses - (Try randomly generating your own)
- Compile the given code:
gcc VM_addr_map.c -o VM_addr_map -lm
- Run the program on the given input files:
./VM_addr_map
< inp1.txt
- 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
- 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
- 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.
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.
- Submission -75%
- In-class Quiz - 10%
- Demo - 15%
< Back to the Lab Home Page