Buffer is a region of memory used to temporarily hold data while it is being moved from one place to another. A buffer is used when moving data between processes within a computer. Majority of buffers are implemented in software. Buffers are generally used when there is a difference between the rate at which data is received and the rate at which it can be processed. If we remove buffers, then either we will have data loss, or we will have lower bandwidth utilization.
What is Buffering ?
In Buffering, Whether the communication is direct or indirect, message exchanged by communicating processes reside in a temporary queue.
Types of Buffering :
- Zero Capacity –
This queue cannot keep any message waiting in it. Thus it has maximum length 0. For this, a sending process must be blocked until the receiving process receives the message. It is also known as no buffering.
- Bounded Capacity –
This queue has finite length n. Thus it can have n messages waiting in it. If the queue is not full, new message can be placed in the queue, and a sending process is not blocked. It is also known as automatic buffering.
- Unbounded Capacity –
This queue has infinite length. Thus any number of messages can wait in it. In such a system, a sending process is never blocked.
Need of Buffering :
- It helps in matching speed between two devices, between which the data is transmitted. For example, a hard disk has to store the file received from the modem.
- It helps the devices with different data transfer size to get adapted to each other.
- It helps devices to manipulate data before sending or receiving.
- It also supports copy semantics.