diff --git a/src/threads/thread.c b/src/threads/thread.c index 70d5667..aa9761d 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -372,11 +372,15 @@ thread_yield (void) if (cur != idle_thread) { if (thread_mlfqs) + { list_insert_ordered (&ready_list, &cur->elem, thread_priority_less, NULL); + } else + { /* Insert the thread back into the ready list in priority order. */ list_insert_ordered(&ready_list, &cur->elem, priority_more, NULL); + } } cur->status = THREAD_READY; @@ -473,7 +477,7 @@ thread_update_recent_cpu (struct thread *t, void *aux UNUSED) = fp_add_int (fp_mul (recent_cpu_coeff, curr_recent_cpu), t->nice); // recent_cpu was updated, update priority. t->priority = calculate_bsd_priority (t->recent_cpu, t->nice); - +} /* Recalculates the effective priority of the current thread. */ void thread_recalculate_priority (void)