From 806d6bc19ea54535430b532beffdaa8776175f40 Mon Sep 17 00:00:00 2001 From: sBubshait Date: Wed, 4 Dec 2024 21:59:38 +0000 Subject: [PATCH] Refactor: Move destroying mmap data into process_exit instead of thread --- src/threads/thread.c | 4 ---- src/userprog/process.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/threads/thread.c b/src/threads/thread.c index e95a40a..ceb53df 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -401,10 +401,6 @@ thread_exit (void) process_exit (); #endif -#ifdef VM - mmap_destroy (); -#endif - /* Remove thread from all threads list, set our status to dying, and schedule another process. That process will destroy us when it calls thread_schedule_tail(). */ diff --git a/src/userprog/process.c b/src/userprog/process.c index 8d649e9..4e61fe6 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -25,6 +25,7 @@ #include "threads/synch.h" #include "devices/timer.h" #include "vm/page.h" +#include "vm/mmap.h" #ifdef VM #include "vm/frame.h" #endif @@ -363,6 +364,9 @@ process_exit (void) struct thread *cur = thread_current (); uint32_t *pd; + /* Unmap all memory mapped files */ + mmap_destroy (); + /* Clean up all open files */ hash_destroy (&cur->open_files, fd_cleanup); hash_destroy (&cur->pages, page_cleanup);