Merge 'task1/priority-donation' into 'master' #14

Merged
sb3923 merged 66 commits from task1/priority-donation into master 2024-10-23 16:15:45 +00:00
4 changed files with 175 additions and 10 deletions
Showing only changes of commit b1dba1a0bd - Show all commits

View File

@@ -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