Buffer underrun

Last updated

In computing, buffer underrun or buffer underflow is a state occurring when a buffer used for communicating between two devices or processes is fed with data at a lower speed than the data is being read from it. This requires the program reading from the buffer to pause its processing while the buffer refills. Having to deal with such situations can cause undesired and sometimes serious side effects because the data being buffered is often not suited for stop-start access of this kind.

Contents

In terms of concurrent programming, a buffer underrun can be considered a form of resource starvation.

The term as defined above is distinct from buffer overflow, a condition where a portion of memory forms a buffer of a fixed size yet is filled with more than that amount of data, thus overwriting memory locations outside of the allocated chunk. However, buffer underrun and underflow are also sometimes used to mean buffer underwrite, where a program is tricked into writing data into memory locations before the beginning of the buffer, overriding potential data there such as permission bits. [1]

General causes and solutions

Buffer underruns are often the result of transitory issues involving the connection which is being buffered: either a connection between two processes, with others competing for CPU time, or a physical link, with devices competing for bandwidth.

The simplest guard against such problems is to increase the size of the buffer—if an incoming data stream needs to be read at 1 bit per second, a buffer of 10 bits would allow the connection to be blocked for up to 10 seconds before failing, whereas one of 60 bits would allow a blockage of up to a minute. However, this requires more memory to be available to the process or device, which can be expensive. It assumes that the buffer starts full—requiring a potentially significant pause before the reading process begins—and that it will always remain full unless the connection is currently blocked. If the data does not, on average, arrive faster than it is needed, any blockages on the connection will be cumulative; "dropping" one bit every minute on a hypothetical connection with a 60-bit buffer would lead to a buffer underrun if the connection remained active for an hour. In real-time applications, a large buffer size also increases the latency between input and output, which is undesirable in low-latency applications such as video conferencing.

CD and DVD recording issues

Buffer underruns can cause serious problems during CD/DVD burning, because once the writing is started, it cannot stop and resume flawlessly; thus the pause needed by the underrun can cause the data on the disc to become invalid. Since the buffer is generally being filled from a relatively slow source, such as a hard disk or another CD/DVD, a heavy CPU or memory load from other concurrent tasks can easily exhaust the capacity of a small buffer. Therefore, a technique called buffer underrun protection was implemented by various individual CD/DVD writer vendors, under various trademarks, such as Plextor BurnProof, Nero UltraBuffer, Yamaha SafeBurn, JustLink, and Seamless Link. With this technique, the laser is indeed able to stop writing for any amount of time and resume when the buffer is full again. The gap between successive writes is extremely small.

Another way to protect against the problem, when using rewritable media (CD-RW, DVD-RW, DVD-RAM), is to use the UDF file system, which organizes data in smaller "packets", referenced by a single, updated address table, which can therefore be written in shorter bursts.

Multimedia playback

If the framebuffer of the graphics controller is not updated, the picture of the computer screen will appear to hang until the buffer receives new data. Many video player programs (e.g. MPlayer) feature the ability to drop frames if the system is overloaded, intentionally allowing a buffer underrun to keep up the tempo.

The buffer in an audio controller is a ring buffer. If an underrun occurs and the audio controller is not stopped, it will either keep repeating the sound contained in the buffer, or output silence depending on the implementation. Such effect is commonly referred to as "machinegun" or Max Headroom stuttering effect. This happens if the operating system hangs during audio playback. An error handling routine (e.g. blue screen of death) may eventually stop the audio controller.

Intentionally imitating this audio glitch during the creation of music or sound art, either by manually splicing audio or re-triggering samples, or by using plugins, is called the Stutter edit.

Related Research Articles

<span class="mw-page-title-main">Computer data storage</span> Storage of digital data readable by computers

Computer data storage or digital data storage is a technology consisting of computer components and recording media that are used to retain digital data. It is a core function and fundamental component of computers.

<span class="mw-page-title-main">Bus (computing)</span> System that transfers data between components within a computer

In computer architecture, a bus is a communication system that transfers data between components inside a computer, or between computers. This expression covers all related hardware components and software, including communication protocols.

<span class="mw-page-title-main">FIFO (computing and electronics)</span> Scheduling algorithm, the first piece of data inserted into a queue is processed first

In computing and in systems theory, first in, first out, acronymized as FIFO, is a method for organizing the manipulation of a data structure where the oldest (first) entry, or "head" of the queue, is processed first.

