From owner-freebsd-hackers Wed Jul 17 12:19:55 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 45FC837B41C for ; Wed, 17 Jul 2002 12:19:49 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1846743E65 for ; Wed, 17 Jul 2002 12:19:49 -0700 (PDT) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id DF577AE30B; Wed, 17 Jul 2002 12:19:48 -0700 (PDT) Date: Wed, 17 Jul 2002 12:19:48 -0700 From: Alfred Perlstein To: Andrei Cojocaru Cc: freebsd-hackers@freebsd.org Subject: Re: Counting the clock cycles Message-ID: <20020717191948.GE77219@elvis.mu.org> References: <00d501c22dc4$57d08b00$0200a8c0@twothousand> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00d501c22dc4$57d08b00$0200a8c0@twothousand> User-Agent: Mutt/1.3.27i 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 [020717 12:02] 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. > Thanks once again. I don't see a platform independant way of doing this, sorry. Have a look at the source for w(1). http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/w/w.c Look at the function pr_header(), it uses SYSCTL to grab system uptime. -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' Tax deductible donations for FreeBSD: http://www.freebsdfoundation.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message