[comp.os.minix] Improved accounting

brucee@runx.ips.oz (Bruce Evans) (07/09/88)

Here's a better version of kernel/clock.c accounting(). It greatly increases
the usefulness of the F1 dump by accumulating times in the tasks and low
users. Output from my system now is

proc         user       -sys-
TTY          7311           0
PRINTR          0           0         (not connected)
WINCHE       1139           0
FLOPPY        742           0
RAMDSK          0           0         (not connected)
CLOCK         414           0
SYS          1648           0
SWITCH       4342           0         (sys_call() and hidden on standard Minix)
IDLE      1018490        5694         (HARDWARE on standard Minix)
MM            312           0
FS           3809           0
users                                 (current times only, not much use)

The times accumulated by HARDWARE are particulary interesting. The user
time is the time idle since the system started. The system time is
the time spent servicing interrupts while idle. This belongs to a user but
is too expensive to account for. System time is always understated as a
result, about 30% in this example. Your results may vary. My system has
been modified to make HARDWARE into the real task IDLE which still has
process magic-number -1 though it should really be > all real users for
consistent magic. The SWITCH results from other more extensive modifications
on my system. The switching overhead is over 20%. I once measured the _CLOCK_
overhead as 15 to 20% but that was on a slow PC and the above on a middling
386 and other changes to the clock routine had reduced the PC overhead to 5%.

There would be only 2 lines different except for the comment. I'm tired of
diffs and the line numbers wouldn't match because of other changes.

----
PRIVATE accounting()
{
/*
 * Update user and system accounting times.
 * First charge the current process for user time.
 * If the current process is not the billable process (usually because it is
 * a task), charge the billable process for system time as well.
 * Thus the unbillable tasks' user time is the billable users' system time.
 */

  bill_ptr->user_time++;
  if (prev_proc < LOW_USER)
	bill_ptr->sys_time++;
}
----

Bruce Evans
Internet: brucee@runx.ips.oz.au    UUCP: uunet!runx.ips.oz.au!brucee