Home Announcements Schedule Assignments Slides Projects Reading

Project 1: Buffer Sets

Due date: January 12th (submit by 23:59 MST)

Description and Project Goals

The goals of this project are to:

In this project, you will learn about buffering by creating a buffer set, which is a circule queue of buffers which you can read and write from. Typically, when we write networking code, we have an underlying buffer that copies data to and from the network socket (note that the operating system keeps its own buffer for the socket which is typically read or written to via DMA and you're performing a 2nd copy on this data to access it).

Normally you have a single buffer, but the question arises: what do you do if you run out of space in that buffer but the socket still has more data on it? In this case, you can expand your current buffer's size, though this will require you to copy your data a 3rd time, which can be costly. An alternative is to keep track of several buffers in a ring. When one buffer is filled, you take the next buffer from the ring and begin writing to it. More buffers are added to the ring as needed. As you read from the buffers, you can remove the empty ones. These buffers comprise your buffer set.

For this project, you get some creativity, but because we need to be able to test your code, we need three functions available:

void config(int buffer_size, int num_buffers);
void write(std::istream &istr);
void read(std::ostream &ostr);

We will initialize your buffer by calling config with a buffer size (the fixed maximum size of your buffers), and num_buffers (the number of buffers in your ring). When we give your program an istream via a call to write, you should read all available data from your buffers into the istream. When we give your program an ostream via a call to read, you should read all the data from the ostream into your buffer.

Getting Started

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.

Undergraduates: How to Proceed

Implement the buffer set as described above. I highly suggest using the STL for your individual buffers and to hold your set of buffers (e.g., std::vector and std::deque). If you have questions about how they should work, let us know. You will want to test your program using small buffers and using fstreams to read and write from your buffer set to see if it works correctly.

Graduates: How to Proceed

Follow the directions for Undergraduates: How to Proceed first. In addition, your program must take a single parameter that specifies a file. You will read from the file into your buffer and then output to std::out. Compare the performance by timing this with the cat utility in unix using a file that is greater than 2Mb. Once you know it's working correctly, redirect your output to /dev/null so the scrolling doesn't affect performance.

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.

Turn-in

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.

Grading

You will be graded as follows:

Turn-In

Turn-in will be done via subversion. To get to your space in the repository, do a:
svn checkout https://svn.cs.du.edu/courses/comp3621/w2012/<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 bufferset.cpp. 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.