]>
Commit | Line | Data |
---|---|---|
84724245 | 1 | #include <signal.h> |
28f540f4 RM |
2 | #include <stdio.h> |
3 | #include <time.h> | |
84724245 | 4 | #include <unistd.h> |
28f540f4 | 5 | |
84724245 RM |
6 | volatile int gotit = 0; |
7 | ||
8 | void | |
9 | alarm_handler (int signal) | |
10 | { | |
11 | gotit = 1; | |
12 | } | |
13 | ||
14 | ||
15 | int | |
16 | main (int argc, char ** argv) | |
28f540f4 | 17 | { |
84724245 | 18 | clock_t start, stop; |
28f540f4 | 19 | |
227d9931 | 20 | if (signal(SIGALRM, alarm_handler) == SIG_ERR) |
9eb2730e UD |
21 | { |
22 | perror ("signal"); | |
23 | exit (1); | |
24 | } | |
84724245 RM |
25 | alarm(1); |
26 | start = clock (); | |
27 | while (!gotit); | |
28 | stop = clock (); | |
28f540f4 | 29 | |
84724245 RM |
30 | printf ("%ld clock ticks per second (start=%ld,stop=%ld)\n", |
31 | stop - start, start, stop); | |
32 | printf ("CLOCKS_PER_SEC=%d, sysconf(_SC_CLK_TCK)=%ld\n", | |
33 | CLOCKS_PER_SEC, sysconf(_SC_CLK_TCK)); | |
28f540f4 RM |
34 | return 0; |
35 | } |