Refactor lock release to follow PintOS indent style and use list functoins, w/ T
This commit is contained in:
@@ -302,14 +302,14 @@ lock_release (struct lock *lock)
|
|||||||
/* Excludes donors that aren't waiting for the lock being released,
|
/* Excludes donors that aren't waiting for the lock being released,
|
||||||
and tracks the rest. */
|
and tracks the rest. */
|
||||||
if (donor->waiting_lock == lock)
|
if (donor->waiting_lock == lock)
|
||||||
{
|
{
|
||||||
list_remove (e);
|
list_remove (e);
|
||||||
list_push_back (&orphan_list, e);
|
list_push_back (&orphan_list, e);
|
||||||
|
|
||||||
/* Identify highest priority donor. */
|
/* Identify highest priority donor. */
|
||||||
if (max_donor == NULL || donor->priority > max_donor->priority)
|
if (max_donor == NULL || donor->priority > max_donor->priority)
|
||||||
max_donor = donor;
|
max_donor = donor;
|
||||||
}
|
}
|
||||||
|
|
||||||
e = next;
|
e = next;
|
||||||
}
|
}
|
||||||
@@ -317,17 +317,10 @@ lock_release (struct lock *lock)
|
|||||||
/* If there exists a maximum donor thread waiting for this lock to be
|
/* If there exists a maximum donor thread waiting for this lock to be
|
||||||
released, transfer the remaining orphaned donors to its donor list. */
|
released, transfer the remaining orphaned donors to its donor list. */
|
||||||
if (max_donor != NULL)
|
if (max_donor != NULL)
|
||||||
{
|
{
|
||||||
tail = list_tail (&orphan_list);
|
while (!list_empty (&orphan_list))
|
||||||
e = list_begin (&orphan_list);
|
list_push_back (&max_donor->donors_list, list_pop_front (&orphan_list));
|
||||||
while (e != tail)
|
}
|
||||||
{
|
|
||||||
struct list_elem *next = list_next (e);
|
|
||||||
list_push_back (&max_donor->donors_list, e);
|
|
||||||
|
|
||||||
e = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Removal of donors to this thread may change its effective priority,
|
/* Removal of donors to this thread may change its effective priority,
|
||||||
so recalculate. */
|
so recalculate. */
|
||||||
|
|||||||
Reference in New Issue
Block a user