From owner-freebsd-hackers Wed Jul 17 12:16:39 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8752E37B400 for ; Wed, 17 Jul 2002 12:16:36 -0700 (PDT) Received: from snipe.mail.pas.earthlink.net (snipe.mail.pas.earthlink.net [207.217.120.62]) by mx1.FreeBSD.org (Postfix) with ESMTP id 226F343E5E for ; Wed, 17 Jul 2002 12:16:36 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0460.cvx22-bradley.dialup.earthlink.net ([209.179.199.205] helo=mindspring.com) by snipe.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17UuHp-0000nb-00; Wed, 17 Jul 2002 12:16:33 -0700 Message-ID: <3D35C261.1ED2AC46@mindspring.com> Date: Wed, 17 Jul 2002 12:15:45 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Andrei Cojocaru Cc: freebsd-hackers@freebsd.org Subject: Re: Counting the clock cycles References: <00d501c22dc4$57d08b00$0200a8c0@twothousand> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Andrei Cojocaru wrote: > I was asking around in #freebsdhelp on EFNet what the equivalent of > GetTickCount() in the Win32 API is in FreeBSD. > > I need a way to properly determine passage of time that is not affected if I > change the system clock for example. The only way I'm aware that you can do > that is by counting the number of clock cycles since system startup. What > function does that in FreeBSD? I'd also like a Linux way if possible. (that > is a way that will work across all UNIX clones). Thanks and please include > my email in the reply directly since I'm not signed up to this mailing list. Use the Pentium Cycle Counter. Note that power management is going to make it inaccurate as a time base. Give up on the idea that you will have a wall time that is more accurate than the CMOS clock; after you've embraced that, you can learn to stop worrying and love Intel. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message