OS & Hardware
When writing small data one byte at a time, why is accumulating it in a user-space buffer and writing in bulk faster than calling a system call each time?
- AWriting in bulk reduces the total amount of data written
- BFewer calls cut the fixed per-call overhead
- CBuffering lets the data be kept without ever being written to the disk
Show answer and explanation
Answer: B. Fewer calls cut the fixed per-call overhead
Every system call requires switching from user to privileged mode, saving registers, checking arguments and returning, a fixed cost paid even for a single byte. Entering the kernel also disturbs cache and TLB contents. Buffering and writing several kilobytes at a time drastically cuts the number of system calls and speeds up the whole process. The total data written is unchanged, and it still ends up on disk.
- A. The total amount of data written is unchanged.
- B. Correct. Fewer calls reduce the fixed per-call overhead.
- C. The data is ultimately written to disk.