From 1f40f9f21f0354c37a735df8bccb46f15ab0b5d3 Mon Sep 17 00:00:00 2001 From: Philip Guenther Date: Mon, 14 Jan 2013 21:34:00 +0000 Subject: When showing threads, say so. Fix up some comments and names at the same time. original diff by zhuk@ ok jsing@ mpi@ zhuk@ --- usr.bin/top/display.c | 31 +++++++++++-------------------- usr.bin/top/display.h | 4 ++-- usr.bin/top/top.c | 7 ++++--- 3 files changed, 17 insertions(+), 25 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/top/display.c b/usr.bin/top/display.c index 60a6f7d64ef..c91afc2cd72 100644 --- a/usr.bin/top/display.c +++ b/usr.bin/top/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.43 2012/06/05 18:52:53 brynet Exp $ */ +/* $OpenBSD: display.c,v 1.44 2013/01/14 21:33:59 guenther Exp $ */ /* * Top users/processes display for Unix @@ -262,36 +262,27 @@ i_timeofday(time_t * tod) } /* - * *_procstates(total, brkdn, names) - print the process summary line + * *_procstates(total, states, threads) - print the process/thread summary line * * Assumptions: cursor is at the beginning of the line on entry */ void -i_procstates(int total, int *brkdn) +i_procstates(int total, int *states, int threads) { if (screen_length > 2 || !smart_terminal) { - int i; char procstates_buffer[MAX_COLS]; move(1, 0); clrtoeol(); - /* write current number of processes and remember the value */ - printwp("%d processes:", total); - - if (smart_terminal) - move(1, 15); - else { - /* put out enough spaces to get to column 15 */ - i = digits(total); - while (i++ < 4) { - if (putchar(' ') == EOF) - exit(1); - } - } + /* write current number of procs and remember the value */ + if (threads == Yes) + printwp("%d threads: ", total); + else + printwp("%d processes: ", total); /* format and print the process state summary */ - summary_format(procstates_buffer, sizeof(procstates_buffer), brkdn, - procstate_names); + summary_format(procstates_buffer, sizeof(procstates_buffer), + states, procstate_names); addstrp(procstates_buffer); putn(); @@ -299,7 +290,7 @@ i_procstates(int total, int *brkdn) } /* - * *_cpustates(states, names) - print the cpu state percentages + * *_cpustates(states) - print the cpu state percentages * * Assumptions: cursor is on the PREVIOUS line */ diff --git a/usr.bin/top/display.h b/usr.bin/top/display.h index 5e23c3aa3b9..bd4711c5bd2 100644 --- a/usr.bin/top/display.h +++ b/usr.bin/top/display.h @@ -1,4 +1,4 @@ -/* $OpenBSD: display.h,v 1.11 2007/11/22 11:01:04 otto Exp $ */ +/* $OpenBSD: display.h,v 1.12 2013/01/14 21:33:59 guenther Exp $ */ /* * Top users/processes display for Unix @@ -38,7 +38,7 @@ int display_resize(void); void i_loadave(int, double *); void u_loadave(int, double *); void i_timeofday(time_t *); -void i_procstates(int, int *); +void i_procstates(int, int *, int); void u_procstates(int, int *); void i_cpustates(int64_t *); void u_cpustates(int64_t *); diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index 377c9834638..086a830e1d7 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -1,4 +1,4 @@ -/* $OpenBSD: top.c,v 1.79 2012/06/08 13:41:16 lum Exp $ */ +/* $OpenBSD: top.c,v 1.80 2013/01/14 21:33:59 guenther Exp $ */ /* * Top users/processes display for Unix @@ -452,8 +452,9 @@ restart: time(&curr_time); i_timeofday(&curr_time); - /* display process state breakdown */ - i_procstates(system_info.p_total, system_info.procstates); + /* display process/threads state breakdown */ + i_procstates(system_info.p_total, system_info.procstates, + ps.threads); /* display the cpu state percentage breakdown */ i_cpustates(system_info.cpustates); -- cgit v1.2.3