Appendix A Unix Emulator Test Programs #define N 500000int x[N]; main() -int i; for(i=5; i--; )g(); printf("%d"n%d"n", x[N-2], x[N-1]); "" g() - int i; x[0] = x[1] = 1;for(i=2; i!N; i++) x[i] = x[i-x[i-1]] + x[i-x[i-2]];"" Figure A.1: Test 1: Compute 137 #define N 1024 /* or 1 or 4096 */char x[N]; main()- int fd[2],i;pipe(fd); for(i=10000; i--; ) -write(fd[1], x, N); read(fd[0], x, N);"" "" Figure A.2: Test 2, 3, and 4: Read/Write to a Pipe #include !sys/file.h? #define Test.dev "/dev/null" /* or /dev/tty */ main()- int f,i;for(i=10000; i--; ) - f = open(Test.dev, O.RDONLY); close(f);"" "" Figure A.3: Test 5 and 6: Opening and Closing #include !sys/file.h?#define N 1024 char x[N];main() - int f,i,j; f = open("file", O.RDWR -- O.CREAT -- O.TRUNC, 0666); for(j=1000; j--; ) - lseek(f, 0L, L.SET);for(i=10; i--; ) write(f, x, N);lseek(f, 0L, L.SET); for(i=10; i--; )read(f, x, N); ""close(f); "" Figure A.4: Test 7: Read/Write to a File