Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ps Add an LTIME column that prints lwp cputime.



details:   https://anonhg.NetBSD.org/src/rev/453f11f05c86
branches:  trunk
changeset: 325980:453f11f05c86
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Wed Jan 15 08:07:53 2014 +0000

description:
Add an LTIME column that prints lwp cputime.

diffstat:

 bin/ps/extern.h  |   3 +-
 bin/ps/keyword.c |   5 ++-
 bin/ps/print.c   |  69 ++++++++++++++++++++++++++++++++++++++-----------------
 bin/ps/ps.1      |   4 ++-
 4 files changed, 55 insertions(+), 26 deletions(-)

diffs (161 lines):

diff -r 93abd1961949 -r 453f11f05c86 bin/ps/extern.h
--- a/bin/ps/extern.h   Tue Jan 14 20:22:35 2014 +0000
+++ b/bin/ps/extern.h   Wed Jan 15 08:07:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.33 2010/05/31 03:18:33 rmind Exp $        */
+/*     $NetBSD: extern.h,v 1.34 2014/01/15 08:07:53 mlelstv Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -59,6 +59,7 @@
 void    gname(void *, VARENT *, int);
 void    groups(void *, VARENT *, int);
 void    groupnames(void *, VARENT *, int);
+void    lcputime(void *, VARENT *, int);
 void    logname(void *, VARENT *, int);
 void    longtname(void *, VARENT *, int);
 void    lname(void *, VARENT *, int);
diff -r 93abd1961949 -r 453f11f05c86 bin/ps/keyword.c
--- a/bin/ps/keyword.c  Tue Jan 14 20:22:35 2014 +0000
+++ b/bin/ps/keyword.c  Wed Jan 15 08:07:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: keyword.c,v 1.53 2009/10/21 21:11:57 rmind Exp $       */
+/*     $NetBSD: keyword.c,v 1.54 2014/01/15 08:07:53 mlelstv Exp $     */
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)keyword.c  8.5 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: keyword.c,v 1.53 2009/10/21 21:11:57 rmind Exp $");
+__RCSID("$NetBSD: keyword.c,v 1.54 2014/01/15 08:07:53 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -149,6 +149,7 @@
        VAR3("logname", "login", ALIAS),
        VAR6("lstart", "STARTED", LJUST, lstarted, POFF(p_ustart_sec), UINT32),
        VAR4("lstate", "STAT", LJUST|LWP, lstate),
+       VAR6("ltime", "LTIME", LWP, lcputime, 0, CPUTIME),
        PUVAR("majflt", "MAJFLT", 0, p_uru_majflt, UINT64, PRIu64),
        PUVAR("minflt", "MINFLT", 0, p_uru_minflt, UINT64, PRIu64),
        PUVAR("msgrcv", "MSGRCV", 0, p_uru_msgrcv, UINT64, PRIu64),
diff -r 93abd1961949 -r 453f11f05c86 bin/ps/print.c
--- a/bin/ps/print.c    Tue Jan 14 20:22:35 2014 +0000
+++ b/bin/ps/print.c    Wed Jan 15 08:07:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: print.c,v 1.120 2012/03/20 18:42:28 matt Exp $ */
+/*     $NetBSD: print.c,v 1.121 2014/01/15 08:07:53 mlelstv Exp $      */
 
 /*
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)print.c    8.6 (Berkeley) 4/16/94";
 #else
-__RCSID("$NetBSD: print.c,v 1.120 2012/03/20 18:42:28 matt Exp $");
+__RCSID("$NetBSD: print.c,v 1.121 2014/01/15 08:07:53 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -1012,29 +1012,11 @@
        intprintorsetwidth(v, l->l_cpuid, mode);
 }
 
-void
-cputime(void *arg, VARENT *ve, int mode)
+static void
+cputime1(int32_t secs, int32_t psecs, VAR *v, int mode)
 {
-       struct kinfo_proc2 *k;
-       VAR *v;
-       int32_t secs;
-       int32_t psecs;  /* "parts" of a second. first micro, then centi */
        int fmtlen;
 
-       k = arg;
-       v = ve->var;
-
-       /*
-        * This counts time spent handling interrupts.  We could
-        * fix this, but it is not 100% trivial (and interrupt
-        * time fractions only work on the sparc anyway).       XXX
-        */
-       secs = k->p_rtime_sec;
-       psecs = k->p_rtime_usec;
-       if (sumrusage) {
-               secs += k->p_uctime_sec;
-               psecs += k->p_uctime_usec;
-       }
        /*
         * round and scale to 100's
         */
@@ -1066,6 +1048,49 @@
        }
 }
 
+void
+cputime(void *arg, VARENT *ve, int mode)
+{
+       struct kinfo_proc2 *k;
+       VAR *v;
+       int32_t secs;
+       int32_t psecs;  /* "parts" of a second. first micro, then centi */
+
+       k = arg;
+       v = ve->var;
+
+       /*
+        * This counts time spent handling interrupts.  We could
+        * fix this, but it is not 100% trivial (and interrupt
+        * time fractions only work on the sparc anyway).       XXX
+        */
+       secs = k->p_rtime_sec;
+       psecs = k->p_rtime_usec;
+       if (sumrusage) {
+               secs += k->p_uctime_sec;
+               psecs += k->p_uctime_usec;
+       }
+
+       cputime1(secs, psecs, v, mode);
+}
+
+void
+lcputime(void *arg, VARENT *ve, int mode)
+{
+       struct kinfo_lwp *l;
+       VAR *v;
+       int32_t secs;
+       int32_t psecs;  /* "parts" of a second. first micro, then centi */
+
+       l = arg;
+       v = ve->var;
+
+       secs = l->l_rtime_sec;
+       psecs = l->l_rtime_usec;
+
+       cputime1(secs, psecs, v, mode);
+}
+
 double
 getpcpu(const struct kinfo_proc2 *k)
 {
diff -r 93abd1961949 -r 453f11f05c86 bin/ps/ps.1
--- a/bin/ps/ps.1       Tue Jan 14 20:22:35 2014 +0000
+++ b/bin/ps/ps.1       Wed Jan 15 08:07:53 2014 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ps.1,v 1.101 2012/06/03 21:42:44 joerg Exp $
+.\"    $NetBSD: ps.1,v 1.102 2014/01/15 08:07:53 mlelstv Exp $
 .\"
 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
 .\"    The Regents of the University of California.  All rights reserved.
@@ -540,6 +540,8 @@
 time started
 .It Ar lstate
 symbolic LWP state
+.It Ar ltime
+CPU time of the LWP
 .It Ar majflt
 total page faults
 .It Ar minflt



Home | Main Index | Thread Index | Old Index