Homework 5: page table magic - deduplication and copy-on-write

In this homework, we implement two advanced virtual memory features in xv6. First, we introduce a deduplication system, wherein the kernel scans the system for duplicated pages and frees up memory by reusing identical physical memory page frames in several virtual memory locations.

This, however, introduces a major problem should a process try to write to one of these shared pages. Thus, the second part of our homework is to handle this problem using a copy-on-write approach: write-protect the shared pages, and make a new writable copy for any process that needs it.

A hw5 template will be provided on Tuesday Sept 26.


The program dedup_reader allocates a lot of memory and fills it with lots of identical content. This uses up a lot of physical RAM. It then calls the new system call sys_dedup(), which identifies duplicate pages, and frees up most of the memory through virtual memory deduplication. The program then reads from the memory to make sure it still works as expected.


The program dedup_writer is identical to dedup_reader, except it then writes to some parts of the memory, and checks that everything looks peachy, including another call to sys_dedup(). It then writes to all of the memory again, and calls sys_dedup().

tip: Make sure that pages are freed as soon as they are no longer needed. To do this, you need to keep track of how many page table entries are pointing at each physical memory page (a reference count).


The programs must both run without crashing or reporting errors. The system memory consumption must be minimized - any time a page is no longer used, add it to the free list with kfree(). Specific numbers may be provided by the instructors when available. Finally, no kernel memory leaks: total system free pages should not change after running one of the programs.


Turn-in is the usual story. Push your hw5 branch to your turn-in repository.

Edit | Attach | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2016-09-27 - 04:12:09 - Main.jakob
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
Helping Women Faculty Advance
Funded by NSF