Explain various I/O buffering techniques.

Mumbai University > Computer Engineering > Sem 5 > Operating System

Marks: 10M

Years: Dec 2015

1 Answer

The various I/O buffering techniques are as follows:

1. Single buffering:

  • When a user process issues an I/O request, the O.S assigns a buffer in the system portion of main memory to the operation.

  • In the block oriented devices, the techniques can be used as follows: Input transfers are made to the system buffer. When the transfer is complete, the process moves the block into user space and request another block. This is called reading ahead, it is done in the expectation that the block will be needed sometimes in future.

  • This approach will generally provide a speed up compared to the lack of system buffering. The O.S must keep track of the assignment of system buffers to user processes.

  • Similar considerations apply to block oriented output. When data are being transmitted to a device, they are first copied from user space into the system buffer, from which they will ultimately be written. The requesting process is now free to continue.

  • Suppose T is the time required to input one block and C is the computation time required for input request.

    • Without buffering: Execution time is T+C.
    • Without buffering: Execution time is max [C,T]+M, where M is time requied to move the data from system buffer to user memory.

In stream oriented I/O, it can be used in two ways,

  • Line-at a time fashion. Line- at a time operation is used for scroll made terminals. User inputs one line at a time, with a carriage return signaling at the end of a line.

  • Byte-at a time fashion. Byte-at a time operation is used on forms mode, terminals when each keystroke is significant.

enter image description here

2. Double buffering

  • An improvement over single buffering is by assigning two system buffers to the operations.

  • A process transfers data to one buffer while operating system empties the other as shown in fig.

  • For block oriented transfer execution time is Max[C,T]. It is possible to keep the block oriented device going at full speed.

    • If C<=T, i.e. computation time is less than the time required to input one block.
    • If C>T, i.e. computation time is greater than the time required to input one block, then double buffering ensures that the process will not have to wait on I/O.

For Stream oriented input again two types.

  • For line- at a time I/O, the user process need not be suspendeds for input or output, unless process runs ahead of double buffer.

  • For byte- at a time operations, double buffer offers no advantage over a single buffer of twice the length.

enter image description here

3. Circular buffer

  • Double buffering may be inadequate, if the process performs rapid burst of I/O. When two or more buffers are used.

  • The collection of buffers is called as a circular buffer, with each buffer being one unit in the circular buffer.

enter image description here

Please log in to add an answer.