git fetch
the latest updates from the class repository. Then git checkout hw5 -b hw5_solution
to start working on your solution from the template provided.
Then, follow the below step-by-step guide to create a paging system for xv6.
sys_evict()
, which is meant to take an address as argument and evict the page that includes that address. sys_evict()
calls evict()
, which is an unfinished function.
Implement evict()
for addresses inside of mmap regions. The beauty of these regions is that they are file-backed. If you successfully evict a page, the standard page fault handling for mmap regions will read the page back into RAM when needed, making this part quite easy.
The program evict_mmap
should run to completion, and the number of free pages reported on exit should be larger than the number of free pages for lazy_mmap
, indicating that the pages were indeed freed up by evicting them.
swap space
in the xv6.img file, which is the first hard drive from xv6's perspective. The space comes directly after the boot sector (before the kernel), and is initialized to all zeros.
In this step, if evict() is called on a page that is not within an mmap region, write the contents of the page to the swap space. Use bread()
and bwrite()
to access raw disk sectors. Do not free the page in this step, start by verifying that writing to swap is working well. You can verify this by running hexdump
on the image file. The program evict_swap
evicts a page with recognizable contents, for this purpose.
For this to be useful in later steps, you need to also retain two things when you write to swap: (a) which virtual memory page (for this process) went where on disk? (b) which swap space pages are used, and which are available to accept page-outs (this is system-wide, not per-process)? For (a), consider using the just-cleared page table entry, just make sure to leave the "present" bit at 0.
evict_swap
checks that memory actually gets freed when you evict a non-mmap page. pagein_swap
tests that the paging functionality works correctly, by allocating memory, writing something familiar to it, evicting the page, then reading the page to make sure the contents are still there.
page_replacement
uses up all the available memory (this is artificially limited for hw5), and more. kalloc
has been modified to evict()
pages rather than return a null pointer when out of free pages.
If the steps above are working correctly, page_replacement
will run to completion. However, you will see a large count of page replacement printed out at process exit. Implement a better page replacement method.
When running with the template victim selection, I get
$ page_replacement Exiting process. System free pages is 1, replacement count is 34040running with my random eviction solution, I get a much more reasonable
$ page_replacement Exiting process. System free pages is 1, replacement count is 2807For full points, get below 3500 replacements. For the bonus, implement an LRU-approximating method based on the "accessed" bit in the PTE's (i.e. not random or otherwise hard-coded order), and get below 2807.
Copyright 2016 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu |
WISEST Helping Women Faculty Advance Funded by NSF | ![]() | ![]() |