nanogui@linuxhacker.org

nanogui@linuxhacker.org


Subject: Re: Timer API.
From: Kyle Harris
Date: Wed, 02 Feb 2000 09:29:50 -0500



Chris Johns wrote:
> 
> Hello,
> 
> I need to have some timers in my application.
> 
> What is the API ?
>
I don't think Microwindows provides for anything like this. Are you
running Linux (unix)? If so, you can use signal() and alarm() for low
resolution timers. select() and setitimer() can be used for higher
resolutions.
 
> Does anyone have an example ?
>

See the man pages for the above functions.  

Normally, you set up a signal handler for the SIGALRM and use alarm to
start timers.

main()
{
	signal(SIGLARM,sigalrm);
	alarm(5);
	for(;;);
}

void
sigalrm(int signo)
{
	printf("signal from alarm\n");
}

The above timer will pop in 5 seconds.

Later, Kyle.

nanogui@linuxhacker.org