Skip to Content
Understanding the Linux Kernel, Second Edition
book

Understanding the Linux Kernel, Second Edition

by Daniel P. Bovet, Marco Cesati
December 2002
Intermediate to advanced
784 pages
27h 7m
English
O'Reilly Media, Inc.
Content preview from Understanding the Linux Kernel, Second Edition

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:

  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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Understanding the Linux Kernel, 3rd Edition

Understanding the Linux Kernel, 3rd Edition

Daniel P. Bovet, Marco Cesati
Understanding the Linux Kernel

Understanding the Linux Kernel

Daniel P. Bovet, Marco Cesati
Linux Kernel Programming

Linux Kernel Programming

Kaiwan N. Billimoria

Publisher Resources

ISBN: 0596002130Catalog PageErrata