|
|
Bucaro TecHelp Newsletter
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web. ~ ~ ~ May 26, 2004 Volume 4 Number 16 ~ ~ ~
|
Buffer Underrun and Overrun Scenarios
By Stephen Bucaro
Buffer underrun and buffer overrun are occurrences that can result in some very frustrating
errors. This is not going to be a "how-to" article about fixing buffer underrun and buffer
overrun errors, but a basic description of what a buffer is, why we need buffers, and
what causes buffer underrun and buffer overrun.
BUFFER UNDERRUN
The most common occurrence of buffer underrun is CD recorders. Let's imagine an example of a
CD recording session. The computer has an ATA hard drive capable of transferring data at a
rate of 8 MBps (Mega Bytes per second). The CD recorder has a recording rate of 8 MBps.
Everything should work fine, right?
Note: The data transfer rates mentioned in this article do not apply to any specific device.
They're just for purposes of discussion.
The 8 MBps specification for the hard drive is for "burst" mode. In other words, it can transfer
data at a rate of 8 MBps for only a few seconds. Then the transfer rate drops much lower, and
if the hard drive hasn't been maintained, for example it has not been defragmented recently,
the transfer rate can drop even lower.
Whereas a hard drive can skip from cluster to cluster while reading and writing, a CD recorder
must burn the data track in a continuous stream without stopping. The design of a CD recorder
requires a "sustained" transfer rate.
When two devices that operate at different transfer rates must communicate, we can make them
work together by placing a buffer between them. A buffer is a block of memory, like a bucket
for bytes. When you start the CD recording session, the hard drive begins filling the buffer.
When the buffer is almost full, the CD recorder begins drawing bytes out of the buffer.
If everything goes smoothly, the hard drive will be able to keep enough bytes in the buffer
so that the speedy CD recorder won't empty the buffer. If the buffer runs dry, the CD recorder
has no data to burn into the CD, so it stops. Buffer underrun error.
We can reduce the chances of buffer underrun by configuring a larger buffer. Then the hard
drive will be able to put more bytes in the bucket before the CD recorder starts drawing them
out. However, sometimes you can't increase the size of the buffer because the computer doesn't
have a large amount of RAM installed. When the computer needs more RAM, it uses "virtual" RAM.
That is, it allocates part of the hard disk and pretends like that's RAM. Now, even though
you've increased the size of the buffer, you have caused the hard drive to work even slower.
BUFFER OVERRUN
The most common occurrence of buffer overrun is video recorders. Let's imagine an example of
a video camera connected to a computer. The video camera records at a data rate of 168 MBps.
The computer monitor is capable of displaying data at a rate of only 60 MBps. We have a big
problem, right?
Thanks to MPEG compression, we might not have as big a problem as first appears. With MPEG
compression, the video camera does not have to send the entire image for every frame. It
sends only the data for the part of the image that changed, and it compresses that part.
If the image doesn't change much, and the part that changed compresses well, the video camera
might need to transfer at a rate of only a few MBps. But if the entire image changes every
frame and the image does not compress well, the video camera might transfer data at a higher
rate than the computer monitor is capable of displaying.
Again, we have two devices that operate at different transfer rates that must communicate.
We can make them work together by placing a buffer between them. When you start recording
video, the video recorder starts filing the buffer. The computer display immediately begins
pulling data out of the buffer to compose display frames.
If everything goes smoothly, the computer display will be pulling data out of the buffer fast
enough so that the buffer never completely fills. If the buffer fills up, the video camera
can't put any more data in, so it stops. Buffer overrun error.
We can reduce the chances of buffer overrun by defining a larger buffer. Then the video camera
will be able to put more bytes in the bucket before it fills up. Hopefully, the video camera
will run into a few frames where the entire image doesn't change, reducing its data transfer
rate enough so the computer display can catch up.
|
|
|
Newsletter Back Issues
2006
2005
|
|