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));
|
ASSERT (lock_held_by_current_thread (lock));
|
||||||
|
|
||||||
sema_init (&waiter.semaphore, 0);
|
sema_init (&waiter.semaphore, 0);
|
||||||
list_insert_ordered (&cond->waiters, &waiter.elem, sema_priority_more,
|
list_push_back (&cond->waiters, &waiter.elem);
|
||||||
&thread_current ()->elem);
|
|
||||||
lock_release (lock);
|
lock_release (lock);
|
||||||
sema_down (&waiter.semaphore);
|
sema_down (&waiter.semaphore);
|
||||||
lock_acquire (lock);
|
lock_acquire (lock);
|
||||||
@@ -436,8 +435,12 @@ cond_signal (struct condition *cond, struct lock *lock UNUSED)
|
|||||||
ASSERT (lock_held_by_current_thread (lock));
|
ASSERT (lock_held_by_current_thread (lock));
|
||||||
|
|
||||||
if (!list_empty (&cond->waiters))
|
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
|
/* Wakes up all threads, if any, waiting on COND (protected by
|
||||||
|
|||||||
Reference in New Issue
Block a user