Merge 'task1/priority-donation' into 'master' #14

Merged
sb3923 merged 66 commits from task1/priority-donation into master 2024-10-23 16:15:45 +00:00
4 changed files with 265 additions and 16 deletions
Showing only changes of commit b0074c80f0 - Show all commits

View File

@@ -220,7 +220,9 @@ donate_priority (struct thread *donee) {
/* Only the sink node of the WFG isn't waiting for a lock and /* Only the sink node of the WFG isn't waiting for a lock and
could be on the ready list. Thus, as its priority changed, could be on the ready list. Thus, as its priority changed,
it must be reinserted into the list. */ it must be reinserted into the list. */
enum intr_level old_level = intr_disable ();
ready_list_reinsert (donee); ready_list_reinsert (donee);
intr_set_level (old_level);
donee = NULL; donee = NULL;
} }
else else

View File

@@ -467,20 +467,18 @@ thread_get_recent_cpu (void)
/* Reinsert thread t into the ready list at its correct position /* Reinsert thread t into the ready list at its correct position
in descending order of priority. Used when this thread's priority in descending order of priority. Used when this thread's priority
may have changed. */ may have changed. Must be called with interrupts disabled. */
void void
ready_list_reinsert (struct thread *t) ready_list_reinsert (struct thread *t)
{ {
enum intr_level old_level = intr_disable (); ASSERT (intr_get_level () == INTR_OFF);
/* If the thread isn't ready to run, do nothing. */ /* If the thread isn't ready to run, do nothing. */
if (t->status == THREAD_READY) if (t->status != THREAD_READY)
{ return;
list_remove (&t->elem);
list_insert_ordered (&ready_list, &t->elem, priority_more, NULL);
}
intr_set_level (old_level); list_remove (&t->elem);
list_insert_ordered (&ready_list, &t->elem, priority_more, NULL);
} }
/* Idle thread. Executes when no other thread is ready to run. /* Idle thread. Executes when no other thread is ready to run.