[Nottingham] CPU time

Michael Simms michael at linuxgamepublishing.com
Thu Oct 2 08:11:30 UTC 2008


Sure it is, don't bother about the second lot, simply open a pipe before
forking the children and report back up the pipe the current processes
total. That way each layer of the application can get regular reports
from the sum of its children or for each process in its tree, however
you implement the data coming up the pipe.

On Wed, 2008-10-01 at 15:22 +0100, Martin wrote:
> Michael Simms wrote:
> > Erm, someone was asking how to get the CPU time of a process and/or its
> > children. I just bumped into the times() function in section 2 of the
> > manual, and it seems to do what people were looking for.
> 
> Thanks for the note. But...
> 
> http://linux.die.net/man/2/times
> 
> "Times for *terminated children* (and their descendants) is added in at
> the moment wait(2) or waitpid(2) returns their process ID. In
> particular, times of grandchildren that the children did not wait for
> are never seen."
> 
> "All times reported are in clock ticks."
> 
> See Also
> time(1), getrusage(2), wait(2), clock(3), sysconf(3), time(7)
> 
> 
> ... Fine for system accounting. No good for checking up on 'progress' of
> various process threads and /gracefully/ terminating any that have
> exceeded limits set by the application itself.
> 
> 
> There's "ulimit" and so on but that is rather too blunt an instrument to
> use against a background task that is trying to be very 'nice'...
> 
> 
> Looks like this is a feature that isn't enough of a problem to be
> included in the kernel.
> 
> Still musing.
> 
> Cheers,
> Martin
> 
> 
-- 
Michael Simms - CEO Linux Game Publishing LTD
http://www.linuxgamepublishing.com



More information about the Nottingham mailing list