From owner-freebsd-hackers Tue Nov 4 04:31:23 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id EAA08019 for hackers-outgoing; Tue, 4 Nov 1997 04:31:23 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from srv.net (snake.srv.net [199.104.81.3]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id EAA08012 for ; Tue, 4 Nov 1997 04:31:15 -0800 (PST) (envelope-from cmott@srv.net) Received: from darkstar.home ([208.141.171.158]) by srv.net (8.8.5/8.8.5) with SMTP id FAA32082 for ; Tue, 4 Nov 1997 05:31:13 -0700 (MST) Date: Tue, 4 Nov 1997 05:30:37 -0700 (MST) From: Charles Mott X-Sender: cmott@darkstar.home To: hackers@hub.freebsd.org Subject: Re: gettimeofday() overhead In-Reply-To: <199711041024.CAA01699@hub.freebsd.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Tue, 4 Nov 1997, Jeffrey Hsu wrote: > If you had threads, you could have a thread which calls gettimeofday() > once a second, storing it into a variable. This is what Sun's Java > Web Server does to avoid calling gettimeofday() on each web hit. > > 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 try setting a timer to go off once a second and update your > cached time of day variable. >