| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- program execution time profile
#include <pcsample.h>longpcsample(uintptr_tsamples[],longnsamples);
Thepcsample() function provides CPU-use statistics by profiling the amount of CPUtime expended by a program.
For profiling dynamically-linked programs and 64-bit programs, it is superior to theprofil(2) function, which assumes that the entire program is contained in a small,contiguous segment of the address space, divides this segment into “bins”, andon each clock tick increments the counter in the bin where the programis currently executing. With shared libraries creating discontinuous program segments spread throughoutthe address space, and with 64-bit address spaces so large that thesize of “bins” would be measured in megabytes, theprofil() function is oflimited value.
Thepcsample() function is passed an arraysamples containingnsamples pointer-sized elements.During program execution, the kernel samples the program counter of the process, storingunadulterated values in the array on each clock tick. The kernel stopswriting to the array when it is full, which occurs afternsamples /HZ seconds of process virtual time. TheHZ value is obtained byinvoking the callsysconf(_SC_CLK_TCK). Seesysconf(3C).
The sampling can be stopped by a subsequent call topcsample() withthensamples argument set to 0. Likeprofil(), sampling continues across acall tofork(2), but is disabled by a call to one oftheexec family of functions (seeexec(2)). It is also disabled if anupdate of thesamples[ ] array causes a memory fault.
Thepcsample() function always returns0 the first time it is called. On subsequent calls, it returns the number of samples that werestored during the previous invocation. Ifnsamples is invalid, it returns-1 andsetserrno to indicate the error.
Thepcsample() function will fail if:
The value ofnsamples is not valid.
Seeattributes(5) for descriptions of the following attributes:
|
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |