From 8f82f9d7470ddae4ad6809bcd348bdbccd7fa8be Mon Sep 17 00:00:00 2001 From: sBubshait Date: Fri, 15 Nov 2024 16:57:16 +0000 Subject: [PATCH] Fix Bug in fd_counter initialisation when USERPROG is not defined --- src/threads/thread.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/threads/thread.c b/src/threads/thread.c index b7c6c42..e80f1e5 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -254,7 +254,10 @@ thread_create (const char *name, int priority, tid = t->tid = allocate_tid (); init_process_result (t); - #ifdef USERPROG +#ifdef USERPROG + /* Initialize the thread's file descriptor table. */ + t->fd_counter = MINIMUM_USER_FD; + if (!hash_init (&t->open_files, fd_hash, fd_less, NULL) || !hash_init (&t->child_results, process_result_hash, process_result_less, t)) @@ -704,7 +707,6 @@ init_thread (struct thread *t, const char *name, int nice, int priority, t->recent_cpu = recent_cpu; t->priority = t->base_priority; - t->fd_counter = MINIMUM_USER_FD; t->exit_status = -1; old_level = intr_disable ();