diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-06-29 15:03:34 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-06-29 15:03:34 +0000 |
commit | 441ccb55b8d160a4fadbd625f604f64c4f7d05b1 (patch) | |
tree | 7eb1defb02077183fdb582ef6e0da74cdf50e61d /bin | |
parent | d6b018580d53ef94568d5ccc139dc0440217f504 (diff) |
After removing the p_swtime from the kernel, ps always printed 0.0
as %cpu time. Remove the calculation in ps that includes the process
lifetime. Just print the p_pctcpu value, that was done before when
ps was called with -C. Keep -C as a no-op for existing scripts.
OK millert@
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ps/extern.h | 4 | ||||
-rw-r--r-- | bin/ps/print.c | 20 | ||||
-rw-r--r-- | bin/ps/ps.1 | 15 | ||||
-rw-r--r-- | bin/ps/ps.c | 10 |
4 files changed, 12 insertions, 37 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h index 3ffd723a89f..1ec30ccc3ee 100644 --- a/bin/ps/extern.h +++ b/bin/ps/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.16 2011/12/29 17:13:55 guenther Exp $ */ +/* $OpenBSD: extern.h,v 1.17 2015/06/29 15:03:33 bluhm Exp $ */ /* $NetBSD: extern.h,v 1.10 1995/05/21 13:38:27 mycroft Exp $ */ /*- @@ -37,7 +37,7 @@ struct var; struct varent; extern fixpt_t ccpu; -extern int eval, fscale, nlistread, rawcpu, maxslp; +extern int eval, fscale, nlistread, maxslp; extern u_int mempages; extern int sumrusage, termwidth, totwidth, kvm_sysctl_only, needheader; extern VAR var[]; diff --git a/bin/ps/print.c b/bin/ps/print.c index a272589af75..9f22e0276e9 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.60 2015/03/15 00:41:27 millert Exp $ */ +/* $OpenBSD: print.c,v 1.61 2015/06/29 15:03:33 bluhm Exp $ */ /* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */ /*- @@ -523,28 +523,12 @@ cputime(const struct kinfo_proc *kp, VARENT *ve) double getpcpu(const struct kinfo_proc *kp) { - double d; - if (fscale == 0) return (0.0); #define fxtofl(fixpt) ((double)(fixpt) / fscale) - /* XXX - I don't like this */ - if (kp->p_swtime == 0) - return (0.0); - if (rawcpu) - return (100.0 * fxtofl(kp->p_pctcpu)); - - d = kp->p_swtime * log(fxtofl(ccpu)); - if (d < -700.0) - d = 0.0; /* avoid IEEE underflow */ - else - d = exp(d); - if (d == 1.0) - return (0.0); - return (100.0 * fxtofl(kp->p_pctcpu) / - (1.0 - d)); + return (100.0 * fxtofl(kp->p_pctcpu)); } void diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 55a467939f3..2d324488f1d 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ps.1,v 1.98 2015/02/11 00:43:33 guenther Exp $ +.\" $OpenBSD: ps.1,v 1.99 2015/06/29 15:03:33 bluhm Exp $ .\" $NetBSD: ps.1,v 1.16 1996/03/21 01:36:28 jtc Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 @@ -30,7 +30,7 @@ .\" .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" -.Dd $Mdocdate: February 11 2015 $ +.Dd $Mdocdate: June 29 2015 $ .Dt PS 1 .Os .Sh NAME @@ -39,7 +39,7 @@ .Sh SYNOPSIS .Nm ps .Sm off -.Op Fl AaCceHhjkLlmrSTuvwx +.Op Fl AaceHhjkLlmrSTuvwx .Sm on .Op Fl M Ar core .Op Fl N Ar system @@ -76,13 +76,6 @@ Display information about processes for all users, including those without contr terminals. .It Fl a Display information about processes for all users with controlling terminals. -.It Fl C -Change the way the CPU percentage is calculated by using a -.Dq raw -CPU calculation that ignores -.Dq resident -time (this normally has -no effect). .It Fl c Do not display full command with arguments, but only the executable name. @@ -613,7 +606,7 @@ X/Open System Interfaces option of .St -p1003.1-2008 . .Pp The flags -.Op Fl CcHhjkLMmNOrSTvWwx +.Op Fl cHhjkLMmNOrSTvWwx are extensions to .St -p1003.1-2008 . .Pp diff --git a/bin/ps/ps.c b/bin/ps/ps.c index c33837f6de3..56876ae571d 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ps.c,v 1.64 2015/04/09 19:48:25 okan Exp $ */ +/* $OpenBSD: ps.c,v 1.65 2015/06/29 15:03:33 bluhm Exp $ */ /* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */ /*- @@ -60,7 +60,6 @@ extern char *__progname; struct varent *vhead; int eval; /* exit value */ -int rawcpu; /* -C */ int sumrusage; /* -S */ int termwidth; /* width of screen (0 == infinity) */ int totwidth; /* calculated width of requested variables */ @@ -136,8 +135,7 @@ main(int argc, char *argv[]) all = 1; break; case 'C': - rawcpu = 1; - break; + break; /* no-op */ case 'c': commandonly = 1; break; @@ -477,8 +475,8 @@ static void usage(void) { (void)fprintf(stderr, - "usage: %s [-AaCceHhjkLlmrSTuvwx] [-M core] [-N system] [-O fmt] [-o fmt] [-p pid]\n", - __progname); + "usage: %s [-AaceHhjkLlmrSTuvwx] [-M core] [-N system] [-O fmt] [-o fmt] [-p pid]\n", + __progname); (void)fprintf(stderr, "%-*s[-t tty] [-U username] [-W swap]\n", (int)strlen(__progname) + 8, ""); exit(1); |