Update donate_priority to only attempt to sort position of the donee that isn't waiting for a lock
This commit is contained in:
@@ -465,10 +465,22 @@ thread_get_recent_cpu (void)
|
||||
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
|
||||
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.
|
||||
@@ -558,7 +570,7 @@ init_thread (struct thread *t, const char *name, int priority)
|
||||
t->stack = (uint8_t *) t + PGSIZE;
|
||||
t->base_priority = priority;
|
||||
t->magic = THREAD_MAGIC;
|
||||
|
||||
|
||||
list_init (&t->donors_list);
|
||||
t->priority = t->base_priority;
|
||||
t->waiting_lock = NULL;
|
||||
|
||||
Reference in New Issue
Block a user