Clarifications.
[pintos-anon] / doc / vm.texi
index 260f9d99c751fce1a3c211e04cbd9119be7f202a..599539be86b905cfa54a071a34122cd69097e86a 100644 (file)
@@ -35,6 +35,9 @@ All the test programs from the previous project should also work with
 this project.  You should also write programs to test the new features
 introduced in this project.
 
+You will continue to handle Pintos disks and file systems the same way
+you did in the previous assignment (@pxref{Using the File System}).
+
 Your submission should define @code{THREAD_JOIN_IMPLEMENTED} in
 @file{constants.h} (@pxref{Conditional Compilation}).
 
@@ -208,7 +211,8 @@ referenced.  Another consideration is that if the replaced page has
 been modified, the page must be first saved to disk before the needed
 page can be brought in.  Many virtual memory systems avoid this extra
 overhead by writing modified pages to disk in advance, so that later
-page faults can be completed more quickly.
+page faults can be completed more quickly (but you do not have to
+implement this optimization).
 
 @node Memory Mapped Files
 @section Memory Mapped Files
@@ -249,17 +253,47 @@ system should allocate additional pages for the stack as necessary
 segment).
 
 It is impossible to predict how large the stack will grow at compile
-time, so we must allocate pages as necessary.  You should only
-allocate additional pages if they ``appear'' to be stack accesses.
-You must devise a heuristic that attempts to distinguish stack
-accesses from other accesses.  Document and explain the heuristic in
-your design documentation.
+time, so we must allocate pages as necessary.  You should only allocate
+additional pages if they ``appear'' to be stack accesses.  You must
+devise a heuristic that attempts to distinguish stack accesses from
+other accesses.@footnote{You might find it useful to know that the
+80@var{x}86 instruction @code{pusha} pushes all 8 registers (32 bytes)
+on the stack at once.}  Document and explain the heuristic in your
+design documentation.
 
 The first stack page need not be loaded lazily.  You can initialize it
 with the command line at load time, with no need to wait for it to be
 faulted in.  Even if you did wait, the very first instruction in the
 user program is likely to be one that faults in the page.
 
+Stack facts:
+
+@itemize
+@item
+The user program's current stack pointer is in the @struct{intr_frame}'s
+@code{esp} member.
+
+@item
+Only buggy user programs write to memory within the stack but below the
+stack pointer.  This is because more advanced OSes may interrupt a
+process at any time to deliver a ``signal'' and this uses the stack.
+
+@item
+The 80@var{x}86 @code{push} instruction may cause a page fault 4 bytes
+below the stack pointer, because it checks access permissions before it
+adjusts the stack pointer.  (Otherwise, the instruction would not be
+restartable in a straightforward fashion.)
+
+@item
+Similarly, the 80@var{x}86 @code{pusha} instruction, which pushes all 32
+bytes of the 8 general-purpose registers at once, may cause a page fault
+32 bytes below the stack pointer.
+
+@item
+Most OSes impose some sort of limit on the stack size.  Sometimes it is
+user-adjustable.
+@end itemize
+
 @node Problem 3-1 Page Table Management
 @section Problem 3-1: Page Table Management
 
@@ -345,7 +379,11 @@ is simply an outline of our suggested implementation.
 
 Implement paging to and from files and the swap disk.  You may use the
 disk on interface @code{hd1:1} as the swap disk, using the disk
-interface prototyped in @code{devices/disk.h}.
+interface prototyped in @code{devices/disk.h}.  From the @file{vm/build}
+directory, use the command @code{pintos make-disk swap.dsk @var{n}} to
+create an @var{n} MB swap disk named @file{swap.dsk}.  Afterward,
+@file{swap.dsk} will automatically be attached when you run
+@command{pintos}.
 
 You will need routines to move a page from memory to disk and from
 disk to memory, where ``disk'' is either a file or the swap disk.  If