implement logic to increment recent_cpu on every timer_interrupt () call
This commit is contained in:
@@ -208,6 +208,7 @@ timer_interrupt (struct intr_frame *args UNUSED)
|
||||
else
|
||||
break;
|
||||
}
|
||||
thread_increment_recent_cpu ();
|
||||
thread_tick ();
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user