Reputation: 11094
In UNIX, most of them are say's like read, write, close are unbuffered I/O. I didn't understand why it is called as unbuffered I/O. In UNIX read is a system call. The following is the structure of read.
ssize_t read(int fd, void *buf, size_t count);
read() attempts to read up to count bytes from file descriptor fd into the buffer starting at buf. Even the read function read input like character by character, but finally it is stored in the buffer named here "buf". So, here also buffer is used. So, how read becomes unbuffered I/O.printf function also store the string literal in array called buffer. And once the array reached \n, the buffer will be printed. This mechanism is also similar to read. So, how to classify whether these are the functions are unbuffered and those are buffered. On which basis they are differentiate there functions are buffered and these are unbuffered.
Upvotes: 1
Views: 607
Reputation: 9893
The read
function you provided is part of unbuffered I/O
functions.
The term unbuffered
means that each read
or write
invokes a system call in the kernel.
In case of read
it doesn't read character by character but reads the number of bytes you specified with count
parameter, with a single kernel call.
The goal of the buffered
functions provided by the standard I/O
library is to use the minimum number of read
and write
calls. It also automates the optimal buffer size's count
calculation, for better performance.
Hope, now, its more or less clear.
Upvotes: 0