What is Buffering?

What is Buffering in Operating Systems?

Buffering is the technique of using a temporary memory area (buffer) to hold data while it is transferred between a fast producer and a slow consumer, or between devices with different speeds. It smooths data flow, reduces waiting time, and allows the CPU to overlap computation with I/O operations.

Why Buffering is Used

  • Matches speed differences between CPU, memory, and I/O devices.
  • Improves throughput by overlapping I/O and processing.
  • Reduces latency spikes and avoids data loss.
  • Supports block-to-stream and stream-to-block data transfers.

Common Types of Buffering

  • Single Buffering: One buffer; simple but may cause waiting.
  • Double Buffering: Two buffers; one fills while the other is processed.
  • Circular (Ring) Buffering: Multiple buffers managed in a loop for continuous data streams.

Examples

  • Print spooler holding print jobs before the printer processes them.
  • Disk I/O buffering to group reads/writes efficiently.
  • Network and audio/video streaming buffers to prevent stutter.
  • Keyboard input buffered before being read by applications.