Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

timer.c

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <signal.h>
00004 #include <sys/time.h>
00008 char astbuf[] = "*";
00009 static void myhandler(int s)
00010 {
00011            write(0, astbuf, sizeof(char));
00012 }
00013 
00014 /* set up the myhandler handler for signal SIGPROF */
00015 void init_timer_interrupt(void)
00016 {
00017            struct sigaction newact;
00018               newact.sa_handler = myhandler;
00019                  newact.sa_flags = SA_RESTART;
00020                     sigemptyset(&newact.sa_mask);
00021                        sigaction(SIGPROF, &newact, NULL);
00022 }
00023 
00024 /* set the ITIMER_PROF interval timer for 2-second intervals */
00025 void setup_interval_timer(void)
00026 {
00027            struct itimerval value;
00028               value.it_interval.tv_sec = 2;
00029                  value.it_interval.tv_usec = 0;
00030                     value.it_value = value.it_interval;
00031                        setitimer(ITIMER_PROF, &value, NULL);
00032 }
00033 
00034 void main(int argc, char *argv[])
00035 {
00036            init_timer_interrupt();
00037               setup_interval_timer();
00038               for (;;) { }
00039                  exit(0);
00040 }
00041 
00042 

Generated on Tue Dec 17 21:14:13 2002 for AUSS_Connector by doxygen1.2.18