From owner-freebsd-questions@FreeBSD.ORG Sat Aug 20 06:13:46 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 611E516A41F for ; Sat, 20 Aug 2005 06:13:46 +0000 (GMT) (envelope-from chris@aebc.com) Received: from imail.aebc.com (dns1.aebc.com [209.53.200.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id EE3EA43D45 for ; Sat, 20 Aug 2005 06:13:45 +0000 (GMT) (envelope-from chris@aebc.com) Received: from aebc.com [209.139.247.233] by imail.aebc.com with ESMTP (SMTPD32-7.15) id AA3B2DB012A; Fri, 19 Aug 2005 23:14:19 -0700 Received: from chris [209.53.197.59] by aebc.com with ESMTP (SMTPD32-7.15) id A81A1A350148; Fri, 19 Aug 2005 13:59:06 -0700 From: "Chris St Denis" To: "'Kannan Varadhan'" , Date: Fri, 19 Aug 2005 13:58:15 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.6353 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 In-Reply-To: thread-index: AcWk8ZVe6/yV5mryR56y89YaoTBy9QADxoOw Message-Id: <200508191359843.SM01472@chris> X-RBL-Warning: NOPOSTMASTER: "Not supporting postmaster@domain" X-RBL-Warning: IPNOTINMX: X-RBL-Warning: SPAMHEADERS: This E-mail has headers consistent with spam [4000020e]. X-RBL-Warning: CMDSPACE: Space found in RCPT TO: command. X-Declude-Sender: chris@aebc.com [209.53.197.59] X-Declude-Spoolname: D481a1a350148d3e9.SMD X-Note: Email was scanned by AE's anti-spam system in MX2 server. X-Note: This E-mail was sent from zz197059.cipherkey.net ([209.53.197.59]). X-Note: Total spam weight of this E-mail is 3. X-Spam-Tests-Failed: NOPOSTMASTER [1], IPNOTINMX [0], SPAMHEADERS [0], CMDSPACE [5] Cc: Subject: RE: Calculating the load average in the freebsd kernel X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Aug 2005 06:13:46 -0000 This may help http://www.teamquest.com/resources/gunther/ldavg1.shtml -----Original Message----- From: owner-freebsd-questions@freebsd.org [mailto:owner-freebsd-questions@freebsd.org] On Behalf Of Kannan Varadhan Sent: Friday, August 19, 2005 12:08 PM To: freebsd-questions@freebsd.org Subject: Calculating the load average in the freebsd kernel Hello, I am staring at the code in kern/kern_synch.c that calculates the load average of the system, and I cannot fully understand how the freebsd version works. Specifically, it looks as: /* * Constants for averages over 1, 5, and 15 minutes * when sampling at 5 second intervals. */ static fixpt_t cexp[3] = { 0.9200444146293232 * FSCALE, /* exp(-1/12) */ 0.9834714538216174 * FSCALE, /* exp(-1/60) */ 0.9944598480048967 * FSCALE, /* exp(-1/180) */ }; ... /* * Compute a tenex style load average of a quantity on * 1, 5 and 15 minute intervals. * XXXKSE Needs complete rewrite when correct info is available. * Completely Bogus.. only works with 1:1 (but compiles ok now :-) */ static void loadav(void *arg) { int i, nrun; struct loadavg *avg; nrun = sched_load(); avg = &averunnable; for (i = 0; i < 3; i++) avg->ldavg[i] = (cexp[i] * avg->ldavg[i] + nrun * FSCALE * (FSCALE - cexp[i])) >> FSHIFT; ... And elsewhere, FSCALE is defined as 1<ldavg[i] = (cexp[i] * avg->ldavg[i] + nrun * FSCALE * (FSCALE - cexp[i])) >> FSHIFT; ^^^^^^ Why do we have that extra FSCALE multiplier in the second term? If I do some logical simplifications, this seems to get me: (\alpha * FSCALE * ldavg[I] + nrum * FSCALE * FSCALE (1 - \alpha)) >> FSHIFT I.e. \alpha * ldavg[I] + nrun * FSCALE * (1 - \alpha) What am I missing in this arithmetic? Thanks, Kannan _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"