summaryrefslogtreecommitdiff
path: root/man/man3/pmaf.3
blob: fc91906ddc3b07c6453d93c2198a1d1e9af30d77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
'\"macro stdmacro
.\"
.\" Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
.\" 
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\" 
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\" 
.\"
.TH PMAF 3 "PCP" "Performance Co-Pilot"
.SH NAME
\f3__pmAFregister\f1,
\f3__pmAFunregister\f1,
\f3__pmAFblock\f1,
\f3__pmAFunblock\f1,
\f3__pmAFisempty\f1 \- event queue services for periodic asynchronous callbacks
.SH "C SYNOPSIS"
.ft 3
#include <pcp/pmapi.h>
.br
#include <pcp/impl.h>
.sp
.ad l
.hy 0
.in +8n
.ti -8n
int __pmAFregister(const struct timeval *\fIdelta\fP, void *\fIdata\fP, void\ (*\fIfunc\fP)(int,\ void *));
.br
.in
.hy
.ad
int __pmAFunregister(int \fIafid\fP);
.br
void __pmAFblock(void);
.br
void __pmAFunblock(void);
.br
int __pmAFisempty(void);
.sp
cc ... \-lpcp
.ft 1
.SH DESCRIPTION
The routines implement an event queue and callback framework that supports
periodic evaluation of a series of events with varying frequencies
for Performance Co-Pilot (PCP) applications.
.P
The
.BR pmlogger (1)
application, the
.BR pmdatrace (1)
PMDA and the
.BR pmdahotproc (1)
PMDA are the principal users of these services.
.P
An event is registered by calling
.BR __pmAFregister ,
and on success the return value is an event number greater than zero.
The event has associated event data identified by the opaque pointer
.IR data .
The event will occur with frequency
.IR delta
(the first instance will be
.I delta
after the current time when the event is registered),
and each time the event occurs the function
.I func
will be called with the event number and the event data as arguments.
.P
Once the event occurs and the callback has been executed, the event
will be rescheduled for
.I delta
into the future, except
if all the fields of
.I delta
are zero, in which case
the event will not be rescheduled
(a ``one trip'' event).
.P
Internally, events are processed serially so there is no
possibility of nested callbacks or re-entrant callbacks from the
event management routines.
.P
Given an event number
.IR afid ,
.B __pmAFunregister
will permanently remove the corresponding entry from the event queue.
.P
To control the event queue processing,
.B __pmAFblock
and
.B __pmAFunblock
may be used to explicitly block and unblock the dispatch of events.
This is most useful when the caller wishes to set up a number of
events via
.B __pmAFregister
and complete the registration phase before the first
event callback occurs.
.P
A call to
.B __pmAFisempty
returns 1 or 0 depending on whether the event queue is empty or not.
.SH SEE ALSO
.BR PMAPI (3)
.SH DIAGNOSTICS
.PP
.B __pmAFregister
and
.B __pmAFunregister
return values less than zero in the case of an error.  These values
are PCP error codes, and may be used to produce error messages via
.BR pmErrStr (3).
.P
The routines support the standard PCP debug tracing, and the value
.B DBG_TRACE_AF
(or
.B "\-D af"
on the command line)
will produce diagnostics on standard error that trace the enqueueing
and execution of events.
.SH CAVEATS
These routines rely on
.BR setitimer (2)
and manipulate the handling of
.B SIGALRM
signals, and hence are probably ill-suited for applications that
require direct and concurrent access to these services and resources.
.P
If the callback functions are slow, or delayed, it is possible that
the event scheduling could fall behind and never catchup.  When this
begins to happen, events are silently skipped and rescheduled at the earliest
possible time on the future according to the fixed schedule defined
by the time of the call to
.B __pmAFregister
and the value of the
.I delta
argument to
.BR __pmAFregister .
.P
In addition, the semantics of the interval timer(s) and the global
state needed to support these services demand that applications
calling these routines must do so from a single thread.
This restriction is enforced at the
.BR PMAPI (3),
where routines may return the error code
.B PM_ERR_THREAD
if the library detects calls from more than one thread.