Merge 'task1/priority-donation' into 'master' #14

Merged
sb3923 merged 66 commits from task1/priority-donation into master 2024-10-23 16:15:45 +00:00
4 changed files with 267 additions and 16 deletions
Showing only changes of commit 5f8dea21be - Show all commits

View File

@@ -210,24 +210,26 @@ 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