Fix Bug in thread initialisation: only init hash if USERPROG is defined

This commit is contained in:
sBubshait
2024-11-08 19:10:42 +00:00
parent e40794e672
commit 115c650c55

View File

@@ -238,7 +238,10 @@ thread_create (const char *name, int priority,
struct thread *parent_thread = thread_current (); struct thread *parent_thread = thread_current ();
init_thread (t, name, parent_thread->nice, priority, parent_thread->recent_cpu); init_thread (t, name, parent_thread->nice, priority, parent_thread->recent_cpu);
tid = t->tid = allocate_tid (); tid = t->tid = allocate_tid ();
#ifdef USERPROG
hash_init (&t->open_files, fd_hash, fd_less, NULL); hash_init (&t->open_files, fd_hash, fd_less, NULL);
#endif
/* Prepare thread for first run by initializing its stack. /* Prepare thread for first run by initializing its stack.
Do this atomically so intermediate values for the 'stack' Do this atomically so intermediate values for the 'stack'