Manual Reference Pages - SNMP_ALARM_REGISTER (3)
snmp_alarm_unregister - alarm functions
snmp_alarm_register(unsigned int seconds,
unsigned int flags,
snmp_alarm_register_hr(struct timeval t,
unsigned int flags,
snmp_alarm_unregister(unsigned int reg);
These functions implement support for a generic timer handling
mechanism for multiple parts of an application to register function
callbacks to happen at a particular time in the future.
The usage is fairly simple and straight-forward: Simply create a
function you want called back at some point in the future. The
function definition should be similar to:
void my_callback(unsigned int reg, void *clientarg);
snmp_alarm_register() to register your callback to be called
seconds from now. The
flags field should either be
NULL. If flags is set with
SA_REPEAT, then the registered callback function will be called every
NULL then the function will only be called once and then removed from the
alarm system registration.
clientarg parameter in the registration function is used only by
the client function and is stored and passed back directly to them on
every call to the system.
snmp_alarm_register() function returns a unique
unsigned int (which is also passed as the first argument of each callback), which
can then be used to remove the callback from the queue at a later
point in the future using the
snmp_alarm_unregister() function. If the
snmp_alarm_register() call fails it returns zero. In particular, note that it is entirely
permissible for an alarm function to unregister itself.
snmp_alarm_register_hr() function is identical in operation to the
snmp_alarm_register() function, but takes a
struct timeval as a first parameter, and schedules the callback after the period
t (the letters
hr stand for "high resolution"). The operation of this function is
dependent on the provision of the
system call by the operating system. If this system call is not
available, the alarm will be scheduled as if
snmp_alarm_register() had been called with a first argument equal to the value of the
tv_sec member of
t. See, however, the notes below.
init_snmp() function initialises the snmp_alarm subsystem by calling
init_snmp_alarm() and then
init_alarm_post_config() to set up the first timer to initialise the callback function. These
two functions should not be used directly by applications.
The default behaviour of the snmp_alarm subsystem is to request
SIGALRM signals from the operating system via the
system calls. This has the disadvantage, however, that no other part
of the application can use the
SIGLARM functionality (or, if some other part of the application
does use the
SIGALRM functionality, the snmp_alarm subsystem will not work correctly).
If your application runs a
event loop, however, there is no need to use
SIGALRM for the snmp_alarm subsystem, leaving it available for other parts of
the application. This is done by making the following call:
snmp_select_info() takes alarms into account when calculating the timeout value to be
All you need to do is call
times out (return value of zero). This is the approach taken in the
snmpd.c. Furthermore, when using this method, high resolution alarms do not
depend on the presence of the
system call, although overall precision is of course still determined
by the underlying operating system. Recommended.
|V5.7.3 ||SNMP_ALARM (3) ||01 Aug 2002 |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.