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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top