From owner-freebsd-hackers Thu Jul 15 11:25:32 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from zibbi.mikom.csir.co.za (zibbi.mikom.csir.co.za [146.64.24.58]) by hub.freebsd.org (Postfix) with ESMTP id A5137155CC for ; Thu, 15 Jul 1999 11:25:24 -0700 (PDT) (envelope-from jhay@zibbi.mikom.csir.co.za) Received: (from jhay@localhost) by zibbi.mikom.csir.co.za (8.9.3/8.9.3) id UAA70423; Thu, 15 Jul 1999 20:24:58 +0200 (SAT) (envelope-from jhay) From: John Hay Message-Id: <199907151824.UAA70423@zibbi.mikom.csir.co.za> Subject: Re: Advice on deriving accurate time values from the kernel? In-Reply-To: <378E10C4.9AD7979E@vulture.dmem.strath.ac.uk> from Jennifer Clark at "Jul 15, 1999 05:48:04 pm" To: jen@vulture.dmem.strath.ac.uk (Jennifer Clark) Date: Thu, 15 Jul 1999 20:24:58 +0200 (SAT) Cc: freebsd-hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG If you only want to timestamp events and not generate the event, you can use microtime() or nanotime(). On a 400MHz PII non-SMP you should get 2.5 ns resolution with nanotime(). On a normal kernel with kern.timecounter.method at the default of 0, the get... versions give you time at the last tick or even worse, so they are no good for that. John -- John Hay -- John.Hay@mikom.csir.co.za > Hi, > > I am in the process of developing a device driver for the purpose of > stepper motor control. The timing of each pulse is determined by > external timing hardware on an I/O board, which will fire an interrupt > after the time requested. Using this method, I am able to generate > streams of pulses at approximately 5000Hz on a Pentium II 400MHz system. > > Everything seems to be working well, but I'd really like to gather some > accurate timing data in order to derive some statistics to from the > system. Intuition tells me I'll need a clock with a tick rate of at > least 20000 Hz to derive this. > > So, is such a thing available in the kernel? I've searched through > various mailing list archives and have found reference to the "HZ" > option to the kernel, which works to a point. However, it is not ideal > as setting HZ to high values generates far too much kernel overhead. > Also being considered is additional external timing hardware, but this > is something I'd rather avoid for many reasons. > > What I am after is not a "timer" as such - all I need to do is derive a > time value at an initial time, and a subsequent value at a later time. > I've used "getmicrouptime", but this appears dependent on the "Hz" > option, and as such is of limited use. > > I've just had some input from a colleauge who has suggested using the > Pentium profiling registers, which we are currently investigating... > > Any advice gratefully received, > > -- > Jennifer Clark > http://telepresence.dmem.strath.ac.uk > http://www.crmjewellery.co.uk > http://www.furniturenet.co.uk To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message