X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fthreads%2Fthread.c;h=ca8a8b07e3fa54769d2068e482a2cb019c2ef563;hb=d51aeb9e448d8a05d4263a7459c857ff2fb9d3b2;hp=01e8ea42919913a8c5219221c01f52a38f5f1d3e;hpb=8abbb333aea445641d967befd3ca477502ea770b;p=pintos-anon diff --git a/src/threads/thread.c b/src/threads/thread.c index 01e8ea4..ca8a8b0 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -92,7 +92,7 @@ thread_init (void) void thread_start (void) { - thread_create ("idle", PRI_MAX, idle, NULL); + thread_create ("idle", PRI_MIN, idle, NULL); intr_enable (); } @@ -483,12 +483,13 @@ schedule_tail (struct thread *prev) /* If the thread we switched from is dying, destroy its struct thread. This must happen late so that thread_exit() doesn't - pull out the rug under itself. */ - if (prev != NULL && prev->status == THREAD_DYING) + pull out the rug under itself. (We don't free + initial_thread because its memory was not obtained via + palloc().) */ + if (prev != NULL && prev->status == THREAD_DYING && prev != initial_thread) { ASSERT (prev != cur); - if (prev != initial_thread) - palloc_free_page (prev); + palloc_free_page (prev); } }