|
Last change
on this file since 2442 was 2036, checked in by bird, 20 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
|
File size:
625 bytes
|
| Line | |
|---|
| 1 | #include <signal.h>
|
|---|
| 2 | #include <stdio.h>
|
|---|
| 3 | #include <stdlib.h>
|
|---|
| 4 | #include <time.h>
|
|---|
| 5 | #include <unistd.h>
|
|---|
| 6 |
|
|---|
| 7 | volatile int gotit = 0;
|
|---|
| 8 |
|
|---|
| 9 | static void
|
|---|
| 10 | alarm_handler (int signal)
|
|---|
| 11 | {
|
|---|
| 12 | gotit = 1;
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | int
|
|---|
| 17 | main (int argc, char ** argv)
|
|---|
| 18 | {
|
|---|
| 19 | clock_t start, stop;
|
|---|
| 20 |
|
|---|
| 21 | if (signal(SIGALRM, alarm_handler) == SIG_ERR)
|
|---|
| 22 | {
|
|---|
| 23 | perror ("signal");
|
|---|
| 24 | exit (1);
|
|---|
| 25 | }
|
|---|
| 26 | alarm(1);
|
|---|
| 27 | start = clock ();
|
|---|
| 28 | while (!gotit);
|
|---|
| 29 | stop = clock ();
|
|---|
| 30 |
|
|---|
| 31 | printf ("%ld clock ticks per second (start=%ld,stop=%ld)\n",
|
|---|
| 32 | stop - start, start, stop);
|
|---|
| 33 | printf ("CLOCKS_PER_SEC=%ld, sysconf(_SC_CLK_TCK)=%ld\n",
|
|---|
| 34 | CLOCKS_PER_SEC, sysconf(_SC_CLK_TCK));
|
|---|
| 35 | return 0;
|
|---|
| 36 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.