diff --git a/src/threads/synch.c b/src/threads/synch.c index 7776cb0..e1bcf9f 100644 --- a/src/threads/synch.c +++ b/src/threads/synch.c @@ -68,7 +68,8 @@ sema_down (struct semaphore *sema) old_level = intr_disable (); while (sema->value == 0) { - list_push_back (&sema->waiters, &thread_current ()->elem); + list_insert_ordered (&sema->waiters, &thread_current ()->elem, + &thread_priority_greater, NULL); thread_block (); } sema->value--; @@ -118,6 +119,7 @@ sema_up (struct semaphore *sema) struct thread, elem)); sema->value++; intr_set_level (old_level); + thread_yield (); } static void sema_test_helper (void *sema_);