Demo: What a System Call Costs¶
Ten million one-byte writes to /dev/null, once as a real system call and once as a plain function call.
Writing to /dev/null does no work, so what is left is the cost of the crossing itself.
Run¶
cd ../../../../02-os-types-interface-full/demos/02-os-interface/syscall-overhead
make
./make_syscalls
./make_libcalls
For where the time goes:
The system-call version is roughly seventy times slower.
Ask¶
/dev/nullthrows the byte away. So what is the system-call version actually spending its time on?- Look at the
sysline inperf: half a second against zero. What happened ten million times? - This is the price of the boundary from part 03. Is it worth paying for a one-byte write? For a one-megabyte one?