Updating System Statistics
The kernel, among the other time-related duties, must periodically collect several data used to:
Checking the CPU resource limit of the running processes
Computing the average system load
Profiling the kernel code
Checking the Current Process CPU Resource Limit
The
update_process_times( ) function (invoked by
either the PIT’s timer interrupt handler on
uniprocessor systems or the local timer interrupt handler in
multiprocessor systems) updates some kernel statistics stored in the
kstat variable of type
kernel_stat; it then invokes
update_one_process( ) to update some fields
storing statistics that can be exported to user programs through the
times( ) system call. In particular, a distinction
is made between CPU time spent in User Mode and in Kernel Mode. The
function performs the following actions:
Updates the
per_cpu_utimefield ofcurrent’s process descriptor, which stores the number of ticks during which the process has been running in User Mode.Updates the
per_cpu_stimefield ofcurrent’s process descriptor, which stores the number of ticks during which the process has been running in Kernel Mode.Invokes
do_process_times( ), which checks whether the total CPU time limit has been reached; if so, it sendsSIGXCPUandSIGKILLsignals tocurrent. Section 3.2.5 describes how the limit is controlled by therlim[RLIMIT_CPU].rlim_curfield of each process descriptor.
Two additional fields called times.tms_cutime and
times.tms_cstime are provided in the process ...