|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Make top display thread IDsHello,
I was using "top -H" to display all the different threads on my system. I then wanted to use cpuset to pin a thread to a particular core, however, I couldn't find the thread ID. So I've hacked top to display thread IDs. Hopefully this patch is useful to something, and perhaps it should be included with FreeBSD. I'd be grateful for any feedback or suggestions. thanks Andrew Index: usr.bin/top/machine.c =================================================================== --- usr.bin/top/machine.c (revision 197611) +++ usr.bin/top/machine.c (working copy) @@ -108,18 +108,18 @@ static char smp_header_thr[] = " PID%s %-*.*s THR PRI NICE SIZE RES STATE C TIME %6s COMMAND"; static char smp_header[] = - " PID%s %-*.*s " "PRI NICE SIZE RES STATE C TIME %6s COMMAND"; + " PID TID%s %-*.*s PRI NICE SIZE RES STATE C TIME %6s COMMAND"; #define smp_Proc_format \ - "%5d%s %-*.*s %s%3d %4s%7s %6s %-6.6s %2d%7s %5.2f%% %.*s" + "%5d%s%s %-*.*s %s%3d %4s%7s %6s %-6.6s %2d%7s %5.2f%% %.*s" static char up_header_thr[] = " PID%s %-*.*s THR PRI NICE SIZE RES STATE TIME %6s COMMAND"; static char up_header[] = - " PID%s %-*.*s " "PRI NICE SIZE RES STATE TIME %6s COMMAND"; + " PID TID%s %-*.*s PRI NICE SIZE RES STATE TIME %6s COMMAND"; #define up_Proc_format \ - "%5d%s %-*.*s %s%3d %4s%7s %6s %-6.6s%.0d%7s %5.2f%% %.*s" + "%5d%s%s %-*.*s %s%3d %4s%7s %6s %-6.6s%.0d%7s %5.2f%% %.*s" /* process state names for the "STATE" column of the display */ @@ -757,7 +757,7 @@ int state; struct rusage ru, *rup; long p_tot, s_tot; - char *proc_fmt, thr_buf[6], jid_buf[6]; + char *proc_fmt, tid_buf[8], thr_buf[6], jid_buf[6]; char *cmdbuf = NULL; char **args; @@ -942,14 +942,19 @@ /* format this entry */ proc_fmt = smpmode ? smp_Proc_format : up_Proc_format; - if (ps.thread != 0) + if (ps.thread) { thr_buf[0] = '\0'; - else + snprintf(tid_buf, sizeof(tid_buf), "%*d", + sizeof(tid_buf) - 1, pp->ki_tid); + } else { + tid_buf[0] = '\0'; snprintf(thr_buf, sizeof(thr_buf), "%*d ", sizeof(thr_buf) - 2, pp->ki_numthreads); + } sprintf(fmt, proc_fmt, pp->ki_pid, + tid_buf, jid_buf, namelength, namelength, (*get_userid)(pp->ki_ruid), thr_buf, _______________________________________________ freebsd-hackers@... mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..." |
|
|
Re: Make top display thread IDsIf a thread has a name, top -H will display it in parentheses after
the executable name. One option would be to print the tid there if the thread has no name. _______________________________________________ freebsd-hackers@... mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..." |
|
|
Re: Make top display thread IDs2009/10/7 Ryan Stone <rysto32@...>:
> If a thread has a name, top -H will display it in parentheses after > the executable name. One option would be to print the tid there if > the thread has no name. > Thanks for your suggestion. I would like the TID always to be displayed, so displaying it when there is no name wouldn't work for me. If you haven't looked at the patch I placed the TID directly after the PID column (when displaying threads in -H mode). thanks Andrew _______________________________________________ freebsd-hackers@... mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..." |
| Free embeddable forum powered by Nabble | Forum Help |