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:
1. Updates the per_cpu_utime field of current's process descriptor, which stores the number of ticks during which the process has been running in User Mode.
2. Updates the per_cpu_stime field of current's process descriptor, which stores the number of ticks during which the process has been running in Kernel Mode.
3. Invokes do_process_times( ), which checks whether the total CPU time limit has been reached; if so, it sends sigxcpu and sigkill signals to current. Section 3.2.5 describes how the limit is controlled by the rlim[RLiMiT_CPU].rlim_cur field of each process descriptor.
Two additional fields called times.tms_cutime and times.tms_cstime 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 by update_one_process( ), but rather when the parent process queries the state of one of its children (see Section 3.5).
Continue reading here: Keeping Track of System Load
Was this article helpful?