implement logic to increment recent_cpu on every timer_interrupt () call

This commit is contained in:
EDiasAlberto
2024-10-16 18:34:56 +01:00
parent 0db3551a9a
commit 7a1aa21e1e
2 changed files with 14 additions and 0 deletions

View File

@@ -208,6 +208,7 @@ timer_interrupt (struct intr_frame *args UNUSED)
else
break;
}
thread_increment_recent_cpu ();
thread_tick ();
}

View File

@@ -382,6 +382,19 @@ calculate_recent_cpu (void)
return { 0 };
}
void
thread_increment_recent_cpu (void)
{
struct thread *t = thread_current ();
if (t == idle_thread)
{
return;
}
fp32_t old_recent_cpu = t->recent_cpu;
old_recent_cpu.raw = old_recent_cpu.raw + 1;
t->recent_cpu = old_recent_cpu;
}
/* Sets the current thread's nice value to NICE. */
void
thread_set_nice (int nice)