aboutsummaryrefslogtreecommitdiff
path: root/bin/ps/print.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>1996-06-29 10:25:31 +0000
committerPeter Wemm <peter@FreeBSD.org>1996-06-29 10:25:31 +0000
commit0164b6d61bbf2404f3926026810aba8d22793f92 (patch)
tree0f171bdc50feb45bddbee12e25333f8861c0009a /bin/ps/print.c
parent01155bd72075d0bca4ffbb96fb27c96a31c8ecee (diff)
downloadsrc-0164b6d61bbf2404f3926026810aba8d22793f92.tar.gz
src-0164b6d61bbf2404f3926026810aba8d22793f92.zip
Make %CPU add up closer to 100%.. At least, it now agrees with top.. :-)
Pointed out by: bde
Notes
Notes: svn path=/head/; revision=16835
Diffstat (limited to 'bin/ps/print.c')
-rw-r--r--bin/ps/print.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c
index f8887ba809a2..5c01f302af74 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)))));
}