From owner-freebsd-arch Thu Dec 2 12:25:18 1999 Delivered-To: freebsd-arch@freebsd.org Received: from ns1.yes.no (ns1.yes.no [195.204.136.10]) by hub.freebsd.org (Postfix) with ESMTP id C72F014E0C for ; Thu, 2 Dec 1999 12:25:12 -0800 (PST) (envelope-from eivind@bitbox.follo.net) Received: from bitbox.follo.net (bitbox.follo.net [195.204.143.218]) by ns1.yes.no (8.9.3/8.9.3) with ESMTP id VAA19760 for ; Thu, 2 Dec 1999 21:25:11 +0100 (CET) Received: (from eivind@localhost) by bitbox.follo.net (8.8.8/8.8.6) id VAA85208 for freebsd-arch@freebsd.org; Thu, 2 Dec 1999 21:25:11 +0100 (MET) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.40.131]) by hub.freebsd.org (Postfix) with ESMTP id AFD7014ECA for ; Thu, 2 Dec 1999 12:24:50 -0800 (PST) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.9.3/8.9.2) with ESMTP id VAA00821; Thu, 2 Dec 1999 21:22:54 +0100 (CET) (envelope-from phk@critter.freebsd.dk) To: peter.jeremy@alcatel.com.au Cc: eischen@vigrid.com, dcs@newsguy.com, arch@freebsd.org Subject: Re: Threads stuff In-reply-to: Your message of "Fri, 03 Dec 1999 07:13:46 +1100." <99Dec3.070619est.40333@border.alcanet.com.au> Date: Thu, 02 Dec 1999 21:22:54 +0100 Message-ID: <819.944166174@critter.freebsd.dk> From: Poul-Henning Kamp Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <99Dec3.070619est.40333@border.alcanet.com.au>, Peter Jeremy writes: >On 1999-Dec-03 04:34:29 +1100, Daniel M. Eischen wrote: >On my PII-266, clock_gettime(CLOCK_REALTIME) takes 2.48usec and >gettimeofday() takes 2.42usec - slightly better. Interestingly, in >both cases about 30% of the time is charged as user rather than system >- which suggests that either the kernel->user return is quite slow[*], >or something odd is going on. > >I wouldn't consider either particularly slow (unless you count the >clock cycles taken - around 650). The time it takes depends on the "timecounter" you are using for your timekeeping. I will venture to guess that the above numbers come from a UP machine using the TSC. You can see which timecounter hardware you are using with the command: sysctl kern.timecounter.hardware If the timestamps don't need to be more precise than 1/hz, normally 10msec, there is an extremely fast facility available in the kernel which is currently not exported to userland. It could be exported as a read-only mapped page of memory which would make the call take only a few memory-accesses. For systems where the timecounter is the TSC (normally all Pentium and later non-SMP systems) A precise timestamp could be obtained the same way since the TSC can be read from userland. Let me know if this is worth working on... -- Poul-Henning Kamp FreeBSD coreteam member phk@FreeBSD.ORG "Real hackers run -current on their laptop." FreeBSD -- It will take a long time before progress goes too far! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message