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?

  1. AWriting in bulk reduces the total amount of data written
  2. BFewer calls cut the fixed per-call overhead
  3. 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.
Practice this topic Back to topic

More OS & Hardware questions

  1. What is the main purpose of giving a CPU a privileged (kernel) mode and a user mode?
  2. What is the mechanism by which applications ask the OS to perform tasks such as file I/O?
  3. What happens when the ecall instruction at the end of the RISC-V code above executes?
  4. Which is the usual distinction between interrupts and exceptions?
  5. Which of the following is asynchronous, occurring at unpredictable times unrelated to the instruction being executed?