In computing, interrupt latency refers to the delay between the start of an Interrupt Request (IRQ) and the start of the respective Interrupt Service Routine (ISR). For many operating systems, devices are serviced as soon as the device's interrupt handler is executed. Interrupt latency may be affected by microprocessor design, interrupt controllers, interrupt masking, and the operating system's (OS) interrupt handling methods.

<span class="mw-page-title-main">Microcontroller</span> Small computer on a single integrated circuit

A microcontroller or microcontroller unit (MCU) is a small computer on a single integrated circuit. A microcontroller contains one or more CPUs along with memory and programmable input/output peripherals. Program memory in the form of NOR flash, OTP ROM, or ferroelectric RAM is also often included on the chip, as well as a small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general-purpose applications consisting of various discrete chips.

Direct memory access (DMA) is a feature of computer systems that allows certain hardware subsystems to access main system memory independently of the central processing unit (CPU).

<span class="mw-page-title-main">Universal asynchronous receiver-transmitter</span> Computer hardware device

A universal asynchronous receiver-transmitter is a peripheral device for asynchronous serial communication in which the data format and transmission speeds are configurable. It sends data bits one by one, from the least significant to the most significant, framed by start and stop bits so that precise timing is handled by the communication channel. The electric signaling levels are handled by a driver circuit external to the UART. Common signal levels are RS-232, RS-485, and raw TTL for short debugging links. Early teletypewriters used current loops.

<span class="mw-page-title-main">Network interface controller</span> Hardware component that connects a computer to a network

A network interface controller is a computer hardware component that connects a computer to a computer network.

Serial Peripheral Interface (SPI) is a de facto standard for synchronous serial communication, used primarily in embedded systems for short-distance wired communication between integrated circuits.

The term arithmetic underflow is a condition in a computer program where the result of a calculation is a number of more precise absolute value than the computer can actually represent in memory on its central processing unit (CPU).

<span class="mw-page-title-main">Integer overflow</span> Computer arithmetic error

In computer programming, an integer overflow occurs when an arithmetic operation on integers attempts to create a numeric value that is outside of the range that can be represented with a given number of digits – either higher than the maximum or lower than the minimum representable value.

In computer science, a data buffer is a region of memory used to store data temporarily while it is being moved from one place to another. Typically, the data is stored in a buffer as it is retrieved from an input device or just before it is sent to an output device ; however, a buffer may be used when data is moved between processes within a computer, comparable to buffers in telecommunication. Buffers can be implemented in a fixed memory location in hardware or by using a virtual data buffer in software that points at a location in the physical memory.

<span class="mw-page-title-main">Dual-ported video RAM</span> Dual-ported variant of dynamic RAM

Dual-ported video RAM (VRAM) is a dual-ported variant of dynamic RAM (DRAM), which was once commonly used to store the framebuffer in graphics adapters.

<span class="mw-page-title-main">Optical disc recording technologies</span> List of technologies used to write to optical discs

Optical disc authoring requires a number of different optical disc recorder technologies working in tandem, from the optical disc media to the firmware to the control electronics of the optical disc drive.

A memory controller, also known as memory chip controller (MCC) or a memory controller unit (MCU), is a digital circuit that manages the flow of data going to and from a computer's main memory. When a memory controller is integrated into another chip, such as an integral part of a microprocessor, it is usually called an integrated memory controller (IMC).

The Xbox 360 technical specifications describe the various components of the Xbox 360 video game console.

<span class="mw-page-title-main">Intel 8237</span>

Intel 8237 is a direct memory access (DMA) controller, a part of the MCS 85 microprocessor family. It enables data transfer between memory and the I/O with reduced load on the system's main processor by providing the memory with control signals and memory address information during the DMA transfer.

This glossary of computer hardware terms is a list of definitions of terms and concepts related to computer hardware, i.e. the physical and structural components of computers, architectural issues, and peripheral devices.

<span class="mw-page-title-main">PlayStation 2 technical specifications</span> Overview of the PlayStation 2 technical specifications

The PlayStation 2 technical specifications describe the various components of the PlayStation 2 (PS2) video game console.

Goldmont is a microarchitecture for low-power Atom, Celeron and Pentium branded processors used in systems on a chip (SoCs) made by Intel. They allow only one thread per core.

References

  1. "CWE-124: Buffer Underwrite ('Buffer Underflow')". CWE.