On Mon, 2002-04-08 at 19:09, Sreekumar Kodakara wrote:
> Hi
> I want to call a function periodically, say every 5 seconds. Is there any
> timer functions which will help me do that? I am using
> RedHat linux 6.1. Thanks for the help in advance.

There are ways to have this happen, but most of them are a big pain. 
What method is best depends a lot on what the rest of your program does.

One method is to use 'sleep' to get a 5 second delay.

Another is to deal with all the wonders and pitfalls of signal
handling.  You set up a handler for SIGALRM using the sigaction call and
use setitimer to set up an interval timer that will send you SIGALRM at
specified intervals.

A last way is if you have a program that's based on an event loop.  You
can carefully track the time and give strategic values for the timeout
arguments to select or poll so you get control back at the right time.

If you're doing C++ and are interested in a whole framework for dealing
with Unix in an event oriented fashion, you might want to look into my
StreamModule libraries (http://www.omnifarious.org/StrMod).

Have fun (if at all possible),
-- 
The best we can hope for concerning the people at large is that they
be properly armed.  -- Alexander Hamilton
-- Eric Hopper (hopper at omnifarious.org 
http://www.omnifarious.org/~hopper) --
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part
Url : http://shadowknight.real-time.com/pipermail/tclug-devel/attachments/20020408/ae6ad766/attachment.pgp