From f9d82c92dec012832f16113269b11e0bdfe09d05 Mon Sep 17 00:00:00 2001 From: Themis Demetriades Date: Wed, 23 Oct 2024 16:16:25 +0100 Subject: [PATCH] Update thread_recalculate_priority to disable interrupts preventing race conditions for access to donors and priorities w/ S --- src/threads/thread.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/threads/thread.c b/src/threads/thread.c index 8731b3b..dd594d9 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -417,6 +417,8 @@ void thread_recalculate_priority (void) { struct thread *t = thread_current (); + + enum intr_level old_level = intr_disable (); t->priority = t->base_priority; /* If there are no donors to the current thread, then the effective @@ -432,6 +434,7 @@ thread_recalculate_priority (void) if (max_donated_priority > t->priority) t->priority = max_donated_priority; } + intr_set_level (old_level); } /* Sets the current thread's nice value to NICE. */