Module Name:    src
Committed By:   mlelstv
Date:           Wed Jan 15 08:07:53 UTC 2014

Modified Files:
        src/bin/ps: extern.h keyword.c print.c ps.1

Log Message:
Add an LTIME column that prints lwp cputime.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/bin/ps/extern.h
cvs rdiff -u -r1.53 -r1.54 src/bin/ps/keyword.c
cvs rdiff -u -r1.120 -r1.121 src/bin/ps/print.c
cvs rdiff -u -r1.101 -r1.102 src/bin/ps/ps.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ps/extern.h
diff -u src/bin/ps/extern.h:1.33 src/bin/ps/extern.h:1.34
--- src/bin/ps/extern.h:1.33	Mon May 31 03:18:33 2010
+++ src/bin/ps/extern.h	Wed Jan 15 08:07:53 2014
@@ -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 @@ double	 getpmem(const struct kinfo_proc2
 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);

Index: src/bin/ps/keyword.c
diff -u src/bin/ps/keyword.c:1.53 src/bin/ps/keyword.c:1.54
--- src/bin/ps/keyword.c:1.53	Wed Oct 21 21:11:57 2009
+++ src/bin/ps/keyword.c	Wed Jan 15 08:07:53 2014
@@ -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 @@ VAR var[] = {
 	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),

Index: src/bin/ps/print.c
diff -u src/bin/ps/print.c:1.120 src/bin/ps/print.c:1.121
--- src/bin/ps/print.c:1.120	Tue Mar 20 18:42:28 2012
+++ src/bin/ps/print.c	Wed Jan 15 08:07:53 2014
@@ -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 @@ cpuid(void *arg, VARENT *ve, int mode)
 	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 @@ cputime(void *arg, VARENT *ve, int mode)
 	}
 }
 
+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)
 {

Index: src/bin/ps/ps.1
diff -u src/bin/ps/ps.1:1.101 src/bin/ps/ps.1:1.102
--- src/bin/ps/ps.1:1.101	Sun Jun  3 21:42:44 2012
+++ src/bin/ps/ps.1	Wed Jan 15 08:07:53 2014
@@ -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 @@ login name of user who started the proce
 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

Reply via email to