Date: Mon, 10 Nov 1997 13:30:38 -0700 (MST) From: Charles Mott <cmott@srv.net> To: hackers@freebsd.org Subject: Reading kernel memory Message-ID: <Pine.BSF.3.96.971110131427.25875C-100000@darkstar.home>
next in thread | raw e-mail | index | archive | help
I had earlier asked some questions about reducing the overhead in a gettimeofday() system call. One suggestion was to somehow map kernel memory into user space and read the system time variable. I have just tried doing this via the kvm_read() function, and it takes about 200 microseconds on a 386 to do this. In comparison, gettimeofday() takes only about 60 microseconds on the same machine. So if one really wants to map a kernel variable to user space, I am guessing something more sophisticated than the kvm routines are needed. [Note: originally I became interested in this as a way to speed up libalias a little bit, but this is really irrelevant now. I am more interested in understanding some of the underlying principles here. Please forgive my lack of practicality.] Wandering through the kernel source code, I have also discovered that gettimeofday() actaully invokes a microtime() call which actually tries to determine the time by reading a timer and using it to refine the kernel time variable. I was quite impressed by this, as previous experience with Linux indicates they just use a time variable updated every kernel quantum. The FreeBSD kernel treats the subject of time quite seriously. Charles Mott
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.971110131427.25875C-100000>