summaryrefslogtreecommitdiffstats
path: root/usr.bin/top
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2011-07-18 17:33:08 +0000
committerjhb <jhb@FreeBSD.org>2011-07-18 17:33:08 +0000
commit4e1a6d0e6744fbd594114870804c3a5062815280 (patch)
treec9ca0ce831e01fabc0898005bf23fb41dcc1c5e9 /usr.bin/top
parent9a6ff5ad378cfaaa99c5162e2b0f6e4cb6a3c796 (diff)
downloadFreeBSD-src-4e1a6d0e6744fbd594114870804c3a5062815280.zip
FreeBSD-src-4e1a6d0e6744fbd594114870804c3a5062815280.tar.gz
- Export each thread's individual resource usage in in struct kinfo_proc's
ki_rusage member when KERN_PROC_INC_THREAD is passed to one of the process sysctls. - Correctly account for the current thread's cputime in the thread when doing the runtime fixup in calcru(). - Use TIDs as the key to lookup the previous thread to compute IO stat deltas in IO mode in top when thread display is enabled. Reviewed by: kib Approved by: re (kib)
Diffstat (limited to 'usr.bin/top')
-rw-r--r--usr.bin/top/machine.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index 02dc847..1f8a002 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -235,6 +235,7 @@ static int *pcpu_cpu_states;
static int compare_jid(const void *a, const void *b);
static int compare_pid(const void *a, const void *b);
+static int compare_tid(const void *a, const void *b);
static const char *format_nice(const struct kinfo_proc *pp);
static void getsysctl(const char *name, void *ptr, size_t len);
static int swapmode(int *retavail, int *retfree);
@@ -557,7 +558,7 @@ get_old_proc(struct kinfo_proc *pp)
* cache it.
*/
oldpp = bsearch(&pp, previous_pref, previous_proc_count,
- sizeof(*previous_pref), compare_pid);
+ sizeof(*previous_pref), ps.thread ? compare_tid : compare_pid);
if (oldpp == NULL) {
pp->ki_udata = NOPROC;
return (NULL);
@@ -652,7 +653,7 @@ get_process_info(struct system_info *si, struct process_select *sel,
previous_pref[i] = &previous_procs[i];
bcopy(pbase, previous_procs, nproc * sizeof(*previous_procs));
qsort(previous_pref, nproc, sizeof(*previous_pref),
- compare_pid);
+ ps.thread ? compare_tid : compare_pid);
}
previous_proc_count = nproc;
@@ -1059,6 +1060,18 @@ compare_pid(const void *p1, const void *p2)
return ((*pp1)->ki_pid - (*pp2)->ki_pid);
}
+static int
+compare_tid(const void *p1, const void *p2)
+{
+ const struct kinfo_proc * const *pp1 = p1;
+ const struct kinfo_proc * const *pp2 = p2;
+
+ if ((*pp2)->ki_tid < 0 || (*pp1)->ki_tid < 0)
+ abort();
+
+ return ((*pp1)->ki_tid - (*pp2)->ki_tid);
+}
+
/*
* proc_compare - comparison function for "qsort"
* Compares the resource consumption of two processes using five
OpenPOWER on IntegriCloud