1cpc_count_usr_eventCsP(U3CPPeCr)formance Counters Library Fucnpcct_icoonusnt_usr_events(3CPC)
2
3
4

NAME

6       cpc_count_usr_events, cpc_count_sys_events - enable and disable perfor‐
7       mance counters
8

SYNOPSIS

10       cc [ flag... ] file... −lcpc [ library... ]
11       #include <libcpc.h>
12
13       int cpc_count_usr_events(int enable);
14
15
16       int cpc_count_sys_events(int enable);
17
18

DESCRIPTION

20       In certain applications, it can be useful to explicitly enable and dis‐
21       able performance counters at different times so that the performance of
22       a critical algorithm can be examined.  The cpc_count_usr_events() func‐
23       tion can be used to control whether events are counted on behalf of the
24       application running in user mode, while cpc_count_sys_events()  can  be
25       used to control whether events are counted on behalf of the application
26       while it is running in the kernel,  without  otherwise  disturbing  the
27       binding  of  events to the invoking LWP. If the enable argument is non-
28       zero, counting of events is enabled, otherwise they are disabled.
29

RETURN VALUES

31       Upon     successful     completion,     cpc_count_usr_events()      and
32       cpc_count_sys_events() return 0. Otherwise, the functions return −1 and
33       set errno to indicate the error.
34

ERRORS

36       The cpc_count_usr_events() and  cpc_count_sys_events()  functions  will
37       fail if:
38
39       EAGAIN     The  associated performance counter context has been invali‐
40                  dated by another process.
41
42
43       EINVAL     No performance counter  context  has  been  created,  or  an
44                  attempt  was  made  to enable system events while delivering
45                  counter overflow signals.
46
47

EXAMPLES

49       Example 1 Use cpc_count_usr_events() to minimize code needed by  appli‐
50       cation.
51
52
53       In this example, the routine cpc_count_usr_events() is used to minimize
54       the amount of code that needs to be added to the application. The  cpu‐
55       track(1)  command  can  be used in conjunction with these interfaces to
56       provide event programming, sampling, and reporting facilities.
57
58
59
60       If the application is instrumented in this way and then started by cpu‐
61       track  with the nouser flag set in the event specification, counting of
62       user events will only be enabled around the critical  code  section  of
63       interest.   If the program is run normally, no harm will ensue.
64
65
66         int have_counters = 0;
67         int
68         main(int argc, char *argv[])
69         {
70             if (cpc_version(CPC_VER_CURRENT) == CPC_VER_CURRENT &&
71                 cpc_getcpuver() != -1 && cpc_access() == 0)
72                 have_counters = 1;
73
74             /* ... other application code */
75
76             if (have_counters)
77                 (void) cpc_count_usr_events(1);
78
79             /* ==> Code to be measured goes here <== */
80
81             if (have_counters)
82                 (void) cpc_count_usr_events(0);
83
84             /* ... other application code */
85         }
86
87

ATTRIBUTES

89       See attributes(5) for descriptions of the following attributes:
90
91
92
93
94       ┌─────────────────────────────┬─────────────────────────────┐
95       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
96       ├─────────────────────────────┼─────────────────────────────┤
97       │MT-Level                     │MT-Safe                      │
98       ├─────────────────────────────┼─────────────────────────────┤
99       │Interface Stability          │Obsolete                     │
100       └─────────────────────────────┴─────────────────────────────┘
101

SEE ALSO

103       cputrack(1),    cpc(3CPC),    cpc_access(3CPC),   cpc_bind_event(3CPC),
104       cpc_enable(3CPC),    cpc_getcpuver(3CPC),    cpc_pctx_bind_event(3CPC),
105       cpc_version(3CPC), libcpc(3LIB), attributes(5)
106

NOTES

108       The  cpc_count_usr_events()  and cpc_count_sys_events() functions exist
109       for binary compatibility only. Source containing these  functions  will
110       not  compile.  These  functions  are obsolete and might be removed in a
111       future release. Applications should use cpc_enable(3CPC) instead.
112
113
114
115SunOS 5.11                        28 Mar 2005       cpc_count_usr_events(3CPC)
Impressum