children CPU times
Henry Cejtin
henry@sourcelight.com
Fri, 22 Jun 2001 18:01:20 -0500
Ah, I was not quite right about the child times: the child times includes any
grand children times. This explains why it includes children of the gcc
(like the assembler and the loader).
Things are a bit complicated by the following strange detail of Unix: every
process has a parent process, which is the process that will get your time,
on your exit, as part of its children's times. (It is also the process that
can wait for you to exit and get your status.) If your parent exits while
you are still running, then your parent process gets set to process 1
(typically init). This init process is always waiting for things to finish,
and when it gets one it knows nothing about (not a child, but a long
descended grand* child), it just ignores it.
The effect here is that if I have a child who has a child, and that grand
child of mine does a lot of expensive computation, and if that grand child
outlives my direct child, then all of its running time, when it exits, will
be added to process 1's child times, not mine.
The reason for the strangeness is that if your parent exits before you do,
then no one would be waiting for your exit status. To make things cleaner in
the kernel, you are assigned to some one who will always accept your exit
status (process 1). It also means that the total time of process 1 (and its
children) is the total amount of CPU time used on the machine by all process
that have exited since boot up.