Date: Sat, 20 Mar 1999 15:18:15 -0500 (EST) From: zhihuizhang <bf20761@binghamton.edu> To: freebsd-hackers@FreeBSD.ORG Subject: Calculation of load average and CCPU_SHIFT Message-ID: <Pine.SOL.L3.93.990320150853.18347B-100000@bingsun1>
next in thread | raw e-mail | index | archive | help
I am looking into the source code in file vm_meter.c and kern_synch.c of FreeBSD 2.2.8. They use integer multiplication and shift operation to replace the costly float multiplication. The FSCALE and FSHIFT are for this purpose. But I could not understand the usage of CCPU_SHIFT in schedcpu(). Specifically, please explain the following comments in the source code in more detail if possible: -------------------------------------------------------------------- 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). Scale factor for scaled integers used to count %cpu time and load averages. The number of CPU 'tick's that map to a unique '%age' can be expressed by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that can be calculated (assuming 32 bits) can be closely approximated using the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). For the scheduler to maintain a 1:1 mapping of CPU 'tick' to '%age', FSHIFT must be at least 11; this gives us a maximum load average of ~1024. ------------------------------------------------------------------- Any help or hint is appreciated. -------------------------------------------------- | 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SOL.L3.93.990320150853.18347B-100000>