Saturday, November 22, 2014

Double Buffering in Standard IO

Standard IO improved performance by maintaining buffers in user space thus avoid making successive system calls.  On the other hand, the down side is that data is required to transfer between the standard IO buffer to the user supplied buffer.

Call like getc triggers a read() call which causes data to be read from the disk to the kernel buffer, copy to the standard IO buffer and finally copy to the buffer passed into the standard IO call.

putc copies the data from the supplied buffer to the standard IO buffer.  The data will then be copied out to kernel buffer via write().

No comments: