From owner-freebsd-hackers Mon Mar 22 18:53:39 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from bingsun2.cc.binghamton.edu (bingsun2.cc.binghamton.edu [128.226.1.6]) by hub.freebsd.org (Postfix) with ESMTP id 0AAAC1530D for ; Mon, 22 Mar 1999 18:53:37 -0800 (PST) (envelope-from bf20761@binghamton.edu) Received: from localhost (bf20761@localhost) by bingsun2.cc.binghamton.edu (8.8.7/8.6.9) with SMTP id VAA12111 for ; Mon, 22 Mar 1999 21:53:15 -0500 (EST) Date: Mon, 22 Mar 1999 21:53:14 -0500 (EST) From: zhihuizhang X-Sender: bf20761@bingsun2 To: freebsd-hackers@FreeBSD.ORG Subject: understanding of scaled load average calculation Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I am trying to understand the calculation of digital decay contants used by process scheduler and ps command (see file kern_synch.c). I have read the web page "fixed-point arithmetic" at http://www.shadow.net/~yates/fp.htm. But I still could not figure out how FSHIFT and CCPU_SHIFT are chosen. The following comment in the source code confuses me: "The number of CPU ticks that map to a unique %age can be expressed by the formula (1/(2 ^ (FSHIFT-11)))." Where does this formula come from? "To estimate CCPU_SHIFT for exp(-1/20), the following formula was used: 1 - exp(-1/20) ~= 0.0487 ~= 0.0488 == 1 (fixed pt, *11* bits)." What does this mean? I do know that 11 fractional digit gives a resolution of 2 ^ (-11) = 0.00048828. The three digits 488 are the same. I did make a little progress in trying to understand this comment: If FSHIFT is 11, the maximum load average is about 1024. This is because cexp[i]*avg->ldavg[i] in routine loadav() (see file vm_meter.c) will overflow if the unscaled load average > 1024. I hope someone will help me out. Thanks a lot. -------------------------------------------------- | Zhihui Zhang, http://cs.binghamton.edu/~zzhang | | Dept. of Computer Science, SUNY at Binghamton | -------------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message