Merge implementations of priority scheduling by Themis and Saleh #12

Closed
td1223 wants to merge 10 commits from task1/priority-scheduling into task1/merged/priority-scheduling
3 changed files with 21 additions and 3 deletions
Showing only changes of commit 6855a48603 - Show all commits

View File

@@ -68,7 +68,8 @@ sema_down (struct semaphore *sema)
old_level = intr_disable (); old_level = intr_disable ();
while (sema->value == 0) 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 (); thread_block ();
} }
sema->value--; sema->value--;
@@ -118,6 +119,7 @@ sema_up (struct semaphore *sema)
struct thread, elem)); struct thread, elem));
sema->value++; sema->value++;
intr_set_level (old_level); intr_set_level (old_level);
thread_yield ();
} }
static void sema_test_helper (void *sema_); static void sema_test_helper (void *sema_);