Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cputime(2) [plan9 man page]

CPUTIME(2)							System Calls Manual							CPUTIME(2)

NAME
cputime, times - cpu time in this process and children SYNOPSIS
#include <u.h> #include <libc.h> int times(long t[4]) double cputime(void) DESCRIPTION
If t is non-null, times fills it in with the number of milliseconds spent in user code, system calls, child processes in user code, and child processes in system calls. Cputime returns the sum of those same times, converted to seconds. Times returns the real time, in mil- liseconds used by the process so far. These functions read /dev/cputime, opening that file when time is first called. SOURCE
/sys/src/libc/9sys SEE ALSO
cons(3) CPUTIME(2)

Check Out this Related Man Page

times(3)						     Library Functions Manual							  times(3)

NAME
times - Gets process and child process times LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <sys/times.h> clock_t times( struct tms *buffer); Programs that are being developed for conformance to the AT&T System V Interface Definition must specify two #include statements, as fol- lows: #include <sys/types.h> #include <sys/times.h> STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: times(): XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to type tms structure space where system time information is stored. DESCRIPTION
The times() function fills the type tms structure space pointed to by the buffer parameter with time-accounting information. All time val- ues reported by this function are in hardware-dependent clock ticks. The times of a terminated child process are included in the tms_cutime and tms_cstime elements of the parent process when a wait function returns the process ID of that terminated child. The tms structure, which is defined in the sys/times.h header file, contains the following members: User time. The CPU time charged while executing user instructions of the calling process. System time. The CPU time charged during system execution on behalf of the calling process. User time, children. The sum of the tms_utime and the tms_cutime times of the child processes. System time, children. The sum of the tms_stime and the tms_cstime times of the child processes. When a child process does not wait for its children, its child-process times are not included in its times. This information comes from the calling process and each of its terminated child processes for which a wait function has been executed. RETURN VALUES
Upon successful completion, the times() function returns the elapsed real time since an arbitrary reference time in the past (for example, system start-up time). The reference time does not change from one invocation of times() within the process to another. The elapsed times are in units of 1/CLK_TCK seconds, where CLK_TCK is processor dependent. For application portability, the value of CLK_TCK should be queried using the sysconf() function (see sysconf(3)). The return value may overflow the possible range of type clock_t values. When the times() function fails, a value of (clock_t)-1 is returned. RELATED INFORMATION
Commands: cc(1) Functions: exec(2), fork(2), getrusage(2), profil(2), stime(3), sysconf(3), time(3), wait(2) Standards: standards(5) delim off times(3)
Man Page

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

echo two command output in the same line

Hi, I try to write script and echo two command at the same line . echo "A" echo "B" How can I pipe above two command at the same line in text file . So, in the output text file , you can see below ??? A B not A B Any sugggestion ??? (4 Replies)
Discussion started by: chuikingman
4 Replies

2. Shell Programming and Scripting

Measure thread execution (in C, unix)

Hi, I have a simulation program which creates two threads and I would like to know if I can measure the time of each individual thread. Threads communicate (I use pthread to manage them) and I want to measure communication time. I found a solution with clock_gettime and CLOCK_THREAD_CPUTIME_ID... (32 Replies)
Discussion started by: Tinkh
32 Replies

3. Shell Programming and Scripting

Checking CPU utilization by db2sysc process

Hi, I am trying to write a script which will fire alert mail to dba ( db2dba) when there process will utilize CPU more than 90%. But I am unable to do so. I am using following command to calucate CPU utilization be db2sysc process : ps -eo pcpu,pid,comm | grep -i db2sysc | awk '{ SUM+=$1;... (6 Replies)
Discussion started by: niteshtheone
6 Replies

4. Programming

calloc fails: 'Cannot allocate memory'

Hi , experts. I work on Linux station (RedHat 5.7), regular user, but have root password. %> uname -a Linux ran1log06 2.6.18-238.1.1.el5 #1 SMP Tue Jan 4 13:32:19 EST 2011 x86_64 x86_64 x86_64 GNU/Linux %> cat /etc/issue Red Hat Enterprise Linux Client release 5.7 (Tikanga) Kernel \r on... (5 Replies)
Discussion started by: baruchgu
5 Replies

5. UNIX for Dummies Questions & Answers

Calculate %Cpu

Hi. For an homework, I have to simulate some part of the PS function. By reading the doc I've been able to find most of it but I don't how I can get the %cpu for each PID. I've read on Internet that I have to do: (utime(t)-utim(t-1))/(cputime(t)-cputime(t-1)) where cputime is the sum of... (2 Replies)
Discussion started by: elnabo
2 Replies

6. Solaris

Oracle DB install failure

Hi all, I'm quite new to Solaris and I've been searching around everywhere to try and find the root of my Oracle DB install problem. It quits immediately when it runs isainfo when it gets a return of 3md64. To me this looks like there is a typo where ever isainfo pulls it's info from, but I... (13 Replies)
Discussion started by: asilv
13 Replies

7. UNIX for Advanced & Expert Users

Timeout procedure for using to much memory or cpu

How hard is it to create some kind of timeout procedure for using to much memory or cpu on a linux/unix server? What would you have to do to do this? (8 Replies)
Discussion started by: cokedude
8 Replies

8. Solaris

The old golden Question - Cpu load vs utilization

Hi all, Load = run queue, process utilizing cpu or waiting for cpu Cpu utilization = % of time that the cpu is busy. Naturally, I am thinking that if I have 1 cpu and my load=1 all the time, my CPU is 100% busy. Now I have 2 CPU thread running and doing prstat -Z, this is what I... (3 Replies)
Discussion started by: javanoob
3 Replies

9. Shell Programming and Scripting

Help with a script that involves processes

Hi everyone! I need to create a bash script that allows me to copy in a file named report_<date>_<time>.csv the list of active processes. <date> and <time> are the date and the time of the system when you create the file .csv How can I create that? I have no idea how to do it :confused: ... (6 Replies)
Discussion started by: Novia96
6 Replies

10. Shell Programming and Scripting

How to restart shell script when cpu is 0.0%?

Hello, My operating system is ubuntu 16.04. I need to kill or restart a shell script when cpu usage of related process is equal to 0.0% for X seconds. Appearing name on top page is vlc While surfing on forums, I found below script but not sure how to edit: Also don't know the function of -gt... (7 Replies)
Discussion started by: baris35
7 Replies