ruby-x.github.io/synthesis/app-A.html
2015-08-08 20:33:42 +03:00

80 lines
2.0 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">
<html>
<head>
<title>Synthesis: An Efficient Implementation of Fundamental Operating System Services - Abstract</title>
<link rel="stylesheet" type="text/css" href="../css/style.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="nav">
<a class=home href="../index.html">Alexia's Home</a>
<a href="index.html">Dissertation</a>
<a href="abs.html">Abstract</a>
<a href="ack.html">Acknowledgements</a>
<a href="toc.html">Contents</a>
<a href="ch1.html">Chapter 1</a>
<a href="ch2.html">Chapter 2</a>
<a href="ch3.html">Chapter 3</a>
<a href="ch4.html">Chapter 4</a>
<a href="ch5.html">Chapter 5</a>
<a href="ch6.html">Chapter 6</a>
<a href="ch7.html">Chapter 7</a>
<a href="ch8.html">Chapter 8</a>
<a href="bib.html">Bibliography</a>
<a class=here href="app-A.html">Appendix A</a>
</div>
<div id="running-title">
Synthesis: An Efficient Implementation of Fundamental Operating System Services - Abstract
</div>
<div id="content">
Appendix A <span class=smallcaps>Unix</span> 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
</div>
</body>
</html>