2.3 vm
This exercise is optional.
Refer to the exercise policy for details.
Implement a simulation of a virtual memory system. Your simulation
should have a fixed amount of physical memory and disk swap
space. Your simulation should receive a stream of memory requests of
the form:
alloc PID SIZE to allocate SIZE bytes for the process PID. This should return a virtual address.
use PID VADDR to use a virtual address.
free PID VADDR to free memory, assuming VADDR is the addressed returned by an alloc request.
As your simulation runs, it should maintain a page tables and mappings
from virtual to physical addresses. Given that the simulation doesn’t
actually include read or write operations, you
only need to store these tables. You don’t need to actually keep track
of any data, so you can run with much larger memories than your
computer actually supports. Make sure you account for the space to
store your metadata and page tables inside the simulated memory!
When the simulation is over, it should output statistics such as peak
memory utilization, the efficiency of the paging system, and so on.
Consider implementing a second variant that looks at an entire set of
request upfront and computes the optimal allocation and page
replacement policy.