Merge implementations of priority scheduling by Themis and Saleh #11

Closed
td1223 wants to merge 14 commits from task1/priority-scheduling into task1/merged/priority-scheduling
Showing only changes of commit 88967acdaa - Show all commits

View File

@@ -355,7 +355,14 @@ 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_push_back (&cond->waiters, &waiter.elem);
/* Insert the semaphore_elem into the waiters list in order of priority.
We pass the priority of the current thread as aux to sema_priority_more
because the thread has not been sema'd down yet (See sema_priority_more) */
int priority = thread_current ()->priority;
list_insert_ordered (&cond->waiters, &waiter.elem, sema_priority_more,
&priority);
lock_release (lock); lock_release (lock);
sema_down (&waiter.semaphore); sema_down (&waiter.semaphore);
lock_acquire (lock); lock_acquire (lock);