CPU usage information

Another nice thing that's stored in the structure is a set of CPU usage (and time-related) members:

start_time
The time, in nanoseconds since January 1, 1970, when the process was started.
utime
The number of nanoseconds spent running in user space (see below).
stime
The number of nanoseconds spent running in system space (see below).
cutime and cstime
Accumulated time that terminated children have run, in nanoseconds, in user and system space.

The start_time is useful not only for its obvious “when was this process started” information, but also to detect reused process IDs. For example, if a process ID X is running and then dies, eventually the same process ID (X) will be handed out to a new (and hence completely different) process. By comparing the two process's start_time members, it's possible to determine that the process ID has in fact been reused.

The utime and stime values are calculated very simply—if the processor is executing in user space when the timer tick interrupt occurs, time is allocated to the utime variable; otherwise, it's allocated to the stime variable. The granularity of the time interval is equivalent to the time tick (e.g., 1 millisecond on an x86 platform with the default clock setting).