Merge task1/themis/priority-donation into task1/priority-donation #13

Merged
td1223 merged 4 commits from task1/themis/priority-donation into task1/priority-donation 2024-10-23 15:03:08 +00:00
3 changed files with 28 additions and 10 deletions
Showing only changes of commit 2cd4da17a4 - Show all commits

View File

@@ -194,11 +194,12 @@ lock_init (struct lock *lock)
sema_init (&lock->semaphore, 1); sema_init (&lock->semaphore, 1);
} }
/* Allows for the donor to donate its priority to donee, iteratively /* Current thread donates its priority to donee, iteratively
propagating the donation in the case of chains in the wait-for graph. propagating the donation in the case of chains in the wait-for graph.
Also keeps track of the donation by updating the donors list. */ Also keeps track of the donation by updating the donors list. */
static void static void
donate_priority (struct thread *donor, struct thread *donee) { donate_priority (struct thread *donee) {
struct thread *donor = thread_current ();
list_push_back (&donee->donors_list, &donor->donor_elem); list_push_back (&donee->donors_list, &donor->donor_elem);
while (donee != NULL) while (donee != NULL)
@@ -249,7 +250,7 @@ lock_acquire (struct lock *lock)
if (lock->holder != NULL) if (lock->holder != NULL)
{ {
t->waiting_lock = lock; t->waiting_lock = lock;
donate_priority (t, lock->holder); donate_priority (lock->holder);
} }
sema_down (&lock->semaphore); sema_down (&lock->semaphore);