Basically on UNIX, read() and write() functions are unbuffered I/O,
and there are Standard I/O, which is buffered I/O.
But, read() and write() functions use buffer cache which is in kernel before doing real I/O(I/O to real device), and real I/O happens using buffer cache. It's using buffer.
I heard unbuffered I/O means I/O happens on char-by-char to real device.
Then, why read() and write() functions are unbuffered I/O, even though it is using buffer cache?
Basically the term "buffering" here means "a place where data is stored when going to/from the kernel", i.e. to avoid doing one system call for each I/O call, the buffered functions use a buffer between.
What the kernel does with the data is not something the standard library can do much about.
It would be possible to do a 1:1 mapping of read/write calls at the standard library's level (i.e. fread() and friends) to read()/write() calls on the underlying file descriptor; the term buffering is telling you that is not what you can expect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With