Merge branch 'task2/thread-init-bug-fix' into 'master'

Fix Bug in fd_counter initialisation when USERPROG is not defined

See merge request lab2425_autumn/pintos_22!49
This commit is contained in:
2024-11-15 17:17:14 +00:00

View File

@@ -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 ();