Update condvar to use linear search due to changes in priority from donations, w/ T
This commit is contained in:
@@ -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);
|
||||
@@ -436,8 +435,12 @@ cond_signal (struct condition *cond, struct lock *lock UNUSED)
|
||||
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);
|
||||
{
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user