Input Output Buffering in Operating System


Input/output (I/O) buffering is a mechanism that improves the throughput of input and output operations. It is implemented directly in hardware and the corresponding drivers (hence the block devices found in Unix-like systems), and is also ubiquitous among programming language standard libraries.



Uses of I/O Buffering-

  1. Buffering is done to deal effectively with a speed mismatch between the producer and consumer of the data stream.
  2. A buffer is produced in the main memory to heap up the bytes received from the modem.
  3. After receiving the data in the buffer, the data get transferred to disk from the buffer in a single operation.
  4. When both the buffers completed their tasks, then the modem switches back to the first buffer while the data from the second buffer get transferred to the disk.
  5. The use of two buffers disintegrates the producer and the consumer of the data thus minimizes the time requirements between them.
  6. Buffering also provides variations for devices that have different data transfer sizes.
  7. This process of data transfer is not instantaneous, therefore the modem needs another buffer in order to store additional incoming data.
  8. When the first buffer got filled, then it is requested to transfer the data to disk.
  9. The modem then starts filling the additional incoming data in the second buffer while the data in the first buffer getting transferred to the disk.

Types of various I/O buffering techniques-

1. Single buffer :

A buffer is provided by the operating system to the system portion of the main memory.

Block oriented device –
  • System buffer takes the input.
  • After taking the input, the block gets transferred to the user space by the process and then the process requests for another block.
  • Two blocks work simultaneously, when one block of data is processed by the user process, the next block is being read in.
  • OS can swap the processes.
  • OS can record the data of system buffer to user processes.
Stream oriented device –
  • Line- at a time operation is used for scroll made terminals. The user inputs one line at a time, with a carriage return signaling at the end of a line.
  • Byte-at a time operation is used on forms mode, terminals when each keystroke is significant.

Untitled Diagram 1 61

2. Double buffer –

Block oriented –
  • There are two buffers in the system.
  • One buffer is used by the driver or controller to store data while waiting for it to be taken by a higher level of the hierarchy.
  • Other buffer is used to store data from the lower-level module.
  • Double buffering is also known as buffer swapping.
  • A major disadvantage of double buffering is that the complexity of the process get increased.
  • If the process performs rapid bursts of I/O, then using double buffering may be deficient.
Stream oriented –
  • Line- at a time I/O, the user process need not be suspended for input or output, unless the process runs ahead of the double buffer.
  • Byte- at a time operation, double buffer offers no advantage over a single buffer of twice the length.

Untitled Diagram 5 1 11

3. Circular buffer –

  • When more than two buffers are used, the collection of buffers is itself referred to as a circular buffer.
  • In this, the data do not directly passed from the producer to the consumer because the data would change due to overwriting of buffers before they had been consumed.
  • The producer can only fill up to buffer i-1 while data in buffer i is waiting to be consumed.

Untitled Diagram 8 2



What is Cache Memory Organization   

What is Program Design
Explain File Allocation Methods


Tygot Adjustable Aluminium Alloy Tripod Stand Holder for Mobile Phones & Camera, 360 mm -1050 mm, 1/4 inch Screw + Mobile Holde