Fix donate_priority to disable interrupts for entire update of possibly-ready donatee's priority
This commit is contained in:
@@ -210,25 +210,27 @@ donate_priority (struct thread *donee) {
|
|||||||
if (donor->priority <= donee->priority)
|
if (donor->priority <= donee->priority)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
donee->priority = donor->priority;
|
|
||||||
|
|
||||||
/* Also stop propagation of donation once a donee is reached with
|
/* Also stop propagation of donation once a donee is reached with
|
||||||
no donees of its own (sink node in WFG). */
|
no donees of its own (sink node in WFG). */
|
||||||
if (donee->waiting_lock == NULL)
|
if (donee->waiting_lock == NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Only the sink node of the WFG isn't waiting for a lock and
|
/* 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,
|
could be on the ready list. Thus, as its priority changed,
|
||||||
it must be reinserted into the list. */
|
it must be reinserted into the list. */
|
||||||
enum intr_level old_level = intr_disable ();
|
enum intr_level old_level = intr_disable ();
|
||||||
|
donee->priority = donor->priority;
|
||||||
ready_list_reinsert (donee);
|
ready_list_reinsert (donee);
|
||||||
intr_set_level (old_level);
|
intr_set_level (old_level);
|
||||||
|
|
||||||
donee = NULL;
|
donee = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
donee->priority = donor->priority;
|
||||||
donee = donee->waiting_lock->holder;
|
donee = donee->waiting_lock->holder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Acquires LOCK, sleeping until it becomes available if
|
/* Acquires LOCK, sleeping until it becomes available if
|
||||||
necessary. The lock must not already be held by the current
|
necessary. The lock must not already be held by the current
|
||||||
|
|||||||
Reference in New Issue
Block a user