Update donate_priority to only attempt to sort position of the donee that isn't waiting for a lock
This commit is contained in:
@@ -214,12 +214,17 @@ donate_priority (struct thread *donor, struct thread *donee) {
|
|||||||
/* 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)
|
||||||
donee = 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. */
|
||||||
|
ready_list_reinsert (donee);
|
||||||
|
donee = NULL;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
donee = donee->waiting_lock->holder;
|
donee = donee->waiting_lock->holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
ready_list_reorder ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Acquires LOCK, sleeping until it becomes available if
|
/* Acquires LOCK, sleeping until it becomes available if
|
||||||
|
|||||||
@@ -465,10 +465,22 @@ thread_get_recent_cpu (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reinsert thread t into the ready list at its correct position
|
||||||
|
in descending order of priority. Used when this thread's priority
|
||||||
|
may have changed. */
|
||||||
void
|
void
|
||||||
ready_list_reorder (void)
|
ready_list_reinsert (struct thread *t)
|
||||||
{
|
{
|
||||||
list_sort (&ready_list, priority_more, NULL);
|
enum intr_level old_level = intr_disable ();
|
||||||
|
|
||||||
|
/* If the thread isn't ready to run, do nothing. */
|
||||||
|
if (t->status == THREAD_READY)
|
||||||
|
{
|
||||||
|
list_remove (&t->elem);
|
||||||
|
list_insert_ordered (&ready_list, &t->elem, priority_more, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
intr_set_level (old_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Idle thread. Executes when no other thread is ready to run.
|
/* Idle thread. Executes when no other thread is ready to run.
|
||||||
|
|||||||
@@ -151,6 +151,6 @@ void thread_set_nice (int);
|
|||||||
int thread_get_recent_cpu (void);
|
int thread_get_recent_cpu (void);
|
||||||
int thread_get_load_avg (void);
|
int thread_get_load_avg (void);
|
||||||
|
|
||||||
void ready_list_reorder (void);
|
void ready_list_reinsert (struct thread *t);
|
||||||
|
|
||||||
#endif /* threads/thread.h */
|
#endif /* threads/thread.h */
|
||||||
|
|||||||
Reference in New Issue
Block a user