kernel: scheduling fix for ARM
[minix.git] / benchmarks / unixbench-5.1.2 / src / spawn.c
blob34761a6e9c5d9a999bce6690bfb574c82482c998
1 /*******************************************************************************
2 * The BYTE UNIX Benchmarks - Release 3
3 * Module: spawn.c SID: 3.3 5/15/91 19:30:20
5 *******************************************************************************
6 * Bug reports, patches, comments, suggestions should be sent to:
8 * Ben Smith, Rick Grehan or Tom Yagerat BYTE Magazine
9 * ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
11 *******************************************************************************
12 * Modification Log:
13 * $Header: spawn.c,v 3.4 87/06/22 14:32:48 kjmcdonell Beta $
14 * August 29, 1990 - Modified timing routines (ty)
15 * October 22, 1997 - code cleanup to remove ANSI C compiler warnings
16 * Andy Kahn <kahn@zk3.dec.com>
18 ******************************************************************************/
19 char SCCSid[] = "@(#) @(#)spawn.c:3.3 -- 5/15/91 19:30:20";
21 * Process creation
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <sys/wait.h>
28 #include "timeit.c"
30 unsigned long iter;
32 void report(int sig)
34 fprintf(stderr,"COUNT|%lu|1|lps\n", iter);
35 exit(0);
38 int main(int argc, char *argv[])
40 int slave, duration;
41 int status;
43 if (argc != 2) {
44 fprintf(stderr,"Usage: %s duration \n", argv[0]);
45 exit(1);
48 duration = atoi(argv[1]);
50 iter = 0;
51 wake_me(duration, report);
53 while (1) {
54 if ((slave = fork()) == 0) {
55 /* slave .. boring */
56 #if debug
57 printf("fork OK\n");
58 #endif
59 /* kill it right away */
60 exit(0);
61 } else if (slave < 0) {
62 /* woops ... */
63 fprintf(stderr,"Fork failed at iteration %lu\n", iter);
64 perror("Reason");
65 exit(2);
66 } else
67 /* master */
68 wait(&status);
69 if (status != 0) {
70 fprintf(stderr,"Bad wait status: 0x%x\n", status);
71 exit(2);
73 iter++;
74 #if debug
75 printf("Child %d done.\n", slave);
76 #endif