process. Whenever the processor needed to look up a translation, it
consulted the page table. As long as the process only accessed
memory that it didn't own, all was well. If the process accessed
process. Whenever the processor needed to look up a translation, it
consulted the page table. As long as the process only accessed
memory that it didn't own, all was well. If the process accessed
32 22 12 0
+--------------------------------------------------------------------+
| Page Directory Index | Page Table Index | Page Offset |
32 22 12 0
+--------------------------------------------------------------------+
| Page Directory Index | Page Table Index | Page Offset |
1|____________| | 1|____________| | |____________|
0|____________| \__\0|____________| \____\|____________|
/ /
1|____________| | 1|____________| | |____________|
0|____________| \__\0|____________| \____\|____________|
/ /
use your new page table management code to construct the page tables
only as page faults occur for them.
use your new page table management code to construct the page tables
only as page faults occur for them.
frames that you use for storing user virtual pages. Be sure to pass
the @code{PAL_USER} flag to this function when you do so, because that
allocates pages from a ``user pool'' separate from the ``kernel pool''
frames that you use for storing user virtual pages. Be sure to pass
the @code{PAL_USER} flag to this function when you do so, because that
allocates pages from a ``user pool'' separate from the ``kernel pool''
There are many possible ways to implement virtual memory. The above
is simply an outline of our suggested implementation.
There are many possible ways to implement virtual memory. The above
is simply an outline of our suggested implementation.
around the loop, @code{read_bytes} represents the number of bytes to
read from the executable file and @code{zero_bytes} represents the number
of bytes to initialize to zero following the bytes read. The two
around the loop, @code{read_bytes} represents the number of bytes to
read from the executable file and @code{zero_bytes} represents the number
of bytes to initialize to zero following the bytes read. The two
to be compatible with the prototypes for @code{hash_hash_func} and
@code{hash_less_func} in @file{lib/kernel/hash.h}.
to be compatible with the prototypes for @code{hash_hash_func} and
@code{hash_less_func} in @file{lib/kernel/hash.h}.
in a hash table. First, add a @code{hash_elem} to the thread
structure by adding a line to its definition:
in a hash table. First, add a @code{hash_elem} to the thread
structure by adding a line to its definition:
@{
struct thread *a = hash_entry (a_, struct thread, h_elem);
struct thread *b = hash_entry (b_, struct thread, h_elem);
@{
struct thread *a = hash_entry (a_, struct thread, h_elem);
struct thread *b = hash_entry (b_, struct thread, h_elem);
hash_init (&threads, thread_hash, thread_less, NULL);
@end example
hash_init (&threads, thread_hash, thread_less, NULL);
@end example
for @var{aux} and ignore the values passed to the hash function and
comparison functions. (You'll get a compiler warning if you don't use
the @var{aux} parameter, but you can turn that off with the
for @var{aux} and ignore the values passed to the hash function and
comparison functions. (You'll get a compiler warning if you don't use
the @var{aux} parameter, but you can turn that off with the
-@b{Why do I need to pass @code{PAL_USER} to @code{palloc_get_page()}
-when I allocate physical page frames?}
+@b{Why do I need to pass @code{PAL_USER} to @func{palloc_get_page}
+when I allocate physical page frames?}@anchor{Why PAL_USER?}
if you like, but it should be the underlying mechanism, directly or
indirectly, for two reasons. First, running out of pages in the user
pool just causes user programs to page, but running out of pages in
if you like, but it should be the underlying mechanism, directly or
indirectly, for two reasons. First, running out of pages in the user
pool just causes user programs to page, but running out of pages in