Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Jun 2018 05:51:41 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334474 - head/usr.bin/top
Message-ID:  <201806010551.w515pfoB090926@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Fri Jun  1 05:51:40 2018
New Revision: 334474
URL: https://svnweb.freebsd.org/changeset/base/334474

Log:
  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

Modified:
  head/usr.bin/top/machine.c
  head/usr.bin/top/top.1

Modified: head/usr.bin/top/machine.c
==============================================================================
--- head/usr.bin/top/machine.c	Fri Jun  1 05:48:28 2018	(r334473)
+++ head/usr.bin/top/machine.c	Fri Jun  1 05:51:40 2018	(r334474)
@@ -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_useri
 		    (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,

Modified: head/usr.bin/top/top.1
==============================================================================
--- head/usr.bin/top/top.1	Fri Jun  1 05:48:28 2018	(r334473)
+++ head/usr.bin/top/top.1	Fri Jun  1 05:51:40 2018	(r334474)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806010551.w515pfoB090926>