Project

General

Profile

Statistics
| Revision:

root / branches / simulator / projects / simulator / core / test_timer.c @ 961

History | View | Annotate | Download (479 Bytes)

1
#include <stdio.h>
2
#include <sys/time.h>
3
#include <signal.h>
4

    
5
void *tick(int sig)
6
{
7
  printf("tick\n");
8
  fflush(stdout);
9

    
10
  return NULL;
11
}
12

    
13
int main()
14
{
15
  int ret;
16
  struct itimerval iv;
17

    
18
  iv.it_interval.tv_sec = 1;
19
  iv.it_interval.tv_usec = 0;
20
  iv.it_value.tv_sec = 5;
21
  iv.it_value.tv_usec = 0;
22

    
23
  signal(SIGVTALRM, tick);
24

    
25
  ret = setitimer(ITIMER_VIRTUAL, &iv, NULL);
26

    
27
  printf("setitimer returned %d.\n waiting...\n", ret);
28
  fflush(stdout);
29

    
30
  while(1);
31

    
32
  return 0;
33
}