From 6e838aa06a86d72a6788dca165119abddaeeb40f Mon Sep 17 00:00:00 2001 From: sBubshait Date: Wed, 4 Dec 2024 15:24:11 +0000 Subject: [PATCH] Fix Bug in thread.c: Only initialise and destroy mmap files table if VM is defined --- src/threads/thread.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/threads/thread.c b/src/threads/thread.c index 0073037..214a458 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -15,11 +15,13 @@ #include "threads/switch.h" #include "threads/synch.h" #include "threads/vaddr.h" -#include "vm/page.h" -#include "vm/mmap.h" #ifdef USERPROG #include "userprog/process.h" #include "userprog/syscall.h" +#include "vm/page.h" +#endif +#ifdef VM +#include "vm/mmap.h" #endif /* Random value for struct thread's `magic' member. @@ -275,7 +277,9 @@ thread_create (const char *name, int priority, } #endif +#ifdef VM mmap_init (); +#endif /* Prepare thread for first run by initializing its stack. Do this atomically so intermediate values for the 'stack' @@ -397,7 +401,9 @@ 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