- /* Starts preemptive thread scheduling by enabling interrupts.
-@@ -101,9 +110,48 @@ void
++/* Adjust recent CPU of a thread based on load factor
++ and recompute its priority. */
++static void
++adjust_recent_cpu (struct thread *t, void *aux)
++{
++ fixed_point_t load_factor = *(fixed_point_t *)aux;
++
++ t->recent_cpu = fix_add (fix_mul (load_factor, t->recent_cpu),
++ fix_int (t->nice));
++ thread_recompute_priority (t);
++}
++
+ /* Called by the timer interrupt handler at each timer tick.
+ Thus, this function runs in an external interrupt context. */
+ void
+@@ -134,9 +150,41 @@ thread_tick (void)