Date: Thu, 02 Dec 1999 21:22:54 +0100 From: Poul-Henning Kamp <phk@critter.freebsd.dk> To: peter.jeremy@alcatel.com.au Cc: eischen@vigrid.com, dcs@newsguy.com, arch@freebsd.org Subject: Re: Threads stuff Message-ID: <819.944166174@critter.freebsd.dk> In-Reply-To: Your message of "Fri, 03 Dec 1999 07:13:46 %2B1100." <99Dec3.070619est.40333@border.alcanet.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?819.944166174>