NAME

BSD::Itimer - Perl extension for accessing interval timers

SYNOPSIS

  use BSD::Itimer;
  my($interval_sec, $interval_usec, $current_sec, $current_usec) =
    getitimer(ITIMER_REAL);
  my($interval_sec, $interval_usec, $current_sec, $current_usec) =
    setitimer(ITIMER_REAL, $interval_sec, $interval_usec,
	      $current_sec, $current_usec));

DESCRIPTION

This module provides access to the interval timers many operating systems provide from perl. Interval timers conceptually have microsecond resolution (hardware typically limits actual granularity), with the ability to reschedule the timer on a fixed repeating interval. There are usually several timers available with a different concept of "time".

OVERVIEW

The interval timer is accessed by two exported functions, getitimer and setitimer. Most Unix systems have three interval timers available for program use. The current BSD::Itimer implementation knows about the following timers, where implemented:

ITIMER_REAL - This timer decrements in real time. A SIGALRM is delivered when this timer expires.

ITIMER_VIRTUAL - This timer decrements in real time when the calling process is running. Delivers SIGVTALRM when it expires.

ITIMER_PROF - This timer runs when the calling process is running, and when the operating system is operating on behalf of the calling process. A SIGPROF is delivered when the timer expires.

ITIMER_REALPROF - This timer is available under Solaris only. Consult the setitimer(2) manual page for more information.

Interval timers are represented as four item integer lists. The first two integers comprise the second and microsecond parts of the timer's repeat interval. The second pair represent the second and microsecond parts of the current timer value.

The getitimer function expects a single argument naming the timer to fetch. It returns a four element list, or an empty list on failure.

The setitimer function expects a argument naming the timer to set, and a four element list representing the interval. It returns the previous setting of the timer, or an empty list on failure. Setting a timer's repeat interval to 0 will cancel the timer after its next delivery. Setting it's current value to 0 will immediately cancel the timer.

SEE ALSO

perl(1), setitimer(2)

AUTHOR

Daniel Hagerty <hag@linnaean.org>

COPYRIGHT

Copyright (c) 1999 Daniel Hagerty. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

BUGS

Could use a friendly interface.