Updating System Statistics
The kernel, among the other time-related duties, must periodically collect various data used for:
Checking the CPU resource limit of the running processes
Updating statistics about the local CPU workload
Computing the average system load
Profiling the kernel code
Updating Local CPU Statistics
We have mentioned that the update_process_times( )
function is
invoked—either by the global timer interrupt handler on uniprocessor
systems or by the local timer interrupt handler in multiprocessor
systems—to update some kernel statistics. This function performs the
following steps:
Checks how long the current process has been running. Depending on whether the current process was running in User Mode or in Kernel Mode when the timer interrupt occurred, invokes either
account_user_time( )
oraccount_system_time( )
. Each of these functions performs essentially the following steps:Updates either the
utime
field (ticks spent in User Mode) or thestime
field (ticks spent in Kernel Mode) of the current process descriptor. Two additional fields calledcutime
andcstime
are provided in the process descriptor to count the number of CPU ticks spent by the process children in User Mode and Kernel Mode, respectively. For reasons of efficiency, these fields are not updated byupdate_process_times( )
, but rather when the parent process queries the state of one of its children (see the section "Destroying Processes" in Chapter 3).Checks whether the total CPU time limit has been reached; ...
Get Understanding the Linux Kernel, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.