Refactor thread recalculate priority to add comments for clarity, w/ T
This commit is contained in:
@@ -419,12 +419,16 @@ thread_recalculate_priority (void)
|
|||||||
struct thread *t = thread_current ();
|
struct thread *t = thread_current ();
|
||||||
t->priority = t->base_priority;
|
t->priority = t->base_priority;
|
||||||
|
|
||||||
|
/* If there are no donors to the current thread, then the effective
|
||||||
|
priority is just the base priority. */
|
||||||
if (!list_empty (&t->donors_list))
|
if (!list_empty (&t->donors_list))
|
||||||
{
|
{
|
||||||
int max_donated_priority =
|
int max_donated_priority =
|
||||||
list_entry (list_max (&t->donors_list, donor_priority_less, NULL),
|
list_entry (list_max (&t->donors_list, donor_priority_less, NULL),
|
||||||
struct thread, donor_elem)->priority;
|
struct thread, donor_elem)->priority;
|
||||||
|
|
||||||
|
/* The effective priority is the max donated priority if this is
|
||||||
|
higher than the base priority. */
|
||||||
if (max_donated_priority > t->priority)
|
if (max_donated_priority > t->priority)
|
||||||
t->priority = max_donated_priority;
|
t->priority = max_donated_priority;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user