[Sussex] processor usage as shown by top

Rupert Swarbrick rupert.swarbrick at lineone.net
Sun Aug 22 15:15:41 UTC 2004

| If I look at top while running a compile I see in the heading line:
| Cpu(s):  97.0% user, 3.0%, system, 0.0% nice, 0.0% idle
| In the body at the top of the list I see cc1 using about 12.0% and nothing
| much else reporting any processor usage.
| I would have expected the list of percentages to add up to roughly the
| "user" figure.
| Can anyone explain what  these numbers mean?

If you tell top to refresh more often, your cc1 will spend less time shown on the terminal, but will use more like 85% CPU or whatever. The reason (I think) is that the kernel reports the total user/sys/nice percentages, whereas top + co. have to work out the process specific ones themselves from 'CPU time used so far' figures. If top is only refreshing once every 2 seconds, and cc1 has been running 80 milliseconds so far when top refreshes, it will only have used a minute percentage of the CPU time in the last 2 seconds. All the rest was used by the previous incarnation of cc1 which finished when top wasn't looking.
That may be right at any rate - that's what I decided when I noticed a few months ago, but I never did bother to look it up.

More information about the Sussex mailing list