Implement page fault for lazy loading executables, w/ G
This commit is contained in:
@@ -119,7 +119,7 @@ process_execute (const char *cmd)
|
||||
|
||||
static void *get_usr_kpage (enum palloc_flags flags, void *upage);
|
||||
static void free_usr_kpage (void *kpage);
|
||||
static bool install_page (void *upage, void *kpage, bool writable);
|
||||
bool install_page (void *upage, void *kpage, bool writable);
|
||||
|
||||
static bool process_init_stack (char *cmd_saveptr, void **esp, char *file_name);
|
||||
static void *push_to_stack (void **esp, void *data, size_t data_size);
|
||||
@@ -707,11 +707,12 @@ load_segment (struct file *file, off_t ofs, uint8_t *upage,
|
||||
size_t page_zero_bytes = PGSIZE - page_read_bytes;
|
||||
|
||||
/* Add the page to the SPT */
|
||||
if (page_insert (file, ofs, upage, read_bytes, zero_bytes, writable,
|
||||
PAGE_EXECUTABLE) == NULL)
|
||||
if (page_insert (file, ofs, upage, page_read_bytes, page_zero_bytes,
|
||||
writable, PAGE_EXECUTABLE) == NULL)
|
||||
return false;
|
||||
|
||||
/* Advance. */
|
||||
ofs += page_read_bytes;
|
||||
read_bytes -= page_read_bytes;
|
||||
zero_bytes -= page_zero_bytes;
|
||||
upage += PGSIZE;
|
||||
@@ -782,7 +783,7 @@ free_usr_kpage (void *kpage)
|
||||
with palloc_get_page().
|
||||
Returns true on success, false if UPAGE is already mapped or
|
||||
if memory allocation fails. */
|
||||
static bool
|
||||
bool
|
||||
install_page (void *upage, void *kpage, bool writable)
|
||||
{
|
||||
struct thread *t = thread_current ();
|
||||
|
||||
Reference in New Issue
Block a user