From owner-freebsd-hackers Tue Nov 4 05:19:12 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id FAA10596 for hackers-outgoing; Tue, 4 Nov 1997 05:19:12 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from word.smith.net.au (ppp13.portal.net.au [202.12.71.113]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id FAA10576 for ; Tue, 4 Nov 1997 05:19:07 -0800 (PST) (envelope-from mike@word.smith.net.au) Received: from word.smith.net.au (localhost [127.0.0.1]) by word.smith.net.au (8.8.7/8.8.5) with ESMTP id XAA00406; Tue, 4 Nov 1997 23:45:13 +1030 (CST) Message-Id: <199711041315.XAA00406@word.smith.net.au> X-Mailer: exmh version 2.0zeta 7/24/97 To: Charles Mott cc: hackers@hub.freebsd.org Subject: Re: gettimeofday() overhead In-reply-to: Your message of "Tue, 04 Nov 1997 05:30:37 PDT." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 04 Nov 1997 23:45:11 +1030 From: Mike Smith Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > If you knew where the time was in kernel memory, you could map it > > into your address space and read it. This is what Digital's X > > server does to timestamp X events. > > For some reason, method number 2 intrigues me. Maybe because it > is probably the lowest overhead yet the most accurate. > > How would one go about doing this? Is it dependent on the > specific kernel build, or would there be a means of automatically > locating and mapping the kernel time variable? You could locate an appropriate variable in kernel space using the kernel symbol table. Unfortunately, this requires access to /dev/kmem, and thus your process must be running as root. IMHO this isn't really an acceptable tradeoff unless the application already requires it. OTOH, if +/- 1 second is good enough, a once-a-second timer and a local call to gettimeofday() would be a simple and straightforward technique, as was also suggested. mike