Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Previous: CPU Time, Up: Processor And CPU Time


21.3.2 Processor Time Inquiry

The times function returns information about a process' consumption of processor time in a struct tms object, in addition to the process' CPU time. See Time Basics. You should include the header file sys/times.h to use this facility.

— Data Type: struct tms

The tms structure is used to return information about process times. It contains at least the following members:

clock_t tms_utime
This is the total processor time the calling process has used in executing the instructions of its program.
clock_t tms_stime
This is the processor time the system has used on behalf of the calling process.
clock_t tms_cutime
This is the sum of the tms_utime values and the tms_cutime values of all terminated child processes of the calling process, whose status has been reported to the parent process by wait or waitpid; see Process Completion. In other words, it represents the total processor time used in executing the instructions of all the terminated child processes of the calling process, excluding child processes which have not yet been reported by wait or waitpid.
clock_t tms_cstime
This is similar to tms_cutime, but represents the total processor time system has used on behalf of all the terminated child processes of the calling process.

All of the times are given in numbers of clock ticks. Unlike CPU time, these are the actual amounts of time; not relative to any event. See Creating a Process.

— Function: clock_t times (struct tms *buffer)

The times function stores the processor time information for the calling process in buffer.

The return value is the calling process' CPU time (the same value you get from clock(). times returns (clock_t)(-1) to indicate failure.

Portability Note: The clock function described in CPU Time is specified by the ISO C standard. The times function is a feature of POSIX.1. In the GNU system, the CPU time is defined to be equivalent to the sum of the tms_utime and tms_stime fields returned by times.


 
 
  Published under the terms of the GNU General Public License Design by Interspire