Due date: January 14th (submit by 23:59 MST)
In this project, you will learn about buffering by creating a
circular buffer that has one special feature: when you write to it,
you are guaranteed to write to the largest contiguous block. The
project will be written in C, primarily because sockets require
char *
buffers.
The goals of this project are to:
For this project you will need to use subversion to store your project and to protect yourself! Version control systems are vital for large engineering projects and when working with groups. They also allow you to work from multiple places, such as in a lab or at home and merge those changes. The use of subversion will be explained in class.
You can download the header file for your buffers from here: cbuffer.h.
Implement each of the functions defined in the header file. If you have questions about how they should work, let us know. Note that typically a user using the cbuffer will reserve_read first, try to read from it, and then do a consume for how much was removed. For writing, they will reserve_write first, and if they discover there's not enough space for what they want to write, they will resize the cbuffer.
Note that even if you do a reserve write, you do not need to wrap around the buffer--remember, you're returning the largest contiguous block of memory to the user; if it's not big enough, they will just resize the buffer. However, your functions, cbuf_find_line and cbuf_find_record will need to return the right values in case a message the user is reading crosses the end of array boundary and wraps around.
Follow the directions for Undergraduates: How to Proceed first. In addition, you must write a
driver program that reads data from the standard input and writes to the standard output. This
program should be called "mycat" and must use the cbuffer you wrote. Next, compare the performance
of the utility cat
with your driver program by cat'ing a large file (> 2mb). Redirect
the output to /dev/null so that your results are not affected by output to the terminal window.
Repeat this experiment 10 times and record the averages and standard deviations in a text file called results.txt. Next, change the size of the initial buffer you give to the mycat driver file. Does the size of this buffer affect your performance? Write an explanation for what you think might be the differences.
All source code and either makefile or eclipse project must be turned in via your directory in subversion. Details will be posted soon concerning the turn in process.
svn checkout https://svn.cs.du.edu/courses/comp3621/w2010/<username>
Where <username> is your CS email user name. You will also need your CS email password to check out that portion of the repository.
Inside of this you will create a directory called p1
which your files will be a part of. Name your
source file cbuffer.c (the implementation of cbuffer.h). Include either a Makefile or an Eclipse
project which runs your test program. Make sure you do a final commit by 11:59PM on Thursday
night.