From 7fb338622b4d655bbb506858e08617394fc532af Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Fri, 17 Mar 2006 10:04:14 +0000 Subject: [PATCH] Let top distinguish kernel time, explain in manpage. --- commands/simple/top.c | 12 +++++++++--- man/man1/top.1 | 21 +++++++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/commands/simple/top.c b/commands/simple/top.c index ea67bf707..4b37bfdda 100644 --- a/commands/simple/top.c +++ b/commands/simple/top.c @@ -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"); diff --git a/man/man1/top.1 b/man/man1/top.1 index 8edb744c2..6f6abbb07 100644 --- a/man/man1/top.1 +++ b/man/man1/top.1 @@ -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) -- 2.44.0