Emulator Assignment part 2
(by now you really should have labels working properly in your assembler)
Add Virtual Memory
- Remember to distinguish between the Page Table and the Hardware Address
Translator. The page table is a software construct, maintained by the operating system, and can
be any size you like. Every page in a process' address space appears in its page table.
The Hardware Address Translator only contains a very small subset of the page table,
and should be the only table accessed directly by the translate function
when your emulator accesses memory.
- Your emulator emulates not only the hardware of the computer, but also its
operating system. Whenever memory is accessed, the translation from virtual
address to physical address is performed by the Hardware Address Translator
part of your emulation. If it fails, the result is a Page Fault, and your program
(as part of its operating system emulation) should search for the correct entry
in the complete Page Table, adding it to the Hardware Address Translator
when found.
- Make it possible for the user to specify both the number of entries in
the Hardware Address Translator, and the Page Replacement Strategy
used when a page fault occurs and an entry in the hardware unit has to be replaced
with a different entry from the page table. Implement at least FIFO and LRU.
- The Purpose of this Assignment is to investigate how
changes to these parameters (number of entries and replacement strategy)
affect the running of programs. Make your emulator report the number
of page faults after each run. Design a few simple programs that cause
page faults while running, and see how the number changes with the parameters.
Report your observations.
- For this assignment, some Page Faults are errors. If a running program
attempts to access a virtual page that does not appear in its page table, it
would be best to treat that as a serious error and stop the program, don't
automatically allocate a new page. During the assembly process, things are different.
When the assembler writes the binary-coded form of an instruction to memory,
if the virtual page does not exist yet, it should be treated as a request for
allocation. Otherwise you'll never get any programs in there.