This assignment makes use of files contained in this zip file. This assignment is due Friday, May 1.
For this assignment you are to write a program that performs virtual memory operations. You will run the program along with a virtual memory mapping program so that you can watch the virtual memory operations take place.
Complete the program that is outlined in the file VMdriver.c
from the zip file. Create a text file, called VMcmds.txt
, with commands to exercise your virtual memory operations. The form of the command file is described in the comments of VMdriver.c
. A simple version of VMcmds.txt
is contained in the zip file. Your command file should demonstrate all of the commands described in the comments of VMdriver.c
. Be sure to create a command file that really tests your version of VMdriver.c
. Run your program in a console window using a command of the form
C:\VMdriver.exe < VMcmds.txt
Notice that VMdriver.exe
should read memory commands from stdin
. Your VMdriver.exe
program should create a process from the program VMmapper.exe
. The VMmapper.exe
process will display a memory map of the VMdriver.exe
process as it is running so that you can see the virtual memory operations take place in the VMdriver.exe
virtual address space. The source code file, VMmapper.c
, is included in the zip file, but you do not (and should not) need to make any changes to it.
In the zip file there is a demo version, VMdriver-demo.exe
, that you can run to see how your program should work. You can run the demo version in interactive mode by just double-clicking on VMdriver-demo.exe
. You should experiment with the demo program because it allows you to test a lot of ideas about virtual memory. The demo program will launch the VMmapper.exe
program, so you can see your memory operations take place. When practicing memory operations, it's a good idea to find a big "empty" region of the virtual memory space to work within. If you scroll up and down the console window for VMmapper.exe
, you should see a "free" region of memory labeled as ****FREE**** (in red text). This is a free region of memory that is at least 1GB in size. The VMdriver-demo.exe
program is not a large program, so it uses only a tiny fraction of its virtual memory space. Since VMdriver-demo.exe
is a 32-bit program, it has a 4 GB virtual address space, but half of this is given to the OS, so VMdriver-demo.exe
has 2 GB of user virtual address space. Most of this is "empty" and Windows makes most of the empty space contiguous in one big free block of virtual memory. The red ****FREE**** label denotes this huge free block. (NOTE: If you run the demo program several times, you will notice that the exact location of this huge empty region changes. This is due to a security feature called Address Space Layout Randomization (ASLR).)
In the zip file there is also a copy of the vmmap.exe
program from Microsoft. This is a much more sophisticated memory mapping program than VMmapper.exe
. When you run the demo program (or your own version of VMdriver.exe
) you can simultaneously run vmmap.exe
and get two views of the same virtual memory space. After you run VMdriver-demo.exe
(or your VMdriver.exe
), double click on vmmap.exe
and choose the VMdriver-demo.exe
process (or your VMdriver.exe
process) from the pop-up list. Compare the output from vmmap.exe
and VMmapper.exe
. For the most part they are the same, but vmmap.exe
contains quite a bit more detail than VMmapper.exe
. Also, you might notice that some regions denoted as "free" by VMmapper.exe
are denoted as "Unusable" by vmmap.exe
. Needless to say, vmmap.exe
is right, and these regions are not really free (there is a bit of an explanation for this discrepancy in this article).
When you are done with your version of VMdriver.c
, here are some questions that you should think about. To answer these questions, you need to use your version of VMdriver.exe
(or the demo version), the VMmapper.exe
program, and you may need to use other programs that let you observe virtual memory (like TaskManager or one of the demo programs we used in class).
Here are a couple of comments about the VMmapper
program. When VMmapper
detects a runtime error, it prints an error message to the console window and it also pops up a MessageBox. Sometimes these MessageBoxes are useful and sometimes they are annoying. If you find the popup MessageBoxes too annoying, you can comment out line 382 of VMmapper.c
and then recompile the program.
Don't resize the console window that VMmapper
runs in. Before Windows 10, console windows were not re-sizable. The VMmapper
program does not respond well to its console window being resized. If you get repeated error messages from the VMmapper
program, please let me know (and if you can figure out how to fix this bug in VMmapper
, please do so and let me know how).
Turn in a zip file called CS302Hw4Surname.zip
(where Surname
is your last name) containing your version of VMdriver.c
and your command file VMcmds.txt
.
This assignment is due Friday, May 1.
Here are links to some Windows API documentation that you might need to use in this assignment.