From 18f1ad2798f7e7f93f61d42e24f72cfe8f195d4a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 13 Sep 2004 02:13:52 +0000 Subject: [PATCH] Don't palloc_free() the initial thread, because it's not allocated from a palloc pool. --- src/threads/thread.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/threads/thread.c b/src/threads/thread.c index ea3562f..1b56f98 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -25,6 +25,10 @@ static struct list ready_list; static struct thread *idle_thread; /* Thread. */ static void idle (void *aux UNUSED); /* Thread function. */ +/* Initial thread. + This is the thread running main(). */ +static struct thread *initial_thread; + /* Stack frame for kernel_thread(). */ struct kernel_thread_frame { @@ -57,14 +61,12 @@ void schedule_tail (struct thread *prev); void thread_init (void) { - struct thread *t; - ASSERT (intr_get_level () == INTR_OFF); /* Set up a thread structure for the running thread. */ - t = running_thread (); - init_thread (t, "main"); - t->status = THREAD_RUNNING; + initial_thread = running_thread (); + init_thread (initial_thread, "main"); + initial_thread->status = THREAD_RUNNING; /* Initialize run queue. */ list_init (&ready_list); @@ -379,7 +381,8 @@ destroy_thread (struct thread *t) #ifdef USERPROG addrspace_destroy (t); #endif - palloc_free (t); + if (t != initial_thread) + palloc_free (t); } /* Completes a thread switch by activating the new thread's page -- 2.30.2