forget difference between big and small commands - obsolete with vm.
[minix.git] / test / benchmarks / unixbench-5.1.2 / src / hanoi.c
blobac5ab5bc46992ae9089ddbd2ef7888b5f015e080
1 /*******************************************************************************
2 * The BYTE UNIX Benchmarks - Release 3
3 * Module: hanoi.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 Yager
9 * ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
11 *******************************************************************************
12 * Modification Log:
13 * $Header: hanoi.c,v 3.5 87/08/06 08:11:14 kenj Exp $
14 * August 28, 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[] = "@(#) @(#)hanoi.c:3.3 -- 5/15/91 19:30:20";
21 #define other(i,j) (6-(i+j))
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include "timeit.c"
27 void mov(int n, int f, int t);
29 unsigned long iter = 0;
30 int num[4];
31 long cnt;
33 void report(int sig)
35 fprintf(stderr,"COUNT|%ld|1|lps\n", iter);
36 exit(0);
40 int main(int argc, char *argv[])
42 int disk=10, /* default number of disks */
43 duration;
45 if (argc < 2) {
46 fprintf(stderr,"Usage: %s duration [disks]\n", argv[0]);
47 exit(1);
49 duration = atoi(argv[1]);
50 if(argc > 2) disk = atoi(argv[2]);
51 num[1] = disk;
53 wake_me(duration, report);
55 while(1) {
56 mov(disk,1,3);
57 iter++;
60 exit(0);
63 void mov(int n, int f, int t)
65 int o;
66 if(n == 1) {
67 num[f]--;
68 num[t]++;
69 return;
71 o = other(f,t);
72 mov(n-1,f,o);
73 mov(1,f,t);
74 mov(n-1,o,t);