Makefile: /blugreen/homes/plank/cs560/labs/lab8/Makefile
Lab 8 -- Demand Paging
Below we describe the JOS disk interface.
Your job is now to get demand paging to work in JOS.
When you are done, everything should work as in lab 7, however
you should be able to
load up to 8 megabytes of user processes at any one time, even though
there is only 1 megabyte of user memory in core.
Compiling Information
Same as lab 7.
Disk Operations
Now when JOS starts up, it will have an
eight megabyte disk. This disk consists of 512-byte sectors set in
512 tracks with 32 sectors per track. It has the following
interface:
- disk_write(int sector, char *data) -- this function writes
out a 512-byte block of memory to the disk at sector numbered sector.
Sector numbers are laid out logically. When the disk is finished with
the write, an interrupt of the type DiskInt occurs. Obviously,
data is a pointer to physical memory, not a virtual address.
It does not have to be a pointer to user memory, nor does it have to
be aligned on a page boundary.
- disk_read(int sector, char *data) -- this function reads
a 512-byte sector from the disk. It also causes an interrupt of type
DiskInt when done. (Thus you cannot read and write to the disk
at the same time.)
Virtual Memory / Demand Paging
Once again, if the valid field of a PTE is not set,
then JOS will
get control in exceptionHandler(), with the which
argument set to PageFaultException, and with the
faulting address in register BadVAddrReg
(see simulator.h). This now can
be for one of two reasons. Either the address is illegal, or the
page has been swapped to disk. It is your job to figure out which
this is (by keeping track of the sbrk() value *and* the size
of the stack), and deal with it appropriately.
Use the CLOCK (second chance)
algorithm from the book to approximate LRU for page replacement.
The dirty and use bits are set by the simulator whenever
a page is written or accessed respectively. You may clear these by
setting them to zero, and you may set them to keep things straight
as you modify process pages from JOS space.
Have fun.
(A final tip from Aunt Heloise's brother, Uncle Todd:
Remember, every time JOS touches user memory, the access can block.
Design
your synchronization strategy accordingly).