The project directory is to contain three source files, a Makefile, and
a report. In addition, the directory
~/man/man1
is to contain man pages for the
executable programs you write for this project, and ~/man/man3
is to contain man pages for the library functions you develop
for this assignment.
You may leave a
README
file in the project directory if you think that one
is needed, but I neither expect nor require you to do so.
stdio
in this assignment. In addition to producing your
own versions of these functions, you will use them to perform a timing
experiment to determine the optimal buffer size for I/O on this system.
The two functions you are to write are __filbuf(), which is called
internally by the stdio
function getc(), and
fopen(). In addition, you will write a main program which exercises
your functions by reading a large data file into memory.
The report, which you are to submit as a text file in the format of a research report, is to summarize your experiments with different buffer sizes for __filbuf(). See the Written Report section below for information on what to put in the report.
You are to do the assignment as a sequence of steps, which are outlined here:
stdio
", and is to be made by linking the object
module for the main program with the standard C library. A second
program is to be called "myio
" (or something similar), and
is to be made by linking three modules: your main program, and separate
modules that contain your own versions of __filbuf() and
fopen(). The other two programs complete the permutations of
combining the standard library functions and the two that you will
write for this assignment.
It is a requirement for this project that the same main module works with both the system-supplied versions of __filbuf() and fopen() and with your own versions. Likewise, your version of __filbuf() must work with the standard library version of fopen() and vice-versa.
The program is to accept an optional command line argument specifying
the name of the data file that it is to read. The default name for the
data file is to be data.file
.
RCS
subdirectory in your project directory,
and put your Makefile and all source files for the assignment
under rcs management.
BUF_SIZE
at execution time to set the size of the
buffer that it uses. Use the getenv() library function for this.
Do some experiments with BUF_SIZE
to see how it affects the
time it takes to read a data file. You will need a large data file to
get a meaningful measure because of the granularity of the system clock.
The report is a text file (not a word-processing document) that starts with a meaningful title and the author's name centered at the top of the page, followed by four sections with the following names:
Introduce the problem of deterimining the optimal buffer size for __filbuf(). Include an explanation of the relationship between __filbuf() and getc() here.
Tell how you determined the optimal buffer size for __filbuf(). You should mention that you wrote a special version of __filbuf() for this experiment and what you were able to do with your __filbuf() (change the buffer size by setting an environment variable), but you should not document your program in any way because that is already done in your man pages and your code's comments.
Give enough information here so that someone else with access to your program could do the same experiments you did.
Provide a summary of the data you collected. Do not give the raw data generated by your program, just a table that summarizes your data, like Figure 3.1 in the textbook.
Interpret your results here.