Add implementation for recalculate effective priority, w/ T
This commit is contained in:
@@ -389,14 +389,8 @@ thread_set_priority (int new_base_priority)
|
|||||||
t->base_priority = new_base_priority;
|
t->base_priority = new_base_priority;
|
||||||
t->priority = new_base_priority;
|
t->priority = new_base_priority;
|
||||||
|
|
||||||
if (!list_empty (&t->donors_list) && new_base_priority < old_priority) {
|
if (new_base_priority < old_priority)
|
||||||
int max_donated_priority =
|
thread_recalculate_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
thread_yield ();
|
thread_yield ();
|
||||||
}
|
}
|
||||||
@@ -412,8 +406,17 @@ thread_get_priority (void)
|
|||||||
void
|
void
|
||||||
thread_recalculate_priority (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. */
|
/* Sets the current thread's nice value to NICE. */
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user