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 237 additions and 14 deletions
Showing only changes of commit 244db41434 - Show all commits

View File

@@ -413,8 +413,7 @@ cond_wait (struct condition *cond, struct lock *lock)
ASSERT (lock_held_by_current_thread (lock));
sema_init (&waiter.semaphore, 0);
list_insert_ordered (&cond->waiters, &waiter.elem, sema_priority_more,
&thread_current ()->elem);
list_push_back (&cond->waiters, &waiter.elem);
lock_release (lock);
sema_down (&waiter.semaphore);
lock_acquire (lock);
@@ -435,9 +434,13 @@ cond_signal (struct condition *cond, struct lock *lock UNUSED)
ASSERT (!intr_context ());
ASSERT (lock_held_by_current_thread (lock));
if (!list_empty (&cond->waiters))
sema_up (&list_entry (list_pop_front (&cond->waiters),
struct semaphore_elem, elem)->semaphore);
if (!list_empty (&cond->waiters))
{
struct list_elem *e = list_min (&cond->waiters, sema_priority_more, NULL);
list_remove (e);
sema_up (&list_entry (e, struct semaphore_elem, elem)->semaphore);
}
}
/* Wakes up all threads, if any, waiting on COND (protected by