V7, VAX-UNIX profiling bug

sri-unix!dan at BBN-UNIX sri-unix!dan at BBN-UNIX
Wed Mar 10 19:32:18 AEST 1982


There's an obscure bug in V7 profiling which has been carried
into Berkeley VAX-UNIX. The bug has to do with profiling a child
of the process that profiling was turned on in. Under this circumstance,
the fork system call is shown--in the child--as taking an enormous amount
of time, rendering the percentages meaningless. The reason is the
way V7 profiles system calls; it finds out the amount of cpu time
used so far before doing the system call, and then, afterwards,
subtracts this from the current cpu time. This difference
is then added to the appropriate profiling slot. Unfortunately,
the current cpu time of a freshly created process is zero, so the
subtraction produces a negative number which the profiling software
treats as hugely positive.

The simplest fix is to change trap() to check whether the
old cpu time is more than the new, and do nothing if this is
the case. This makes forks "free" to the child, while still
showing their expense in the parent process, which is probably
the right thing.




More information about the Comp.unix.wizards mailing list