From: Ben Pfaff Date: Tue, 20 Dec 2005 22:26:13 +0000 (+0000) Subject: Suggest order of operations for recent_cpu calculation. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00d65ff1310f5cfe59bf0bde1e5166f9d2570340;p=pintos-anon Suggest order of operations for recent_cpu calculation. Thanks to "Jeff Sun" for report. --- diff --git a/doc/44bsd.texi b/doc/44bsd.texi index e53e829..1747277 100644 --- a/doc/44bsd.texi +++ b/doc/44bsd.texi @@ -190,6 +190,11 @@ multiple of a second, that is, when @code{timer_ticks () % TIMER_FREQ == The value of @var{recent_cpu} can be negative for a thread with a negative @var{nice} value. Do not clamp negative @var{recent_cpu} to 0. +You may need to think about the order of calculations in this formula. +We recommend computing the coefficient of @var{recent_cpu} first, then +multiplying. Some students have reported that multiplying +@var{load_avg} by @var{recent_cpu} directly can cause overflow. + You must implement @func{thread_get_recent_cpu}, for which there is a skeleton in @file{threads/thread.c}.