file streams

B

Bill Cunningham

Is there any benefit to using any of the buffering functions when
reading and writing to disk? For example setlinebuf(). I understand by
default file streams are read as blocks. Does line buffering add any
benefits for certain situations? And what are these "unlocking" versions of
stream functions in the stdio library?

Bill
 
S

Siri Crews

Bill Cunningham said:
Is there any benefit to using any of the buffering functions when
reading and writing to disk? For example setlinebuf(). I understand by

Potentially there's a disk read for every block with a partial write, and a disk
write for each full or partial write. Ideally the kernel, if any, is bufferring
blocks and does the minimal disk activity. If the system has a privileged state
kernel, it needs a context switch everytime a write is called in the kernel.
default file streams are read as blocks. Does line buffering add any
benefits for certain situations? And what are these "unlocking" versions of

Unbufferred or line bufferred reduces the risk of losing partial output if the
program aborts. It can increase the time spent in context switches and disk I/O.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top