1pcsample(2)                      System Calls                      pcsample(2)
2
3
4

NAME

6       pcsample - program execution time profile
7

SYNOPSIS

9       #include <pcsample.h>
10
11       long pcsample(uintptr_t samples[], long nsamples);
12
13

DESCRIPTION

15       The  pcsample()  function  provides CPU-use statistics by profiling the
16       amount of CPU time expended by a program.
17
18
19       For profiling dynamically-linked programs and 64-bit  programs,  it  is
20       superior  to the profil(2) function, which assumes that the entire pro‐
21       gram is contained in a small, contiguous segment of the address  space,
22       divides this segment into "bins", and on each clock tick increments the
23       counter in the bin where  the  program  is  currently  executing.  With
24       shared   libraries   creating  discontinuous  program  segments  spread
25       throughout the address space, and with 64-bit address spaces  so  large
26       that  the  size  of "bins" would be measured in megabytes, the profil()
27       function is of limited value.
28
29
30       The pcsample() function is passed an array samples containing  nsamples
31       pointer-sized  elements.  During  program execution, the kernel samples
32       the program counter of the process, storing unadulterated values in the
33       array on each clock tick. The kernel stops writing to the array when it
34       is full, which occurs after nsamples / HZ seconds  of  process  virtual
35       time.    The    HZ   value   is   obtained   by   invoking   the   call
36       sysconf(_SC_CLK_TCK). See sysconf(3C).
37
38
39       The sampling can be stopped by a subsequent call to pcsample() with the
40       nsamples argument set to 0.  Like profil(), sampling continues across a
41       call to fork(2), but is disabled by a call to one of the exec family of
42       functions  (see  exec(2)). It is also disabled if an update of the sam‐
43       ples[] array causes a memory fault.
44

RETURN VALUES

46       The pcsample() function always returns 0 the first time it  is  called.
47       On  subsequent calls, it returns the number of samples that were stored
48       during the previous invocation. If nsamples is invalid, it  returns  −1
49       and sets errno to indicate the error.
50

ERRORS

52       The pcsample() function will fail if:
53
54       EINVAL    The value of nsamples is not valid.
55
56

ATTRIBUTES

58       See attributes(5) for descriptions of the following attributes:
59
60
61
62
63       ┌─────────────────────────────┬─────────────────────────────┐
64       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
65       ├─────────────────────────────┼─────────────────────────────┤
66       │MT-Level                     │Async-Signal-Safe            │
67       ├─────────────────────────────┼─────────────────────────────┤
68       │Interface Stability          │Stable                       │
69       └─────────────────────────────┴─────────────────────────────┘
70

SEE ALSO

72       exec(2), fork(2), profil(2), sysconf(3C), attributes(5)
73
74
75
76SunOS 5.11                        10 Mar 1998                      pcsample(2)
Impressum