Let top distinguish kernel time, explain in manpage.

This commit is contained in:
Ben Gras 2006-03-17 10:04:14 +00:00
parent 96783ed1f7
commit 7fb338622b
2 changed files with 22 additions and 11 deletions

View file

@ -110,7 +110,7 @@ void print_procs(int maxlines,
struct mproc *mproc)
{
int p, nprocs;
int idleticks = 0;
int idleticks = 0, kernelticks = 0;
for(p = nprocs = 0; p < PROCS; p++) {
if(proc2[p].p_rts_flags & SLOT_FREE)
@ -127,13 +127,19 @@ void print_procs(int maxlines,
idleticks = tick_procs[nprocs].ticks;
continue;
}
/* Kernel task time, not counting IDLE */
if(proc2[p].p_nr < 0)
kernelticks += tick_procs[nprocs].ticks;
nprocs++;
}
qsort(tick_procs, nprocs, sizeof(tick_procs[0]), cmp_ticks);
printf("CPU states: %5.2f%% user, %5.2f%% idle\n\n",
100.0*(dt-idleticks)/dt, 100.0*idleticks/dt);
printf("CPU states: %5.2f%% user, %5.2f%% kernel, %5.2f%% idle\n\n",
100.0*(dt-idleticks-kernelticks)/dt,
100.0*(kernelticks)/dt,
100.0*idleticks/dt);
maxlines -= 2;
printf(" PID USERNAME PRI NICE SIZE STATE TIME CPU COMMAND\n");

View file

@ -1,20 +1,25 @@
.TH TOP 1
.SH NAME
top \- show processes sorted by cpu usage
top \- show processes sorted by CPU usage
.SH SYNOPSIS
.B top
.SH DESCRIPTION
Top displays a list of all running processes, once every update interval
(currently 5 seconds). It is sorted by the cpu usage of the processes in
the last interval. The first display is the cpu usage of processes since
(currently 5 seconds). It is sorted by the CPU usage of the processes in
the last interval. The first display is the CPU usage of processes since
the boot time.
At the top of the screen, top shows the current system load averages in
the last 1-minute, 5-minute and 15-minute intervals. Then, over the
last top interval it displays: the number of alive, active, and sleeping
processes; memory free; and cpu usage.
processes; memory free; and CPU usage. CPU usage is split into
user, kernel and idle time. Kernel time is time spent by kernel tasks,
that is tasks that run in kernel mode in kernel address space. User
time is all other CPU time, including system processes such as servers
and drivers, as top can't see the difference between a user process and
a server or driver.
Then it displays all the alive processes sorted by cpu usage in the last
Then it displays all the alive processes sorted by CPU usage in the last
interval, with a number of fields for every process. Currently the
following fields are displayed:
.PP
@ -41,8 +46,8 @@ following fields are displayed:
STATE
RUN if the process is runnable, empty if blocking.
TIME
Total number of cpu time spent in the process itself. So-called
system time (cpu time spent on behalf of this process by another
Total number of CPU time spent in the process itself. So-called
system time (CPU time spent on behalf of this process by another
process, generally a system process) is not seen here.
CPU
Percentage of time that the process was running in the last interval.
@ -54,7 +59,7 @@ following fields are displayed:
.SH BUGS
This is a from-scratch reimplementation of top for MINIX 3.
Many features (such as interactive commands) are not implemented.
Sorting is only done by cpu usage currently. Displayed state is
Sorting is only done by CPU usage currently. Displayed state is
only RUN or empty.
.SH AUTHOR
Ben Gras (beng@few.vu.nl)