-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)
{
Index: bin/ps/ps.1
===================================================================
RCS file: /cvsroot/src/bin/ps/ps.1,v
retrieving revision 1.101
diff -u -r1.101 ps.1
--- bin/ps/ps.1 3 Jun 2012 21:42:44 -0000 1.101
+++ bin/ps/ps.1 15 Jan 2014 07:57:12 -0000
@@ -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
Index: bin/ps/ps.c
===================================================================
RCS file: /cvsroot/src/bin/ps/ps.c,v
retrieving revision 1.78
diff -u -r1.78 ps.c
--- bin/ps/ps.c 7 May 2012 13:14:31 -0000 1.78
+++ bin/ps/ps.c 15 Jan 2014 07:57:12 -0000
@@ -136,7 +136,7 @@
char jfmt[] = "user pid ppid pgid sess jobc state tt time command";
char lfmt[] = "uid pid ppid cpu pri nice vsz rss wchan state tt time command";
char sfmt[] = "uid pid ppid cpu lid nlwp pri nice vsz rss wchan lstate tt "
- "time command";
+ "ltime command";
char ufmt[] = "user pid %cpu %mem vsz rss tt state start time command";
char vfmt[] = "pid state time sl re pagein vsz rss lim tsiz %cpu %mem command";