kernel: scheduling fix for ARM
[minix.git] / benchmarks / unixbench-5.1.2 / src / looper.c
blobd2f7a5069651dda23b2e59256b177eabeb974ee4
1 /*******************************************************************************
2 * The BYTE UNIX Benchmarks - Release 1
3 * Module: looper.c SID: 1.4 5/15/91 19:30:22
5 *******************************************************************************
6 * Bug reports, patches, comments, suggestions should be sent to:
8 * Ben Smith or Tom Yager at BYTE Magazine
9 * ben@bytepb.byte.com tyager@bytepb.byte.com
11 *******************************************************************************
12 * Modification Log:
14 * February 25, 1991 -- created (Ben S.)
15 * October 22, 1997 - code cleanup to remove ANSI C compiler warnings
16 * Andy Kahn <kahn@zk3.dec.com>
18 ******************************************************************************/
19 char SCCSid[] = "@(#) @(#)looper.c:1.4 -- 5/15/91 19:30:22";
21 * Shell Process creation
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <sys/wait.h>
28 #include "timeit.c"
30 unsigned long iter;
31 char *cmd_argv[28];
32 int cmd_argc;
34 void report(int sig)
36 fprintf(stderr,"COUNT|%lu|60|lpm\n", iter);
37 exit(0);
40 int main(int argc, char *argv[])
42 int slave, count, duration;
43 int status;
45 if (argc < 2)
47 fprintf(stderr,"Usage: %s duration command [args..]\n", argv[0]);
48 fprintf(stderr," duration in seconds\n");
49 exit(1);
52 if((duration = atoi(argv[1])) < 1)
54 fprintf(stderr,"Usage: %s duration command [arg..]\n", argv[0]);
55 fprintf(stderr," duration in seconds\n");
56 exit(1);
59 /* get command */
60 cmd_argc=argc-2;
61 for( count=2;count < argc; ++count)
62 cmd_argv[count-2]=argv[count];
63 #ifdef DEBUG
64 printf("<<%s>>",cmd_argv[0]);
65 for(count=1;count < cmd_argc; ++count)
66 printf(" <%s>", cmd_argv[count]);
67 putchar('\n');
68 exit(0);
69 #endif
71 iter = 0;
72 wake_me(duration, report);
74 while (1)
76 if ((slave = fork()) == 0)
77 { /* execute command */
78 execvp(cmd_argv[0],cmd_argv);
79 exit(99);
81 else if (slave < 0)
83 /* woops ... */
84 fprintf(stderr,"Fork failed at iteration %lu\n", iter);
85 perror("Reason");
86 exit(2);
88 else
89 /* master */
90 wait(&status);
91 if (status == 99 << 8)
93 fprintf(stderr, "Command \"%s\" didn't exec\n", cmd_argv[0]);
94 exit(2);
96 else if (status != 0)
98 fprintf(stderr,"Bad wait status: 0x%x\n", status);
99 exit(2);
101 iter++;