From 4fd6a30d164874fd660aacc36b44842e14bba208 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 21 Jun 2012 20:06:48 +0200 Subject: mark pages removed from page/mmap table as clear --- vm/mmap.c | 8 ++++++-- vm/page.c | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'vm') diff --git a/vm/mmap.c b/vm/mmap.c index 0dc9190..8620513 100644 --- a/vm/mmap.c +++ b/vm/mmap.c @@ -1,11 +1,11 @@ #include -#include "userprog/pagedir.h" -#include "userprog/process.h" #include "filesys/file.h" #include "threads/thread.h" #include "threads/vaddr.h" #include "threads/malloc.h" #include "threads/palloc.h" +#include "userprog/pagedir.h" +#include "userprog/process.h" #include "vm/mmap.h" #include "vm/page.h" @@ -128,8 +128,12 @@ mmap_table_remove (struct mmap_table *table, mapid_t mapid) process_unlock_filesys (); } + /* free page and page table entry */ if (pte != NULL) + { + pagedir_clear_page (thread->pagedir, pte->upage); free (pte); + } ofs += PGSIZE; } diff --git a/vm/page.c b/vm/page.c index b40382f..b98c553 100644 --- a/vm/page.c +++ b/vm/page.c @@ -1,10 +1,11 @@ #include #include "filesys/file.h" -#include "userprog/process.h" #include "threads/thread.h" #include "threads/vaddr.h" #include "threads/malloc.h" #include "threads/palloc.h" +#include "userprog/pagedir.h" +#include "userprog/process.h" #include "vm/page.h" static unsigned page_table_hash (const struct hash_elem *e, void *aux UNUSED); @@ -52,6 +53,7 @@ static void page_table_entry_free (struct hash_elem *e, void *aux UNUSED) { struct page_table_entry *pte = hash_entry (e, struct page_table_entry, elem); + pagedir_clear_page (thread_current ()->pagedir, pte->upage); free (pte); } @@ -97,7 +99,7 @@ page_table_fetch (struct hash *ht, void *upage) } /* remove an entry from the page table. returns the element or NULL if not found. - the caller is responsible for freeing the element! */ + the caller is responsible for freeing the element and the associated page! */ struct page_table_entry * page_table_remove (struct hash *ht, void *upage) { -- cgit v1.2.3