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 172 additions and 10 deletions
Showing only changes of commit 8e20884a23 - Show all commits

View File

@@ -265,6 +265,18 @@ lock_release (struct lock *lock)
ASSERT (lock != NULL);
ASSERT (lock_held_by_current_thread (lock));
struct thread *current_thread = thread_current ();
struct list_elem *tail = list_tail (&current_thread->donors_list);
for (struct list_elem *e = list_begin (&current_thread->donors_list);
e != tail; e = e->next)
{
struct thread *donor = list_entry (e, struct thread, donor_elem);
if (donor->waiting_lock == lock)
list_remove (e);
}
thread_recalculate_priority ();
lock->holder = NULL;
sema_up (&lock->semaphore);
}

View File

@@ -408,6 +408,13 @@ thread_get_priority (void)
return thread_current ()->priority;
}
/* Recalculates the effective priority of the current thread. */
void
thread_recalculate_priority (void)
{
barrier ();
};
/* Sets the current thread's nice value to NICE. */
void
thread_set_nice (int nice UNUSED)

View File

@@ -144,6 +144,7 @@ bool priority_more (const struct list_elem *a_, const struct list_elem *b_,
void *aux UNUSED);
int thread_get_priority (void);
void thread_set_priority (int);
void thread_recalculate_priority (void);
int thread_get_nice (void);
void thread_set_nice (int);