In computer science and telecommunications, buffers are storage devices for the intermediate storage of data. Depending on the task, the buffer can be structured differently. A buffer usually stores the data temporarily, and can be located in volatile or non-volatile memory.
Piping and Queueing (FIFO Buffer)
Buffers to compensate for differences in processing speed make it possible to tolerate a congestion in a processing by temporarily storing the data in the buffer until it can be processed. Such buffers form a pipe or queue and work according to the principle of first in – first out. Technically, they are often implemented as ring buffers. Buffers can be implemented on the hardware or software side, with the vast 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.
Stacking (LIFO buffer)
Buffers used to store a state during an interruption in the program’s flow or during the “descent” to a subroutine are generally called stacks. They work according to the principle of last in – first out. They allow the program to pick up right where the interruption took place after the interruption. Stack buffers are also sometimes used to mark data in a program for later editing.
---
At the level of machine language, it is realized, for example, by means of the instructions, which has a direct effect on the stack pointer of the microprocessor. A major disadvantage of the stack is that it has a fixed size – a stack overflow that is not programmatically intercepted (special case of a buffer overflow) is a serious and dangerous programming error and the basis for the attack of numerous malware.
Caching and Mapping
Buffer for faster access to data on a slow storage medium is called cache. When data is read, it is also stored in the cache so that it can be taken directly from there when it is read again. The data in the cache is freely accessible via its address, whereby the addressing of the underlying storage medium is simulated. Write access is only made to the image during operation (indirect access).
While reading data sequentially, the behavior of the cache corresponds to 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.
Mapping, for example, is typically used when writing to a hard disk or USB stick: the operating system only works on a data set mapped from the hard drive, and can therefore work faster. In the case of the hard disk, for example, the final writing takes place when the sector is changed, in the case of the USB stick when it 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 is time-critical applications. An example is the monitor’s framebuffer, which is located in a protected memory area or on the graphics card and can be filled by the graphics driver regardless of the display device’s readout rate. Special forms are double buffering and triple buffering. Such buffers are also needed for burning a CD, where an interruption in the supply of data would result in an error.

Swapping and Paging (virtual memory)
The goal of virtual memory is to store data from a faster storage medium in a slower one by offloading currently unused data sets. As a result, the – usually expensive – fast memory can be reduced – the virtual memory simulates a much larger active memory. In the case of swapping, a completely inactive process is swapped out, and in the case of paging, a block of memory is swapped. Typical pagebuffer is the page file.
In addition to FIFO, typical concepts about the criteria for which processes/data are swapped include least recently used (LRU), least frequently used (LFU) or not recently used (NRU).
Heaping
Memory areas that fill programs with data for later processing are also used for data stream buffering. To do this, the programs reserve a memory beyond their loaded program code. Today, the heap is based on dynamic memory allocation, which the operating system serves at the request of the program – typical program commands for requesting memory are malloc() and realloc().
Clipboarding
Clipboarding includes the buffers, which only have a fixed number of seats, but which as such can be occupied and read independently. The clipboard, for example, is a cross-application small storage area provided by the operating system for caching data. It generally only allows one record, the previous one will always be overwritten.