X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=doc%2Fvm.texi;h=e6ff141067f58ce2b80cbb2f2a807a018267519d;hb=13753f29344700c01d9dc80834e51c7303ed18f7;hp=6e5d5a076b281bdb6dd72515e9b2c22b792fbf93;hpb=b0498d0f3428dfd14e7b679990f0a4a605a1287e;p=pintos-anon diff --git a/doc/vm.texi b/doc/vm.texi index 6e5d5a0..e6ff141 100644 --- a/doc/vm.texi +++ b/doc/vm.texi @@ -316,11 +316,12 @@ Some way of translating in software from virtual page frames to physical page frames. Pintos provides a hash table that you may find useful for this purpose (@pxref{Hash Table}). -It is possible to do this translation without adding a new data -structure, by modifying the code in @file{userprog/pagedir.c}. However, -if you do that you'll need to carefully study and understand section 3.7 -in @bibref{IA32-v3}, and in practice it is probably easier to add a new -data structure. +You don't strictly need a new data structure for this. You could +instead modify the code in @file{userprog/pagedir.c}. If you do that +you'll need to thoroughly understand how 80@var{x}86 page tables work +by, e.g.,@: studying section 3.7, ``Page Translation Using 32-Bit +Physical Addressing,'' in @bibref{IA32-v3a}. In practice, most groups +use a separate data structure. @item Some way of finding a page on disk (in a file or in swap) if it is not @@ -419,11 +420,10 @@ Bits}) to implement an approximation to LRU. Your algorithm should perform at least as well as the ``second chance'' or ``clock'' algorithm. -Your design should allow for parallelism. Multiple processes should -be able to process page faults at once. If one page fault require +Your design should allow for parallelism. If one page fault requires I/O, in the meantime processes that do not fault should continue -executing and other page faults that do not require I/O should be able to -complete. These criteria require some synchronization effort. +executing and other page faults that do not require I/O should be able +to complete. These criteria require some synchronization effort. @node Lazy Loading @subsection Lazy Loading @@ -440,25 +440,25 @@ be written to swap. The core of the program loader is the loop in @func{load_segment} in @file{userprog/process.c}. -Each time around the loop, @code{read_bytes} receives the number of -bytes to read from the executable file and @code{zero_bytes} receives +Each time around the loop, @code{page_read_bytes} receives the number of +bytes to read from the executable file and @code{page_zero_bytes} receives the number of bytes to initialize to zero following the bytes read. The two always sum to @code{PGSIZE} (4,096). The handling of a page depends on these variables' values: @itemize @bullet @item -If @code{read_bytes} equals @code{PGSIZE}, the page should be demand +If @code{page_read_bytes} equals @code{PGSIZE}, the page should be demand paged from disk on its first access. @item -If @code{zero_bytes} equals @code{PGSIZE}, the page does not need to +If @code{page_zero_bytes} equals @code{PGSIZE}, the page does not need to be read from disk at all because it is all zeroes. You should handle such pages by creating a new page consisting of all zeroes at the first page fault. @item -If neither @code{read_bytes} nor @code{zero_bytes} equals +If neither @code{page_read_bytes} nor @code{page_zero_bytes} equals @code{PGSIZE}, then part of the page is to be read from disk and the remainder zeroed. This is a special case. You are allowed to handle it by reading the partial page from disk at executable load time and @@ -669,7 +669,7 @@ kernel functions need to obtain memory. You can layer some other allocator on top of @func{palloc_get_page} if you like, but it should be the underlying mechanism. -Also, you can use the @option{-u} option to @command{pintos} to limit +Also, you can use the @option{-ul} option to @command{pintos} to limit the size of the user pool, which makes it easy to test your VM implementation with various user memory sizes. @@ -712,7 +712,7 @@ with the file mapped into your address space, you can directly address it like so: @example -write (addr, 64, STDOUT_FILENO); +write (STDOUT_FILENO, addr, 64); @end example Similarly, if you wanted to replace the first byte of the file,