Fine-grained locking for POSIX local sockets (UNIX
davidxu at freebsd.org
Wed May 10 02:38:38 UTC 2006
Tim Kientzle wrote:
> I recall Matt talking about implementing gettimeofday()
> without a syscall. The basic idea is to have the kernel
> record some constants in a page that's mapped across
> all processes, then libc can just read the time from
> a known location.
> It might be nice to combine this with some of the
> other ideas being tossed around here:
> * On each clock tick, store a base time in
> a known location (page mapped read-only, no-execute
> across all memory maps)
> * libc can just read the base time (accurate
> to the clock rate) from a constant. Very, very fast.
> * For higher resolution, the kernel could record
> TSC and CPU clock speed data (per-CPU? Hmmm...)
> and libc could use that to fine-tune the time?
> Still some details I need to think through...
One of the problems to implement it is that atomic operations,
if there are multiple integer needs to be updated by kernel,
userland maybe gets an inconsistent result, the way to avoid the
problem is using two generation numbers.
check do_vgettimeofday(struct timeval * tv):
Another problem is how you tell userland the address of the kernel
page ? do you use fixed address or tell it via program headers like
the PT_TLS set by kernel, check /usr/src/lib/libc/gen/tls.c.
More information about the freebsd-performance