diff options
Diffstat (limited to 'userprog/process.c')
| -rw-r--r-- | userprog/process.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/userprog/process.c b/userprog/process.c index 80e327d..bf1a706 100644 --- a/userprog/process.c +++ b/userprog/process.c | |||
| @@ -129,6 +129,7 @@ start_process (void *aux) | |||
| 129 | process->parent_tid = aux_data->parent_thread->tid; | 129 | process->parent_tid = aux_data->parent_thread->tid; |
| 130 | thread->process = process; | 130 | thread->process = process; |
| 131 | 131 | ||
| 132 | /* initialize page and mmap table */ | ||
| 132 | page_table_init (&thread->page_table); | 133 | page_table_init (&thread->page_table); |
| 133 | if (!mmap_table_init (&process->mmap_table)) | 134 | if (!mmap_table_init (&process->mmap_table)) |
| 134 | goto signal; | 135 | goto signal; |
| @@ -151,10 +152,9 @@ start_process (void *aux) | |||
| 151 | /* If process startup failed, quit. */ | 152 | /* If process startup failed, quit. */ |
| 152 | if (thread->process == NULL) { | 153 | if (thread->process == NULL) { |
| 153 | if (process != NULL) { | 154 | if (process != NULL) { |
| 155 | /* close/free memory mapped files and page table */ | ||
| 154 | /* close/free memory mapped files */ | 156 | /* close/free memory mapped files */ |
| 155 | mmap_table_free (&process->mmap_table); | 157 | mmap_table_free (&process->mmap_table); |
| 156 | |||
| 157 | /* free page table */ | ||
| 158 | page_table_free (&thread->page_table); | 158 | page_table_free (&thread->page_table); |
| 159 | 159 | ||
| 160 | if (process->fd_table.fds != NULL) | 160 | if (process->fd_table.fds != NULL) |
| @@ -240,8 +240,9 @@ process_exit (void) | |||
| 240 | lock_release (&filesys_lock); | 240 | lock_release (&filesys_lock); |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | /* close/free memory mapped files */ | 243 | /* close/free memory mapped files and page table */ |
| 244 | mmap_table_free (&proc->mmap_table); | 244 | mmap_table_free (&proc->mmap_table); |
| 245 | page_table_free (&thread->page_table); | ||
| 245 | 246 | ||
| 246 | int fd; | 247 | int fd; |
| 247 | for (fd = 2; fd <= proc->fd_table.fd_max; fd++) { | 248 | for (fd = 2; fd <= proc->fd_table.fd_max; fd++) { |
| @@ -265,9 +266,6 @@ process_exit (void) | |||
| 265 | pagedir_destroy (pd); | 266 | pagedir_destroy (pd); |
| 266 | } | 267 | } |
| 267 | 268 | ||
| 268 | /* free page table */ | ||
| 269 | page_table_free (&thread->page_table); | ||
| 270 | |||
| 271 | /* Destroy the process structure if the parent is not alive | 269 | /* Destroy the process structure if the parent is not alive |
| 272 | * any more. Atomic test and set would be sufficient here. | 270 | * any more. Atomic test and set would be sufficient here. |
| 273 | */ | 271 | */ |
