diff options
author | peter <peter@FreeBSD.org> | 1996-06-29 10:25:31 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1996-06-29 10:25:31 +0000 |
commit | de937c496c7789cd4c5d97daab75b7ac78abfacb (patch) | |
tree | 0f171bdc50feb45bddbee12e25333f8861c0009a /bin/ps | |
parent | 5b37bd13e00bb27cd3cfb7de1374e53dac8d29ee (diff) | |
download | FreeBSD-src-de937c496c7789cd4c5d97daab75b7ac78abfacb.zip FreeBSD-src-de937c496c7789cd4c5d97daab75b7ac78abfacb.tar.gz |
Make %CPU add up closer to 100%.. At least, it now agrees with top.. :-)
Pointed out by: bde
Diffstat (limited to 'bin/ps')
-rw-r--r-- | bin/ps/print.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c index f8887ba..5c01f30 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: print.c,v 1.13 1996/05/02 13:06:21 phk Exp $ + * $Id: print.c,v 1.14 1996/06/29 08:04:05 peter Exp $ */ #ifndef lint @@ -64,6 +64,7 @@ static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #include <stddef.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include <string.h> #include <vis.h> @@ -531,8 +532,8 @@ getpcpu(k) if (p->p_swtime == 0 || (p->p_flag & P_INMEM) == 0) return (0.0); if (rawcpu) - return (100.0 * fxtofl(p->p_pctcpu)); - return (100.0 * fxtofl(p->p_pctcpu) / + return (10000.0 / sysconf(_SC_CLK_TCK) * fxtofl(p->p_pctcpu)); + return (10000.0 / sysconf(_SC_CLK_TCK) * fxtofl(p->p_pctcpu) / (1.0 - exp(p->p_swtime * log(fxtofl(ccpu))))); } |