A buffer is a register or an area of main memory used to hold data generated by a producer process or an input device and removed from the buffer at a later time by a consumer process or an output device. Depending on the intended use, a single buffer can hold one character at a time or a larger block of data.
If too much data is loaded into a buffer before it has a chance to be read from, you may get a buffer overflow error.
The main purpose of using a single buffer is to decouple the producer from the consumer in time. This allows the device and the process to be simultaneously active.
Buffer swapping is a technique that allows the operations of a producer process and a consumer process to overlap by using two buffers. The producer works on one buffer, while the consumer works on a second buffer. This way both can be working, with minimal down time. Assuming they take the same time to complete their work with the buffer, the downtime is almost zero, except for the simple swap of using the buffer.
A circular buffer is a fixed array of buffer slots filled by the producer and emptied by the consumer one slot at a time in ascending order.
To speed up access to a disk, a disk block cache is used by setting aside some main memory buffers that contain the most recently accessed disk blocks. The size is dependent upon application, as speed is important. Blocks critical to performance are kept, as are those who are expected to be used in the near future.
Buffer can thus have two meanings:
- It can be used to decouple a consumer from a producer holds new data generated by the producer and used later by the consumer.
- And it can be used for caching holds a temporary copy of data that already exists on the disk to facilitate faster access.
Data Buffering and Caching was originally found on Access 2 Learn