Buffer (computer science)

from Wikipedia, the free encyclopedia

Buffer ( English buffer ) are in the computer science and telecommunications memory for the temporary storage of data . The buffer can be structured differently depending on the task.

A buffer usually saves the data temporarily and can be located in a volatile , but also in a non-volatile memory .

Forms of buffer storage

Piping and queuing (FIFO buffer)

Buffers to compensate for differences in processing speed make it possible to tolerate a jam in a processing in which the processing objects are temporarily stored for the purpose of later processing. Such buffers form a queue (engl. Pipe , tube 'or queue , queue') and operate on the principle First In - First Out . Technically, they are often implemented as ring buffers . Buffers can be implemented on the hardware or software side, with the majority of buffers being implemented on the software side.

Typical applications are the print queue , which buffers tasks for a printer, or the communication between system and application programs, interprocess communication .

Stacking (LIFO buffer)

Buffer for storing a state during an interruption of the program flow or during the "descent" into a subroutine is generally called a stack . They work on the principle of last in - first out . They allow the program to continue exactly where the interruption took place after the interruption. Stack buffers are also sometimes used to reserve data in a program for later processing.

The stack is one of the earliest storage systems in computer technology and is also implemented at the level of the machine language ( push/pop), which acts directly on the stack pointer of the microprocessor. The big disadvantage of the stack is that it has a fixed size - an uninterrupted overflow leads to a buffer overflow , a serious and dangerous programming error and attack base for numerous malware .

Caching and mapping

Buffer for faster access to data on a slow storage medium is called a cache ('hiding place'), especially when it comes to hardware , one speaks of mapping (in German: "write on a card")

Both means to map a data area in a memory. When data is read in, it is also stored in the cache so that it can be transferred directly from there when it is read again. The data in the cache are freely accessible via their address , with the addressing of the underlying storage medium being simulated. Write access is only made to the image during operation (indirect access).

When reading data sequentially, the behavior of the cache corresponds to that of a FIFO buffer; a parallel method has the advantage that one side of the mapped area can be filled regardless of how the data is to be read out.

Mapping is typically used when writing to a hard drive or a USB stick : The operating system only works on a data record mapped from the permanent memory and can therefore work faster. The hard disk is finally written when there is a sector change, for example when the USB stick is "ejected" - if the data cannot be transferred correctly (failure of the system, line or storage unit, premature removal), it is lost.

Another area of ​​application are time-critical applications. One example is the monitor's frame buffer , which is located in a protected memory area or on the graphics card and can be filled by the graphics driver regardless of the readout rate of the display device. Special forms are double buffering and triple buffering . Such buffers are also required for burning a CD in which an interruption in the supply of data would result in an error.

Swapping and Paging (Virtual Memory)

The aim of virtual memory is to store data from a faster storage medium in the slower one by swapping out data records that are currently not in use. As a result, the - usually expensive - fast memory can be dimensioned smaller - the virtual memory simulates a much larger active memory. Here is the swapping a complete inactive process, while paging outsourced a memory block. The swap file is a typical pagebuffer .

Typical concepts about the criteria for which processes / data are swapped are, in addition to FIFO, for example least recently used ('most recently unused', LRU), least frequently used (' least frequently used ', LFU) or not recently used ('most recently unused ', NRU).

Heaping

Memory areas that programs fill with data for later processing are also used for data stream buffering. For this purpose, the programs reserve a memory that goes beyond their loaded program code. Today, based Heap (English for. Stockpile , hence heap memory ) on dynamic memory allocation , which uses the operating system at the request of the program - typical program commands for memory request malloc()and realloc().

Clipboarding

Clipboarding includes buffers that only have a fixed number of spaces, but which as such can be assigned and read independently. The clipboard, for example, is a cross-application, small memory area made available by the operating system for the temporary storage of data. It generally only allows one data record, the previous one is always overwritten.

literature

  • Hartmut Ernst: Basic course in computer science. Basics and concepts for successful IT practice, 3rd edition, Springer Fachmedien, Wiesbaden 2003, ISBN 978-3-528-05717-6 .
  • Peter Fischer, Peter Hofer: Lexicon of Computer Science. 15th revised edition, Springer Verlag, Berlin / Heidelberg 2010, ISBN 978-3-64215125-5 .
  • Heinz-Peter Gumm, Manfred Sommer: Introduction to Computer Science. 18th completely revised edition, Oldenbourg Verlag, Munich 2013, ISBN 978-3-486-58724-1 .
  • Hans-Jochen Schneider (Hrsg.): Lexicon computer science and data processing. 4th updated and expanded edition, Oldenbourg Verlag, Munich 1998, ISBN 3-486-24538-4 .

Web links