From 5f8dea21befb9bf5688383796eb510770ddb2d0b Mon Sep 17 00:00:00 2001 From: Themis Demetriades Date: Wed, 23 Oct 2024 14:10:48 +0100 Subject: [PATCH] Fix donate_priority to disable interrupts for entire update of possibly-ready donatee's priority --- src/threads/synch.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/threads/synch.c b/src/threads/synch.c index 7dc6eaa..b99332e 100644 --- a/src/threads/synch.c +++ b/src/threads/synch.c @@ -210,23 +210,25 @@ donate_priority (struct thread *donee) { if (donor->priority <= donee->priority) break; - donee->priority = donor->priority; - /* Also stop propagation of donation once a donee is reached with no donees of its own (sink node in WFG). */ if (donee->waiting_lock == NULL) { - /* Only the sink node of the WFG isn't waiting for a lock and could be on the ready list. Thus, as its priority changed, it must be reinserted into the list. */ enum intr_level old_level = intr_disable (); + donee->priority = donor->priority; ready_list_reinsert (donee); intr_set_level (old_level); + donee = NULL; } else - donee = donee->waiting_lock->holder; + { + donee->priority = donor->priority; + donee = donee->waiting_lock->holder; + } } }