From e1ba86c9364f65505457acbcb16036a6acad4ee4 Mon Sep 17 00:00:00 2001 From: eadler Date: Fri, 1 Jun 2018 05:51:40 +0000 Subject: [PATCH] top(1): Display of TID when using 'H' flag Some users prefer seeing the TID when viewing individual threads. This makes sense as the PID will be the same for multiple entries. An attempt was made to include both, but there is insufficient room. As such, using the TID. While here, rename the header variables to be more understandable. Discussed with: mmacy Reported on: 2009-10-07 --- usr.bin/top/machine.c | 18 +++++++++--------- usr.bin/top/top.1 | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 0f31d87ce46b..06889fd07b44 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -97,18 +97,18 @@ static char io_header[] = #define io_Proc_format \ "%5d%*s %-*.*s %6ld %6ld %6ld %6ld %6ld %6ld %6.2f%% %.*s" -static char smp_header_thr[] = +static char smp_header_thr_and_pid[] = " PID%*s %-*.*s THR PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND"; -static char smp_header[] = - " PID%*s %-*.*s " "PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND"; +static char smp_header_tid_only[] = + " THR%*s %-*.*s " "PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND"; #define smp_Proc_format \ "%5d%*s %-*.*s %s%3d %4s%7s %6s%*.*s %-6.6s %2d%7s %6.2f%% %.*s" -static char up_header_thr[] = +static char up_header_thr_and_pid[] = " PID%*s %-*.*s THR PRI NICE SIZE RES%*s STATE TIME %7s COMMAND"; -static char up_header[] = - " PID%*s %-*.*s " "PRI NICE SIZE RES%*s STATE TIME %7s COMMAND"; +static char up_header_tid_only[] = + " THR%*s %-*.*s " "PRI NICE SIZE RES%*s STATE TIME %7s COMMAND"; #define up_Proc_format \ "%5d%*s %-*.*s %s%3d %4s%7s %6s%*.*s %-6.6s%.0d%7s %6.2f%% %.*s" @@ -436,8 +436,8 @@ format_header(char *uname_field) * separate lines). */ prehead = smpmode ? - (ps.thread ? smp_header : smp_header_thr) : - (ps.thread ? up_header : up_header_thr); + (ps.thread ? smp_header_tid_only : smp_header_thr_and_pid) : + (ps.thread ? up_header_tid_only : up_header_thr_and_pid); snprintf(Header, sizeof(Header), prehead, jidlength, ps.jail ? " JID" : "", namelength, namelength, uname_field, @@ -1145,7 +1145,7 @@ format_next_process(caddr_t xhandle, char *(*get_userid)(int), int flags) (int)(sizeof(thr_buf) - 2), pp->ki_numthreads); snprintf(fmt, sizeof(fmt), proc_fmt, - pp->ki_pid, + (ps.thread) ? pp->ki_tid : pp->ki_pid, jidlength, jid_buf, namelength, namelength, (*get_userid)(pp->ki_ruid), thr_buf, diff --git a/usr.bin/top/top.1 b/usr.bin/top/top.1 index a98c0d203c66..8b56af89f8db 100644 --- a/usr.bin/top/top.1 +++ b/usr.bin/top/top.1 @@ -331,6 +331,7 @@ command. .TP .B H Toggle the display of threads. +Also toggles the display of PID or TID. .TP .B i (or