Optimise load_avg and recent_cpu updates

- only run when BSD scheduler is enabled
This commit is contained in:
2024-10-16 22:56:47 +01:00
parent de8f303fa2
commit eacd93b32d

View File

@@ -155,7 +155,7 @@ thread_tick (void)
/* Update system load_avg and all threads recent_cpu every second. */ /* Update system load_avg and all threads recent_cpu every second. */
int64_t ticks = timer_ticks (); int64_t ticks = timer_ticks ();
if (ticks % TIMER_FREQ == 0) if (thread_mlfqs && (ticks % TIMER_FREQ == 0))
{ {
fp32_t old_coeff = fp_mul (fp_div_int (int_to_fp (59), 60), load_avg); fp32_t old_coeff = fp_mul (fp_div_int (int_to_fp (59), 60), load_avg);
fp32_t new_coeff = fp_div_int (int_to_fp (threads_ready ()), 60); fp32_t new_coeff = fp_div_int (int_to_fp (threads_ready ()), 60);
@@ -165,7 +165,7 @@ thread_tick (void)
} }
/* Update current thread's recent_cpu. */ /* Update current thread's recent_cpu. */
if (t != idle_thread) if (thread_mlfqs && (t != idle_thread))
{ {
t->recent_cpu = fp_add_int (t->recent_cpu, 1); t->recent_cpu = fp_add_int (t->recent_cpu, 1);
if (ticks % 4 == 0) // recent_cpu was updated, update priority. if (ticks % 4 == 0) // recent_cpu was updated, update priority.