From 09fa5c11aff62bd728d4fe8de28a7abaf252fed3 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 12 Feb 2011 10:03:53 -0800 Subject: [PATCH] thread: Properly protect 'all_list' around insertion. Reported by Francis Russell . --- src/threads/thread.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/threads/thread.c b/src/threads/thread.c index 955ccdc..d68c123 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -459,6 +459,8 @@ is_thread (struct thread *t) static void init_thread (struct thread *t, const char *name, int priority) { + enum intr_level old_level; + ASSERT (t != NULL); ASSERT (PRI_MIN <= priority && priority <= PRI_MAX); ASSERT (name != NULL); @@ -469,7 +471,10 @@ init_thread (struct thread *t, const char *name, int priority) t->stack = (uint8_t *) t + PGSIZE; t->priority = priority; t->magic = THREAD_MAGIC; + + old_level = intr_disable (); list_push_back (&all_list, &t->allelem); + intr_set_level (old_level); } /* Allocates a SIZE-byte frame at the top of thread T's stack and -- 2.30.2