diff --git a/src/threads/thread.c b/src/threads/thread.c index ed717e3..1f2d273 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -389,14 +389,8 @@ thread_set_priority (int new_base_priority) t->base_priority = new_base_priority; t->priority = new_base_priority; - if (!list_empty (&t->donors_list) && new_base_priority < old_priority) { - int max_donated_priority = - list_entry (list_max (&t->donors_list, priority_more, NULL), - struct thread, donor_elem)->priority; - - if(new_base_priority < max_donated_priority) - t->priority = new_base_priority; - } + if (new_base_priority < old_priority) + thread_recalculate_priority (); thread_yield (); } @@ -412,8 +406,17 @@ thread_get_priority (void) void thread_recalculate_priority (void) { - barrier (); -}; + struct thread *t = thread_current (); + + if (!list_empty (&t->donors_list)) { + int max_donated_priority = + list_entry (list_max (&t->donors_list, priority_more, NULL), + struct thread, donor_elem)->priority; + + if(max_donated_priority > t->priority) + t->priority = max_donated_priority; + } +} /* Sets the current thread's nice value to NICE. */ void