gettimeofday() -- user-space vs. system call
Posted Feb 6, 2007 20:06 UTC (Tue) by
AnswerGuy (guest, #1256)
In reply to:
Methodology used by pjm
Parent article:
Comparing Linux and Minix
While gettimeofday() should be one of the simplest system calls in the
universe (and uname() should be another) ... it's even better if you
have a kernel that implemeents these as pre-initialized data mappings
into every process' address space.
Then the libc can just fetch the relevant data from its own address
space and incur no context switch overhead.
This is, of course, a standard memory for speed trade-off. Tridge (of
Samba fame) once described to me a case on some system where he tweaked
a kernel and libc in this way and saw a significant performance improvement
(some Fujitsu hardware?).
(Of course it's possible that the effect would be less dramatic on x86
hardware running Linux --- but it's still an option to consider. If we
did it then I imagine it would be a bit like the VDSO mapping the kernel
is already doing for the latest TLS support. The system call would still
exist for legacy support ... but newer libc updates would check for and
use the extra data area for return such data. (The time of day and
perhaps some other dynamic system-wide information would all be stored
in one or two read-only pages which would be aliased into every user
address space be default ... while process-state info would be mapped
into private pages. Obviously some accomodation for the virtualization
models would have to be made --- so each virtual kernel would have it's
own pages to map into process).
JimD
(
Log in to post comments)